Class: Player

Inherits:
Chingu::GameObject
  • Object
show all
Defined in:
lib/games_paradise/flappy_bird/gosu/player.rb,
lib/games_paradise/gui/gosu/chinguroids/objects.rb,
lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb

Overview

#

Player - main player class

#

Constant Summary collapse

GRAVITY =
#

GRAVITY

#
100
JUMP_TIME =
#

JUMP_TIME

#
0.3
JUMP_POWER =
#

JUMP_POWER

#
-250
INCREASE_GRAVITY =
#

INCREASE_GRAVITY

#
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ Player

#

initialize

#


57
58
59
60
61
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 57

def initialize(window)
  @player_image = load_image(window)
  @window = window
  reset
end

Instance Attribute Details

#deadObject

Returns the value of attribute dead.



31
32
33
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 31

def dead
  @dead
end

#faceObject (readonly)

Returns the value of attribute face.



9
10
11
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 9

def face
  @face
end

#healthObject (readonly)

Returns the value of attribute health.



11
12
13
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 11

def health
  @health
end

#scoreObject (readonly)

Returns the value of attribute score.



11
12
13
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 11

def score
  @score
end

#windowObject (readonly)

Returns the value of attribute window.



9
10
11
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 9

def window
  @window
end

#xObject

Returns the value of attribute x.



29
30
31
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 29

def x
  @x
end

#yObject

Returns the value of attribute y.



30
31
32
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 30

def y
  @y
end

Instance Method Details

#accelerateObject

pressing up arrow causes player to accelerate



53
54
55
56
57
58
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 53

def accelerate  # pressing up arrow causes player to accelerate
   if self.velocity_x <= @max_speed && self.velocity_y <= @max_speed
 		self.velocity_x += Gosu::offset_x(self.angle, @speed)
  	self.velocity_y += Gosu::offset_y(self.angle, @speed)
   end
end

#add_apples_scoreObject

add score when collect apples by player



435
436
437
438
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 435

def add_apples_score
  @score += 50
  @lives += 1 if @lives < 3
end

#add_enemies_scoreObject

add_enemies_score

add score when kill enemies



443
444
445
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 443

def add_enemies_score
  @score += 75
end

#add_injuryObject

add injury when enemies attack



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 467

def add_injury
  case face
  when 'left'
    @x += 4
  when 'right'
    @x -= 4
  when 'up'
    @y += 4
  when 'down'
    @y -= 4
  end
  @stamina -= 5
  if @stamina <= 0
    @die_song.play(looping = false)
    @stamina = 0
    reboot
  end
end

#add_injury_to_enemiesObject

add injury to enemies



487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 487

def add_injury_to_enemies
  window.level.enemies.each do |e|
    if Gosu::distance(e.x, e.y, @weapon.x, @weapon.y) <= 8
      @weapon.drawing = false
      add_enemies_score
    end
    if Gosu::distance(e.x, e.y, x, y) <= 8
      add_injury
    end
  end
  window.level.enemies.reject! { |e|
    Gosu::distance(e.x, e.y, @weapon.x, @weapon.y) <= 8
  }
end

#add_stars_scoreObject

add_stars_score

add score when collect stars by player



429
430
431
432
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 429

def add_stars_score
  @score += 10
  @stars += 1
end

#attackObject

attack

attack enemies



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 450

def attack
  if @weapon.drawing == false
    case face
    when 'left'
      @weapon.x, @weapon.y = x - 4, y + 4
    when 'right'
      @weapon.x, @weapon.y = x + 12, y + 4
    when 'up'
      @weapon.x, @weapon.y = x + 4, y - 8
    when 'down'
      @weapon.x, @weapon.y = x + 4, y + 16
    end
  end
  @weapon.drawing = true
end

#bird_fallObject

#

bird_fall

Bird fall to the ground

#


168
169
170
171
172
173
174
175
176
177
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 168

def bird_fall
  if @y < @window.ground_y - @player_image.height/2
    @gravity += INCREASE_GRAVITY
    @a += 25
    @a = [@a,90].min
    @y += @gravity * @window.delta
  else
    @y = @window.ground_y - @player_image.height/2
  end
