Class: GamesAndRpgParadise::Crowd

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

Overview

CROWD

Enormous background multitude

Instance Method Summary collapse

Instance Method Details

#next_imageObject

called once every 6 ticks in update



220
221
222
223
224
225
226
227
228
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/characters.rb', line 220

def next_image   # called once every 6 ticks in update
  @current += @pendulum
  if @current == 9       # @current goes from 0 up to 9, back down to 0, back up to 9...
    @pendulum = -1       # count back down from 9
  elsif @current == 0
    @pendulum = 1        # count back up from 0
  end
  @image = @crowds[@current]   # switch to next animation frame [@c1, @c2, etc.]
end

#setupObject

this is a ten-frame animation



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/characters.rb', line 201

def setup           # this is a ten-frame animation
  @c1 = Gosu::Image["assets/crowd/crowd1.png"]
  @c2 = Gosu::Image["assets/crowd/crowd2.png"]
  @c3 = Gosu::Image["assets/crowd/crowd3.png"]
  @c4 = Gosu::Image["assets/crowd/crowd4.png"]
  @c5 = Gosu::Image["assets/crowd/crowd5.png"]
  @c6 = Gosu::Image["assets/crowd/crowd6.png"]
  @c7 = Gosu::Image["assets/crowd/crowd7.png"]
  @c8 = Gosu::Image["assets/crowd/crowd8.png"]
  @c9 = Gosu::Image["assets/crowd/crowd9.png"]
  @c10 = Gosu::Image["assets/crowd/crowd10.png"]

  @image = @c1
  @count = 0    # counter for delay between frames
  @current = 0  # current frame number
  @pendulum = 1 # positive one at start
  @crowds = [@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8,@c9,@c10]  # array of images -- basic animation loop
end

#updateObject

update



231
232
233
234
235
236
237
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/characters.rb', line 231

def update
  @count += 1
  if @count == 6    # 6-tick delay between frames
    @count = 0
    next_image
  end
end