-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponents.rb
197 lines (172 loc) · 3.49 KB
/
components.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
class DyingEvent; end
class Debug; end
class BackgroundBlob; end
class Monster; end
class ColorSource; end
class SuperColorSource; end
class Bouncy; end
class BlackHole; end
class Death; end
class Particle; end
class EmitParticlesEvent
attr_accessor :color, :target, :intensity, :speed, :size
def initialize(color:, target:nil, intensity: 5, speed: nil, size: nil)
@color = color
@target = target
@intensity = intensity
@speed = speed
@size = size
end
end
class ChangeColorEvent; end
class Rainbow
attr_accessor :colors, :color_index
def initialize(colors:)
@colors = colors
@color_index = 0
end
end
class MovableTile
attr_accessor :path, :vel, :world_target, :dir_vec, :path_target
def initialize(path:, start_node:, dir_vec:)
@path = path
@vel = vec(0, 0)
@path_target = start_node
@dir_vec = dir_vec
end
end
class Exit
attr_accessor :open
def initialize(open:false)
@open = open
end
end
class EntityTarget
attr_accessor :id
def initialize(id)
@id = id
end
end
class PlatformPosition
attr_accessor :last_grounded_at, :last_tile_bouncy,
:jump_time, :last_jump
def initialize
@last_grounded_at = -1
@last_tile_bouncy = false
@jump_time = 0
@last_jump = 0
end
end
class Camera
attr_accessor :scale, :target_id, :mode
MODES = [
AUTOFIT = :autofit,
FREE = :free
]
def initialize(target_id:,scale:1, mode: AUTOFIT)
@scale = scale
@target_id = target_id
@mode = mode
end
end
class ZoomCameraOperation
attr_accessor :scale, :duration, :ttl, :target_scale, :target_x, :target_y
def initialize(scale:, duration:, target_x:, target_y:)
@scale = 0
@duration = duration
@ttl = duration
@target_scale = scale
@target_x = target_x
@target_y = target_y
end
end
class Position
attr_accessor :x, :y, :z
def initialize(x,y,z=2)
@x = x
@y = y
@z = z
end
def to_vec
vec(@x, @y)
end
def nearby(dx,dy)
Position.new @x + rand(dx*2) - dx,
@y + rand(dy*2) - dy, @z
end
end
class Velocity < Vec
end
class JoyColor
attr_accessor :color
def initialize(color)
@color = color
end
end
class ColorSink < JoyColor; end
class Boxed
attr_accessor :width, :height,
:squished_y_at, :squish_height, :squish_y_amount, :squish_y_dir,
:squished_x_at, :squish_width, :squish_x_amount, :squish_x_dir
def initialize(width,height)
@width = width
@height = height
@squish_height = 0
@squish_y_amount = 0
@squish_y_dir = 0
@squish_width = 0
@squish_x_amount = 0
@squish_x_dir = 0
end
def h
@height
end
def w
@width
end
end
class Border
attr_accessor :width, :height
def initialize(width,height)
@width = width
@height = height
end
end
class JoyImage
attr_reader :name, :image
def initialize(name)
@name = name
@image = Gosu::Image.new name
end
end
class LevelTimer; end
class Timed
attr_accessor :accumulated_time_in_ms
def initialize
@accumulated_time_in_ms = 0
end
end
class Label
attr_accessor :text, :size, :font
def initialize(size:,text:"",font:nil)
@size = size
@font = font
@text = text
end
end
class Timer
attr_accessor :ttl, :repeat, :total, :event, :name, :expires_at
def initialize(name, ttl, repeat, event = nil)
@name = name
@total = ttl
@ttl = ttl
@repeat = repeat
@event = event
end
end
class SoundEffectEvent
attr_accessor :sound_to_play
def initialize(sound_to_play)
@sound_to_play = sound_to_play
end
end