Class: Star

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

Overview

#

Star - star class (collect by player)

#

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window, x, y) ⇒ Star

initialize



10
11
12
13
# File 'lib/games_paradise/gui/gosu/garden_hero/core/level/star.rb', line 10

def initialize(window, x, y)
  @window, @x, @y = window, x, y
  @img = Gosu::Image.new window, "images/player/star.png", true
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



15
16
17
# File 'lib/games_paradise/gui/gosu/garden_hero/core/level/star.rb', line 15

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



15
16
17
# File 'lib/games_paradise/gui/gosu/garden_hero/core/level/star.rb', line 15

def y
  @y
end

Instance Method Details

#drawObject

draw



18
19
20
# File 'lib/games_paradise/gui/gosu/garden_hero/core/level/star.rb', line 18

def draw
  @img.draw(@x, @y, 1)
end

#setupObject



200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 200

def setup
  @animation = Chingu::Animation.new(:file => "../media/assets/living.png", :size => 64)
  @image = @animation.next
  self.zorder = 200
  self.color = Gosu::Color.new(0xff000000)
  self.color.red = rand(255 - 40) + 40
  self.color.green = rand(255 - 40) + 40
  self.color.blue = rand(255 - 40) + 40
  self.x = rand * 800
  self.y = rand * 600
  cache_bounding_circle     # A cached bounding circle will not adapt to changes in size, but it will follow objects X / Y
end

#updateObject



213
214
215
216
217
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 213

def update
  # Move the animation forward by fetching the next frame and putting it into @image
  # @image is drawn by default by GameObject#draw
  @image = @animation.next
end