ruby-ogre 0.0.2-x86-linux → 0.0.3-x86-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +80 -5
- data/Rakefile +26 -19
- data/bindings/ogre/interface/Rakefile +22 -0
- data/bindings/ogre/interface/ogre.i +3 -1
- data/bindings/ogre/interface/ogre_wrap.cpp +99671 -17485
- data/bindings/ogre/interface/ogre_wrap.o +0 -0
- data/bindings/ogrebites/interface/Rakefile +22 -0
- data/bindings/ogrebites/interface/ogrebites.i +1 -1
- data/bindings/ogrebites/interface/ogrebites_wrap.cpp +728 -728
- data/bindings/ogrebites/interface/ogrebites_wrap.h +2 -2
- data/bindings/ogrebites/interface/ogrebites_wrap.o +0 -0
- data/bindings/ois/interface/Rakefile +22 -0
- data/bindings/ois/interface/ois.i +1 -1
- data/bindings/ois/interface/ois_wrap.cpp +553 -553
- data/bindings/ois/interface/ois_wrap.h +2 -2
- data/bindings/ois/interface/ois_wrap.o +0 -0
- data/bindings/procedural/interface/Rakefile +22 -0
- data/bindings/procedural/interface/procedural.i +1 -1
- data/bindings/procedural/interface/procedural_wrap.cpp +1247 -1247
- data/bindings/procedural/interface/procedural_wrap.o +0 -0
- data/lib/{Ogre.so → ogre.so} +0 -0
- data/lib/ogre_config.rb +37 -0
- data/lib/ogrebites.so +0 -0
- data/lib/{OIS.so → ois.so} +0 -0
- data/lib/{Procedural.so → procedural.so} +0 -0
- data/lib/{Version.rb → version.rb} +1 -1
- data/sample/charactor/camera_mover.rb +184 -0
- data/sample/{Charactor → charactor}/plugins.cfg +0 -0
- data/sample/{Charactor → charactor}/resources.cfg +0 -0
- data/sample/{Charactor → charactor}/sinbad +1 -1
- data/sample/charactor/sinbad.rb +246 -0
- data/sample/{Charactor → charactor}/sinbad.win +1 -1
- data/sample/{Charactor/SinbadCharacter.rb → charactor/sinbad_character.rb} +125 -125
- data/sample/charactor/ui_listener.rb +65 -0
- metadata +22 -21
- data/bindings/ogre/interface/Makefile +0 -19
- data/bindings/ogrebites/interface/Makefile +0 -19
- data/bindings/ois/interface/Makefile +0 -19
- data/bindings/procedural/interface/Makefile +0 -19
- data/lib/OgreBites.so +0 -0
- data/lib/OgreConfig.rb +0 -37
- data/sample/Charactor/CameraMover.rb +0 -184
- data/sample/Charactor/Sinbad.rb +0 -246
- data/sample/Charactor/UiListener.rb +0 -65
@@ -24,39 +24,39 @@ class SinbadCharacter
|
|
24
24
|
ANIM_NONE = 13
|
25
25
|
|
26
26
|
def initialize(sceneMgr, cameraMover)
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
setup_body(sceneMgr)
|
28
|
+
setup_camera(cameraMover)
|
29
|
+
setup_animations()
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def setup_body(sceneMgr)
|
33
33
|
# create main model
|
34
|
-
@bodyNode = sceneMgr.
|
35
|
-
@bodyEnt = sceneMgr.
|
36
|
-
@bodyNode.
|
34
|
+
@bodyNode = sceneMgr.get_root_scene_node().create_child_scene_node(Ogre::Vector3.UNIT_Y * CHAR_HEIGHT)
|
35
|
+
@bodyEnt = sceneMgr.create_entity("SinbadBody", "Sinbad.mesh")
|
36
|
+
@bodyNode.attach_object(@bodyEnt)
|
37
37
|
|
38
38
|
# create swords and attach to sheath
|
39
|
-
@sword1 = sceneMgr.
|
40
|
-
@sword2 = sceneMgr.
|
41
|
-
@bodyEnt.
|
42
|
-
@bodyEnt.
|
39
|
+
@sword1 = sceneMgr.create_entity("SinbadSword1", "Sword.mesh")
|
40
|
+
@sword2 = sceneMgr.create_entity("SinbadSword2", "Sword.mesh")
|
41
|
+
@bodyEnt.attach_object_to_bone("Sheath.L", @sword1)
|
42
|
+
@bodyEnt.attach_object_to_bone("Sheath.R", @sword2)
|
43
43
|
|
44
44
|
# create a couple of ribbon trails for the swords, just for fun
|
45
45
|
params = {}
|
46
46
|
#params = Ogre::NameValuePairList.new
|
47
47
|
params["numberOfChains"] = "2"
|
48
48
|
params["maxElements"] = "80"
|
49
|
-
@swordTrail = Ogre::RibbonTrail::cast(sceneMgr.
|
50
|
-
@swordTrail.
|
51
|
-
@swordTrail.
|
52
|
-
@swordTrail.
|
53
|
-
sceneMgr.
|
49
|
+
@swordTrail = Ogre::RibbonTrail::cast(sceneMgr.create_movable_object("RibbonTrail", params))
|
50
|
+
@swordTrail.set_material_name("Examples/LightRibbonTrail")
|
51
|
+
@swordTrail.set_trail_length(20)
|
52
|
+
@swordTrail.set_visible(false)
|
53
|
+
sceneMgr.get_root_scene_node().attach_object(@swordTrail)
|
54
54
|
|
55
55
|
2.times.each {|i|
|
56
|
-
@swordTrail.
|
57
|
-
@swordTrail.
|
58
|
-
@swordTrail.
|
59
|
-
@swordTrail.
|
56
|
+
@swordTrail.set_initial_colour(i, 1, 0.8, 0)
|
57
|
+
@swordTrail.set_colour_change(i, 0.75, 1.25, 1.25, 1.25)
|
58
|
+
@swordTrail.set_width_change(i, 1)
|
59
|
+
@swordTrail.set_initial_width(i, 0.5)
|
60
60
|
}
|
61
61
|
|
62
62
|
@keyDirection = Ogre::Vector3.new(0, 0, 0)
|
@@ -64,40 +64,40 @@ class SinbadCharacter
|
|
64
64
|
@timer = 0
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def setup_camera(cameraMover)
|
68
68
|
@cameraMover = cameraMover
|
69
|
-
cameraMover.
|
70
|
-
cameraMover.
|
69
|
+
cameraMover.set_style(CameraMover::CS_TPS)
|
70
|
+
cameraMover.set_target(@bodyNode)
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
73
|
+
def setup_animations()
|
74
74
|
@anims = []
|
75
75
|
@fadingIn = []
|
76
76
|
@fadingOut = []
|
77
77
|
@baseAnimID = 0
|
78
78
|
@topAnimID = 0
|
79
79
|
|
80
|
-
@bodyEnt.
|
80
|
+
@bodyEnt.get_skeleton().set_blend_mode(Ogre::ANIMBLEND_CUMULATIVE)
|
81
81
|
animNames =["IdleBase", "IdleTop", "RunBase", "RunTop", "HandsClosed", "HandsRelaxed", "DrawSwords",
|
82
82
|
"SliceVertical", "SliceHorizontal", "Dance", "JumpStart", "JumpLoop", "JumpEnd"]
|
83
83
|
animNames.each_with_index {|name, i|
|
84
|
-
@anims[i] = @bodyEnt.
|
85
|
-
@anims[i].
|
84
|
+
@anims[i] = @bodyEnt.get_animation_state(name)
|
85
|
+
@anims[i].set_loop(true)
|
86
86
|
@fadingIn[i] = false
|
87
87
|
@fadingOut[i] = false
|
88
88
|
}
|
89
89
|
|
90
90
|
# start off in the idle state (top and bottom together)
|
91
|
-
|
92
|
-
|
91
|
+
set_base_animation(ANIM_IDLE_BASE)
|
92
|
+
set_top_animation(ANIM_IDLE_TOP)
|
93
93
|
|
94
94
|
# relax the hands since we're not holding anything
|
95
|
-
@anims[ANIM_HANDS_RELAXED].
|
95
|
+
@anims[ANIM_HANDS_RELAXED].set_enabled(true)
|
96
96
|
|
97
97
|
@swordsDrawn = false
|
98
98
|
end
|
99
99
|
|
100
|
-
def
|
100
|
+
def set_base_animation(id, reset = false)
|
101
101
|
if (@baseAnimID >= 0 && @baseAnimID < NUM_ANIMS)
|
102
102
|
# if we have an old animation, fade it out
|
103
103
|
@fadingIn[@baseAnimID] = false
|
@@ -108,15 +108,15 @@ class SinbadCharacter
|
|
108
108
|
|
109
109
|
if (id != ANIM_NONE)
|
110
110
|
# if we have a new animation, enable it and fade it in
|
111
|
-
@anims[id].
|
112
|
-
@anims[id].
|
111
|
+
@anims[id].set_enabled(true)
|
112
|
+
@anims[id].set_weight(0)
|
113
113
|
@fadingOut[id] = false
|
114
114
|
@fadingIn[id] = true
|
115
|
-
@anims[id].
|
115
|
+
@anims[id].set_time_position(0) if (reset)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
def
|
119
|
+
def set_top_animation(id, reset = false)
|
120
120
|
if (@topAnimID >= 0 && @topAnimID < NUM_ANIMS)
|
121
121
|
# if we have an old animation, fade it out
|
122
122
|
@fadingIn[@topAnimID] = false
|
@@ -127,31 +127,31 @@ class SinbadCharacter
|
|
127
127
|
|
128
128
|
if (id != ANIM_NONE)
|
129
129
|
# if we have a new animation, enable it and fade it in
|
130
|
-
@anims[id].
|
131
|
-
@anims[id].
|
130
|
+
@anims[id].set_enabled(true)
|
131
|
+
@anims[id].set_weight(0)
|
132
132
|
@fadingOut[id] = false
|
133
133
|
@fadingIn[id] = true
|
134
|
-
@anims[id].
|
134
|
+
@anims[id].set_time_position(0) if (reset)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
def
|
138
|
+
def update_body(deltaTime)
|
139
139
|
@goalDirection = Ogre::Vector3.new(0, 0, 0) # we will calculate this
|
140
140
|
|
141
|
-
if (!@keyDirection.
|
141
|
+
if (!@keyDirection.is_zero_length && @baseAnimID != ANIM_DANCE)
|
142
142
|
|
143
143
|
# calculate actually goal direction in world based on player's key directions
|
144
|
-
@goalDirection += @cameraMover.camera.
|
145
|
-
@goalDirection += @cameraMover.camera.
|
144
|
+
@goalDirection += @cameraMover.camera.get_orientation().z_axis() * @keyDirection.z
|
145
|
+
@goalDirection += @cameraMover.camera.get_orientation().x_axis() * @keyDirection.x
|
146
146
|
@goalDirection.y = 0
|
147
147
|
@goalDirection.normalise()
|
148
148
|
|
149
|
-
zDirection = @cameraMover.camera.
|
149
|
+
zDirection = @cameraMover.camera.get_orientation().z_axis()
|
150
150
|
|
151
|
-
toGoal = @bodyNode.
|
151
|
+
toGoal = @bodyNode.get_orientation().z_axis().get_rotation_to(@goalDirection)
|
152
152
|
|
153
153
|
# calculate how much the character has to turn to face goal direction
|
154
|
-
yawToGoal = toGoal.
|
154
|
+
yawToGoal = toGoal.get_yaw().value_degrees()
|
155
155
|
# this is how much the character CAN turn this frame
|
156
156
|
yawAtSpeed = yawToGoal / yawToGoal.abs * deltaTime * TURN_SPEED
|
157
157
|
# reduce "turnability" if we're in midair
|
@@ -164,10 +164,10 @@ class SinbadCharacter
|
|
164
164
|
yawToGoal = [0, [yawToGoal, yawAtSpeed].min].max
|
165
165
|
end
|
166
166
|
|
167
|
-
@bodyNode.yaw(Ogre::Radian.new(Ogre::Degree.new(yawToGoal).
|
167
|
+
@bodyNode.yaw(Ogre::Radian.new(Ogre::Degree.new(yawToGoal).value_radians()))
|
168
168
|
|
169
169
|
# move in current body direction (not the goal direction)
|
170
|
-
@bodyNode.translate(0, 0, deltaTime * RUN_SPEED * @anims[@baseAnimID].
|
170
|
+
@bodyNode.translate(0, 0, deltaTime * RUN_SPEED * @anims[@baseAnimID].get_weight(),
|
171
171
|
Ogre::Node::TS_LOCAL)
|
172
172
|
end
|
173
173
|
|
@@ -176,18 +176,18 @@ class SinbadCharacter
|
|
176
176
|
@bodyNode.translate(0, @verticalVelocity * deltaTime, 0, Ogre::Node::TS_LOCAL)
|
177
177
|
@verticalVelocity -= GRAVITY * deltaTime;
|
178
178
|
|
179
|
-
pos = @bodyNode.
|
179
|
+
pos = @bodyNode.get_position()
|
180
180
|
if (pos.y <= CHAR_HEIGHT)
|
181
181
|
# if we've hit the ground, change to landing state
|
182
182
|
pos.y = CHAR_HEIGHT
|
183
|
-
@bodyNode.
|
184
|
-
|
183
|
+
@bodyNode.set_position(pos)
|
184
|
+
set_base_animation(ANIM_JUMP_END, true)
|
185
185
|
@timer = 0
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
-
def
|
190
|
+
def update_animations(deltaTime)
|
191
191
|
baseAnimSpeed = 1
|
192
192
|
topAnimSpeed = 1
|
193
193
|
|
@@ -198,77 +198,77 @@ class SinbadCharacter
|
|
198
198
|
topAnimSpeed = @swordsDrawn ? -1 : 1
|
199
199
|
|
200
200
|
# half-way through the animation is when the hand grasps the handles...
|
201
|
-
if (@timer >= @anims[@topAnimID].
|
202
|
-
@timer - deltaTime < @anims[@topAnimID].
|
201
|
+
if (@timer >= @anims[@topAnimID].get_length() / 2 &&
|
202
|
+
@timer - deltaTime < @anims[@topAnimID].get_length() / 2)
|
203
203
|
# so transfer the swords from the sheaths to the hands
|
204
|
-
@bodyEnt.
|
205
|
-
@bodyEnt.
|
206
|
-
@bodyEnt.
|
204
|
+
@bodyEnt.detach_all_objects_from_bone()
|
205
|
+
@bodyEnt.attach_object_to_bone(@swordsDrawn ? "Sheath.L" : "Handle.L", @sword1)
|
206
|
+
@bodyEnt.attach_object_to_bone(@swordsDrawn ? "Sheath.R" : "Handle.R", @sword2)
|
207
207
|
# change the hand state to grab or let go
|
208
|
-
@anims[ANIM_HANDS_CLOSED].
|
209
|
-
@anims[ANIM_HANDS_RELAXED].
|
208
|
+
@anims[ANIM_HANDS_CLOSED].set_enabled(!@swordsDrawn)
|
209
|
+
@anims[ANIM_HANDS_RELAXED].set_enabled(@swordsDrawn)
|
210
210
|
|
211
211
|
# toggle sword trails
|
212
212
|
if (@swordsDrawn)
|
213
|
-
@swordTrail.
|
214
|
-
@swordTrail.
|
215
|
-
@swordTrail.
|
213
|
+
@swordTrail.set_visible(false)
|
214
|
+
@swordTrail.remove_node(@sword1.get_parent_node())
|
215
|
+
@swordTrail.remove_node(@sword2.get_parent_node())
|
216
216
|
else
|
217
|
-
@swordTrail.
|
218
|
-
@swordTrail.
|
219
|
-
@swordTrail.
|
217
|
+
@swordTrail.set_visible(true)
|
218
|
+
@swordTrail.add_node(@sword1.get_parent_node())
|
219
|
+
@swordTrail.add_node(@sword2.get_parent_node())
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
-
if (@timer >= @anims[@topAnimID].
|
223
|
+
if (@timer >= @anims[@topAnimID].get_length())
|
224
224
|
# animation is finished, so return to what we were doing before
|
225
225
|
if (@baseAnimID == ANIM_IDLE_BASE)
|
226
|
-
|
226
|
+
set_top_animation(ANIM_IDLE_TOP)
|
227
227
|
else
|
228
|
-
|
229
|
-
@anims[ANIM_RUN_TOP].
|
228
|
+
set_top_animation(ANIM_RUN_TOP)
|
229
|
+
@anims[ANIM_RUN_TOP].set_time_position(@anims[ANIM_RUN_BASE].get_time_position())
|
230
230
|
end
|
231
231
|
@swordsDrawn = !@swordsDrawn
|
232
232
|
end
|
233
233
|
|
234
234
|
elsif (@topAnimID == ANIM_SLICE_VERTICAL || @topAnimID == ANIM_SLICE_HORIZONTAL)
|
235
|
-
if (@timer >= @anims[@topAnimID].
|
235
|
+
if (@timer >= @anims[@topAnimID].get_length())
|
236
236
|
# animation is finished, so return to what we were doing before
|
237
237
|
if (@baseAnimID == ANIM_IDLE_BASE)
|
238
|
-
|
238
|
+
set_top_animation(ANIM_IDLE_TOP)
|
239
239
|
else
|
240
|
-
|
241
|
-
@anims[ANIM_RUN_TOP].
|
240
|
+
set_top_animation(ANIM_RUN_TOP)
|
241
|
+
@anims[ANIM_RUN_TOP].set_time_position(@anims[ANIM_RUN_BASE].get_time_position())
|
242
242
|
end
|
243
243
|
end
|
244
244
|
# don't sway hips from side to side when slicing. that's just embarrasing.
|
245
245
|
baseAnimSpeed = 0 if (@baseAnimID == ANIM_IDLE_BASE)
|
246
246
|
|
247
247
|
elsif (@baseAnimID == ANIM_JUMP_START)
|
248
|
-
if (@timer >= @anims[@baseAnimID].
|
248
|
+
if (@timer >= @anims[@baseAnimID].get_length())
|
249
249
|
# takeoff animation finished, so time to leave the ground!
|
250
|
-
|
250
|
+
set_base_animation(ANIM_JUMP_LOOP, true)
|
251
251
|
# apply a jump acceleration to the character
|
252
252
|
@verticalVelocity = JUMP_ACCEL
|
253
253
|
end
|
254
254
|
elsif (@baseAnimID == ANIM_JUMP_END)
|
255
|
-
if (@timer >= @anims[@baseAnimID].
|
255
|
+
if (@timer >= @anims[@baseAnimID].get_length())
|
256
256
|
# safely landed, so go back to running or idling
|
257
|
-
if (@keyDirection.
|
258
|
-
|
259
|
-
|
257
|
+
if (@keyDirection.is_zero_length)
|
258
|
+
set_base_animation(ANIM_IDLE_BASE)
|
259
|
+
set_top_animation(ANIM_IDLE_TOP)
|
260
260
|
else
|
261
|
-
|
262
|
-
|
261
|
+
set_base_animation(ANIM_RUN_BASE, true)
|
262
|
+
set_top_animation(ANIM_RUN_TOP, true)
|
263
263
|
end
|
264
264
|
end
|
265
265
|
end
|
266
266
|
# increment the current base and top animation times
|
267
|
-
@anims[@baseAnimID].
|
268
|
-
@anims[@topAnimID].
|
267
|
+
@anims[@baseAnimID].add_time(deltaTime * baseAnimSpeed) if (@baseAnimID != ANIM_NONE)
|
268
|
+
@anims[@topAnimID].add_time(deltaTime * topAnimSpeed) if (@topAnimID != ANIM_NONE)
|
269
269
|
|
270
270
|
# apply smooth transitioning between our animations
|
271
|
-
|
271
|
+
fade_animations(deltaTime)
|
272
272
|
end
|
273
273
|
|
274
274
|
def clamp(value, min, max)
|
@@ -277,100 +277,100 @@ class SinbadCharacter
|
|
277
277
|
return value
|
278
278
|
end
|
279
279
|
|
280
|
-
def
|
280
|
+
def fade_animations(deltaTime)
|
281
281
|
NUM_ANIMS.times {|i|
|
282
282
|
if (@fadingIn[i])
|
283
283
|
# slowly fade this animation in until it has full weight
|
284
|
-
newWeight = @anims[i].
|
285
|
-
@anims[i].
|
284
|
+
newWeight = @anims[i].get_weight() + deltaTime * ANIM_FADE_SPEED
|
285
|
+
@anims[i].set_weight(clamp(newWeight, 0, 1))
|
286
286
|
@fadingIn[i] = false if (newWeight >= 1)
|
287
287
|
|
288
288
|
elsif (@fadingOut[i])
|
289
289
|
# slowly fade this animation out until it has no weight, and then disable it
|
290
|
-
newWeight = @anims[i].
|
291
|
-
@anims[i].
|
290
|
+
newWeight = @anims[i].get_weight() - deltaTime * ANIM_FADE_SPEED
|
291
|
+
@anims[i].set_weight(clamp(newWeight, 0, 1))
|
292
292
|
if (newWeight <= 0)
|
293
|
-
@anims[i].
|
293
|
+
@anims[i].set_enabled(false)
|
294
294
|
@fadingOut[i] = false
|
295
295
|
end
|
296
296
|
end
|
297
297
|
}
|
298
298
|
end
|
299
299
|
|
300
|
-
def
|
301
|
-
|
302
|
-
|
300
|
+
def add_time(delta)
|
301
|
+
update_body(delta)
|
302
|
+
update_animations(delta)
|
303
303
|
end
|
304
304
|
|
305
|
-
def
|
306
|
-
if (evt.key ==
|
305
|
+
def inject_key_down(evt)
|
306
|
+
if (evt.key == Ois::KC_Q && (@topAnimID == ANIM_IDLE_TOP || @topAnimID == ANIM_RUN_TOP))
|
307
307
|
# take swords out (or put them back, since it's the same animation but reversed)
|
308
|
-
|
308
|
+
set_top_animation(ANIM_DRAW_SWORDS, true)
|
309
309
|
@timer = 0
|
310
|
-
elsif (evt.key ==
|
310
|
+
elsif (evt.key == Ois::KC_E && !@swordsDrawn)
|
311
311
|
if (@topAnimID == ANIM_IDLE_TOP || @topAnimID == ANIM_RUN_TOP)
|
312
312
|
# start dancing
|
313
|
-
|
314
|
-
|
313
|
+
set_base_animation(ANIM_DANCE, true)
|
314
|
+
set_top_animation(ANIM_NONE)
|
315
315
|
# disable hand animation because the dance controls hands
|
316
|
-
@anims[ANIM_HANDS_RELAXED].
|
316
|
+
@anims[ANIM_HANDS_RELAXED].set_enabled(false)
|
317
317
|
elsif (@baseAnimID == ANIM_DANCE)
|
318
318
|
# stop dancing
|
319
|
-
|
320
|
-
|
319
|
+
set_base_animation(ANIM_IDLE_BASE)
|
320
|
+
set_top_animation(ANIM_IDLE_TOP)
|
321
321
|
# re-enable hand animation
|
322
|
-
@anims[ANIM_HANDS_RELAXED].
|
322
|
+
@anims[ANIM_HANDS_RELAXED].set_enabled(true)
|
323
323
|
end
|
324
324
|
# keep track of the player's intended direction
|
325
|
-
elsif (evt.key ==
|
325
|
+
elsif (evt.key == Ois::KC_W)
|
326
326
|
@keyDirection.z = -1
|
327
|
-
elsif (evt.key ==
|
327
|
+
elsif (evt.key == Ois::KC_A)
|
328
328
|
@keyDirection.x = -1
|
329
|
-
elsif (evt.key ==
|
329
|
+
elsif (evt.key == Ois::KC_S)
|
330
330
|
@keyDirection.z = 1
|
331
|
-
elsif (evt.key ==
|
331
|
+
elsif (evt.key == Ois::KC_D)
|
332
332
|
@keyDirection.x = 1
|
333
|
-
elsif (evt.key ==
|
333
|
+
elsif (evt.key == Ois::KC_SPACE && (@topAnimID == ANIM_IDLE_TOP || @topAnimID == ANIM_RUN_TOP))
|
334
334
|
# jump if on ground
|
335
|
-
|
336
|
-
|
335
|
+
set_base_animation(ANIM_JUMP_START, true)
|
336
|
+
set_top_animation(ANIM_NONE)
|
337
337
|
@timer = 0
|
338
338
|
end
|
339
339
|
|
340
|
-
if (!@keyDirection.
|
340
|
+
if (!@keyDirection.is_zero_length() && @baseAnimID == ANIM_IDLE_BASE)
|
341
341
|
# start running if not already moving and the player wants to move
|
342
|
-
|
343
|
-
|
342
|
+
set_base_animation(ANIM_RUN_BASE, true)
|
343
|
+
set_top_animation(ANIM_RUN_TOP, true) if (@topAnimID == ANIM_IDLE_TOP)
|
344
344
|
end
|
345
345
|
|
346
346
|
end
|
347
347
|
|
348
|
-
def
|
348
|
+
def inject_key_up(evt)
|
349
349
|
# keep track of the player's intended direction
|
350
|
-
if (evt.key ==
|
350
|
+
if (evt.key == Ois::KC_W && @keyDirection.z == -1)
|
351
351
|
@keyDirection.z = 0
|
352
|
-
elsif (evt.key ==
|
352
|
+
elsif (evt.key == Ois::KC_A && @keyDirection.x == -1)
|
353
353
|
@keyDirection.x = 0
|
354
|
-
elsif (evt.key ==
|
354
|
+
elsif (evt.key == Ois::KC_S && @keyDirection.z == 1)
|
355
355
|
@keyDirection.z = 0
|
356
|
-
elsif (evt.key ==
|
356
|
+
elsif (evt.key == Ois::KC_D && @keyDirection.x == 1)
|
357
357
|
@keyDirection.x = 0
|
358
358
|
end
|
359
359
|
|
360
|
-
if (@keyDirection.
|
360
|
+
if (@keyDirection.is_zero_length() && @baseAnimID == ANIM_RUN_BASE)
|
361
361
|
# stop running if already moving and the player doesn't want to move
|
362
|
-
|
363
|
-
|
362
|
+
set_base_animation(ANIM_IDLE_BASE)
|
363
|
+
set_top_animation(ANIM_IDLE_TOP) if (@topAnimID == ANIM_RUN_TOP)
|
364
364
|
end
|
365
365
|
end
|
366
366
|
|
367
|
-
def
|
367
|
+
def inject_mouse_down(evt, id)
|
368
368
|
if (@swordsDrawn && (@topAnimID == ANIM_IDLE_TOP || @topAnimID == ANIM_RUN_TOP))
|
369
369
|
# if swords are out, and character's not doing something weird, then SLICE!
|
370
|
-
if (id ==
|
371
|
-
|
372
|
-
elsif (id ==
|
373
|
-
|
370
|
+
if (id == Ois::MB_Left)
|
371
|
+
set_top_animation(ANIM_SLICE_VERTICAL, true)
|
372
|
+
elsif (id == Ois::MB_Right)
|
373
|
+
set_top_animation(ANIM_SLICE_HORIZONTAL, true)
|
374
374
|
end
|
375
375
|
@timer = 0
|
376
376
|
end
|