end

#bird_flyObject

#

bird_fly

Bird fly when all is done

#


184
185
186
187
188
189
190
191
192
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 184

def bird_fly
  move
  margin = 20
  @y += @velocityY * @window.delta if @y > @velocityY * @window.delta + margin
  @gravity += INCREASE_GRAVITY
  @a += 0.5
  @a = [@a,90].min
  @y += @gravity * @window.delta
end

blink on and off every 7 ticks



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 41

def blink    # blink on and off every 7 ticks
  if @blink == 14
    @image = @picture2
    @blink = 0
  elsif @blink == 7
    @image = @picture1
    @blink +=1
  else
    @blink +=1
  end
end

#brakeObject

pressing down arrow invokes brakes



60
61
62
63
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 60

def brake       # pressing down arrow invokes brakes
	self.velocity_x *= 0.88
	self.velocity_y *= 0.88
end

#collect_applesObject

collect_apples

collect apples by player



414
415
416
417
418
419
420
421
422
423
424
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 414

def collect_apples
  window.level.apples.each { |a|
    if (x - a.x).abs <= 8 && (y - a.y).abs <= 8
      add_apples_score
      @collect_apples.play(looping = false)
    end
  }
  window.level.apples.reject! do |a|
    (x - a.x).abs <= 8 && (y - a.y).abs <= 8
  end
end

#collect_starsObject

collect stars by player



399
400
401
402
403
404
405
406
407
408
409
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 399

def collect_stars
  window.level.stars.each do |s|
    if (x - s.x).abs <= 8 && (y - s.y).abs <= 8
      add_stars_score
      @collect.play(looping = false)
    end
  end
  window.level.stars.reject! do |s|
    (x - s.x).abs <= 8 && (y - s.y).abs <= 8
  end
end

#collision?(other) ⇒ Boolean

Does the bird touch anything

Returns:

  • (Boolean)


126
127
128
129
130
131
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 126

def collision?(other)
  @y + @player_image.height/2 > other.y &&
  @y - @player_image.height/2 < other.y + other.height &&
  @x + @player_image.width/2  > other.x &&
  @x - @player_image.width/2  < other.x + other.width
end

#cool_downObject

player cannot be damaged when blinking



29
30
31
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 29

def cool_down   # player cannot be damaged when blinking
  @cooling_down = $cooling_down
end

#damageObject



33
34
35
36
37
38
39
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 33

def damage
  if @cooling_down == 0  # only causes damage if player is not blinking
    @cooling_down = $cooling_down
    $health -= 1
    Sound["media/audio/exploded.ogg"].play(0.3)
  end
end

#dead_if_touch_groundObject

The bird is dead if he touch the ground



116
117
118
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 116

def dead_if_touch_ground
  @dead = true if @y >= @window.ground_y - @player_image.height/2
end

#drawObject

#

draw

#


89
90
91
92
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 89

def draw
  @player_image = load_image(@window)
  @player_image.draw_rot(@x, @y, 1, @a)
end

#fireObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 73

def fire
@shoot.play(rand(0.05..0.1))  # randomize laser sound effect volume
  if $weapon == 1   # number of Bullets fired depends on weapons upgrade status
		Bullet.create(:x => @x, :y => @y, :angle => @angle, :zorder => Zorder::Projectile)

  elsif $weapon == 2   # use Gosu::offset for upgraded weapons (thanks to PeterT)
    Bullet.create(:x => @x + Gosu::offset_x(@angle+90, 8), :y => @y + Gosu::offset_y(@angle+90, 8), :angle => @angle)
    Bullet.create(:x => @x + Gosu::offset_x(@angle+90, -8), :y => @y + Gosu::offset_y(@angle+90, -8), :angle => @angle)

  elsif $weapon >= 3   # fires three Bullets when weapons are fully upgraded
    Bullet.create(:x => @x, :y => @y, :angle => @angle, :zorder => Zorder::Projectile)
    Bullet.create(:x => @x + Gosu::offset_x(@angle+90, 14), :y => @y + Gosu::offset_y(@angle+90, 14), :angle => @angle)
    Bullet.create(:x => @x + Gosu::offset_x(@angle+90, -14), :y => @y + Gosu::offset_y(@angle+90, -14), :angle => @angle)
