Class: GamesAndRpgParadise::Knight

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Knight

Returns a new instance of Knight.



7
8
9
10
11
12
13
14
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/characters.rb', line 7

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



18
19
20
21
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/characters.rb', line 18

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

#movementObject

called in Introduction gamestate



15
16
17
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/characters.rb', line 15

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

#speakObject

called in Introduction gamestate



22
23
24
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/characters.rb', line 22

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

#updateObject



25
26
27
28
29
30
31
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/characters.rb', line 25

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