class RubyFighter::Player

Constants

POS_Y
SCALE
SPEED

Public Class Methods

new(window, name, flip=false) click to toggle source
# File lib/ruby_fighter/player.rb, line 8
def initialize(window, name, flip=false)
  @tiles = Tileset.new(window, name)
  @pos_x = 0
  @flip  = flip
  @max_x = window.width

  move_to flip ? @max_x - 100 - width : 100
  idle!
end

Public Instance Methods

blocking!() click to toggle source
# File lib/ruby_fighter/player.rb, line 27
def blocking!
  @tiles.blocking!
end
draw() click to toggle source
# File lib/ruby_fighter/player.rb, line 71
def draw
  pos_x   = @pos_x + (@flip ? width : 0)
  scale_x = SCALE * (@flip ? -1 : 1)

  @tiles.draw(pos_x, POS_Y, 1, scale_x, SCALE)
end
idle!() click to toggle source
# File lib/ruby_fighter/player.rb, line 18
def idle!
  return if @busy
  @tiles.idle!
end
kick!() click to toggle source
# File lib/ruby_fighter/player.rb, line 39
def kick!
  @busy = true
  @tiles.kick! do
    @busy = false
    idle!
  end
end
left() click to toggle source
# File lib/ruby_fighter/player.rb, line 59
def left
  @pos_x
end
move_left() click to toggle source
# File lib/ruby_fighter/player.rb, line 51
def move_left
  @pos_x -= SPEED
end
move_right() click to toggle source
# File lib/ruby_fighter/player.rb, line 55
def move_right
  @pos_x += SPEED
end
move_to(x) click to toggle source
# File lib/ruby_fighter/player.rb, line 47
def move_to(x)
  @pos_x = x
end
punch!() click to toggle source
# File lib/ruby_fighter/player.rb, line 31
def punch!
  @busy = true
  @tiles.punch! do
    @busy = false
    idle!
  end
end
right() click to toggle source
# File lib/ruby_fighter/player.rb, line 63
def right
  @pos_x + width
end
walking!() click to toggle source
# File lib/ruby_fighter/player.rb, line 23
def walking!
  @tiles.walking!
end
width() click to toggle source
# File lib/ruby_fighter/player.rb, line 67
def width
  @tiles.width * SCALE
end