#      Bullet.create(:x => @x + 20 * Math.cos(@angle*Math::PI/180) , :y => @y + 20 * Math.sin(@angle*Math::PI/180), :angle => @angle)
#      alternate way to do the weapons offsets with sin and cos
  end
end

#jump_startObject

Set @jump_start with Gosu seconds



141
142
143
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 141

def jump_start
  @jump_start = Gosu::milliseconds / 1000.0
end

#killed?Boolean

Is bird is dead ?

Returns:

  • (Boolean)


111
112
113
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 111

def killed?
  (@y == @window.ground_y - @player_image.height/2) ? true : false
end

#load_image(window) ⇒ Object

#

load_image

#


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 36

def load_image(window)
  image = ''
  images = [
    GamesParadise.image_directory?+'flappy_bird/flappy-1.png',
    GamesParadise.image_directory?+'flappy_bird/flappy-2.png',
    GamesParadise.image_directory?+'flappy_bird/flappy-3.png'
  ]
  sec = (Gosu::milliseconds / 1000).to_s.split(//).last
  if ['0', '3' , '6', '9'].include? sec
    image = images[0]
  elsif ['1', '4', '7'].include? sec
    image = images[1]
  else
    image = images[2]
  end
  @player_image = Gosu::Image.new(image)
end

#moveObject

#

move

Player movement logic.

#


102
103
104
105
106
107
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 102

def move
  @space = user_hit_space?
  jump_start if @space && !@space_before
  update_jump_params if @jump_start > 0
  @space_before = @space
end

#move_downObject

move_down



392
393
394
395
396
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 392

def move_down
  @face = 'down'
  @weapon.last_direction = 'down' if @weapon.drawing == false
  @y += 2
end

#move_leftObject

move_left



372
373
374
375
376
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 372

def move_left
  @face = 'left'
  @weapon.last_direction = 'left' if @weapon.drawing == false
  @x -= 2
end

#move_rightObject

move_right



379
380
381
382
383
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 379

def move_right
  @face = 'right'
  @weapon.last_direction = 'right' if @weapon.drawing == false
  @x += 2
end

#move_upObject

move_up



386
387
388
389
390
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 386

def move_up
  @face = 'up'
  @weapon.last_direction = 'up' if @weapon.drawing == false
  @y -= 2
end

#rebootObject

#

Reboot player.

#


505
506
507
508
509
510
511
512
513
514
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 505

def reboot
  case window.level.num
  when 1
    start_point 600, 456
  when 2
    start_point 620, 168
  end
  @lives -= 1
  @stamina = 100
end

#resetObject

#

reset

Reset position of the bird

#


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 68

def reset
  @x = @window.width / 4
  @y = @window.height / 2
  @a = 0
  @velocityY = 0
  @gravity = 50
  @delta = 0.25

  @space = false
  @space_before = false

  @jump = false
  @jump_max = 0.3
  @jump_start = 0

  @dead = false
end

#speedifyObject

speedify



92
93
94
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 92

def speedify  # method called in Win gamestate, in ending.rb
  @max_speed = 50
end

#start_point(x, y) ⇒ Object

#

start_point

set player coordinates in new level

#


38
39
40
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 38

def start_point(x, y)
  @x, @y = x, y
end

#through_wall?(other) ⇒ Boolean

Is the bird hit a wall ?

Returns:

  • (Boolean)


121
122
123
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 121

def through_wall?(other)
  @x > other.x + (other.width/2)
end

#turn_leftObject



65
66
67
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 65

def turn_left
	self.angle -= @rotate_speed
end

#turn_rightObject



69
70
71
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 69

def turn_right
	self.angle += @rotate_speed
end

#updateObject

update



95
96
97
98
99
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 95

def update
  dead_if_touch_ground
  bird_fall if @dead
  bird_fly if !@dead
end

#update_jump_paramsObject

#

update_jump_params

Stop jump if its duration > JUMP_TIME. Else update acceleration used during jump activation

#


151
152
153
154
155
156
157
158
159
160
161
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 151

def update_jump_params
  @gravity = GRAVITY
  if ((Gosu.milliseconds / 1000.0) - @jump_start) > JUMP_TIME
    @jump_start = 0
  else
    @velocityY = JUMP_POWER
    @a = -45
    @a = -22 if ((Gosu.milliseconds / 1000.0) - @jump_start) > JUMP_TIME / 3
    @a = 0 if ((Gosu.milliseconds / 1000.0) - @jump_start) > (JUMP_TIME*2 / 3)
  end
end

#user_hit_space?Boolean

Does the use hit space key

Returns:

  • (Boolean)


135
136
137
138
# File 'lib/games_paradise/flappy_bird/gosu/player.rb', line 135

def user_hit_space?
  return true if @window.button_down?(Gosu::KbSpace)
  return false if !@window.button_down?(Gosu::KbSpace)
end

#walk_on_horizontal_roadsObject

#

player walking on horizontal roads

#


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
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 101

def walk_on_horizontal_roads
  case window.level.num
  when 1
    if (x >= 82 && x <= 604 && y >= 448 && y <= 460)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 90
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 600
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 453
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 454
      end
    end

    if (x >= 4 && x <= 604 && y >= 306 && y <= 314)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 8
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 600
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 308
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 310
      end
    end

    if (x >= 4 && x <= 462 && y >= 44 && y <= 56)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 8
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 458
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 52
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 53
      end
    end
  when 2
    if (x >= 4 && x <= 632 && y >= 160 && y <= 168)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 8
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 628
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 164
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 165
      end
    end

    if (x >= 82 && x <= 536 && y >= 436 && y <= 440)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 88
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 532
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 438
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 438
      end
    end
  end
end

#walk_on_vertical_roadsObject

#

walk_on_vertical_roads

Player walking on vertical roads.

#


186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/games_paradise/gui/gosu/garden_hero/core/player/player.rb', line 186

def walk_on_vertical_roads
  case window.level.num
  when 1
    if (x >= 590 && x <= 602 && y >= 312 && y <= 460)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 598
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 600
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 316
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 454
      end
    end

    if (x >= 546 && x <= 560 && y >= 220 && y <= 314)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 550
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 554
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 222
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 310
      end
    end

    if (x >= 448 && x <= 460 && y >= 50 && y <= 314)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 454
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 458
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 56
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 310
      end
    end

    if (x >= 368 && x <= 380 && y >= 160 && y <= 314)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 374
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 376
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 164
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 310
      end
    end

    if (x >= 80 && x <= 96 && y >= 160 && y <= 314)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 86
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 88
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 164
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 310
      end
    end

    if (x >= 4 && x <= 16 && y >= 4 && y <= 314)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 8
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 9
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 6
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 310
      end
    end

    if (x >= 82 && x <= 92 && y >= 428 && y <= 460)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 88
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 90
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 430
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 454
      end
    end
  when 2
    if (x >= 550 && x <= 556 && y >= 94 && y <= 168)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 552
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 553
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 98
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 164
      end
    end

    if (x >= 294 && x <= 298 && y >= 94 && y <= 440)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 296
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 297
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 98
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 436
      end
    end

    if (x >= 70 && x <= 74 && y >= 94 && y <= 168)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 72
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 73
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 98
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 164
      end
    end

    if (x >= 84 && x <= 90 && y >= 376 && y <= 444)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 88
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 89
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 382
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 438
      end
    end

    if (x >= 532 && x <= 538 && y >= 376 && y <= 444)
      if window.button_down? Gosu::KbLeft
        move_left if @x >= 535
      end
      if window.button_down? Gosu::KbRight
        move_right if @x <= 536
      end
      if window.button_down? Gosu::KbUp
        move_up if @y >= 382
      end
      if window.button_down? Gosu::KbDown
        move_down if @y <= 438
      end
    end
  end
end