Class: Knight

Inherits:
Chingu::GameObject
  • Object
show all
Defined in:
lib/games_paradise/gui/gosu/chinguroids/characters.rb

Overview

KNIGHT

called in beginning.rb, in Introduction gamestate

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Knight

Returns a new instance of Knight.



5
6
7
8
9
10
11
12
# File 'lib/games_paradise/gui/gosu/chinguroids/characters.rb', line 5

def initialize(options)
  super
  @image = Image["media/assets/knight.png"]
  @voice = Sound["media/audio/mumble.ogg"]
  @velox = 0     # x velocity starts as 0
  @veloy = 0     # y velocity starts as 0
  @factoring = 1 # used for shrinking Knight when he enters the ship
end

Instance Method Details

#enter_shipObject

called in Introduction gamestate



16
17
18
19
# File 'lib/games_paradise/gui/gosu/chinguroids/characters.rb', line 16

def enter_ship # called in Introduction gamestate
  @veloy = 2
  @factoring = 0.98
end

#movementObject

called in Introduction gamestate



13
14
15
# File 'lib/games_paradise/gui/gosu/chinguroids/characters.rb', line 13

def movement   # called in Introduction gamestate
  @velox = -7  # move left
end

#speakObject

called in Introduction gamestate



20
21
22
# File 'lib/games_paradise/gui/gosu/chinguroids/characters.rb', line 20

def speak      # called in Introduction gamestate
  @voice.play
end

#updateObject



23
24
25
26
27
28
29
# File 'lib/games_paradise/gui/gosu/chinguroids/characters.rb', line 23

def update
  self.factor *= @factoring
  @x += @velox
  @y += @veloy
  if @x <= 400; @velox = 0; end
  if @y >= 450; @veloy = 0; end
end