Class: Core::Animation

Inherits:
Object show all
Defined in:
lib/animation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graphic, sx, sy, repeat, frames) ⇒ Animation

Returns a new instance of Animation.



18
19
20
21
22
23
24
25
26
# File 'lib/animation.rb', line 18

def initialize(graphic, sx, sy, repeat, frames)
  @anim_frames = Core.tiles("animations/#{graphic}", sx, sy, false)
  @repeat = repeat
  @frames = frames
  @index = 0
  @time = 0
  @x, @y = 0
  @remove = false
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



17
18
19
# File 'lib/animation.rb', line 17

def x
  @x
end

#yObject

Returns the value of attribute y.



17
18
19
# File 'lib/animation.rb', line 17

def y
  @y
end

Instance Method Details

#drawObject



36
37
38
39
40
41
42
43
44
# File 'lib/animation.rb', line 36

def draw
  return if remove?
  @anim_frames[@index].draw(@x + frame.x, @y + frame.y, @z, 1, 1, frame.color, frame.mode)
  @time += 1
  if @time >= frame.length
    @time = 0
    next_frame
  end
end

#frameObject



28
29
30
# File 'lib/animation.rb', line 28

def frame
  return @frames[@index]
end

#play(x, y, z) ⇒ Object



32
33
34
# File 'lib/animation.rb', line 32

def play(x, y, z)
  @x, @y, @z = x, y, z
end

#remove?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/animation.rb', line 46

def remove?
  return @remove
end