Module: RoadToRubykaigi::Graphics::Player

Defined in:
lib/road_to_rubykaigi/graphics/player.rb

Defined Under Namespace

Classes: Direction, Variant

Constant Summary collapse

RIGHT =
RoadToRubykaigi::Sprite::Player::RIGHT
LEFT =
RoadToRubykaigi::Sprite::Player::LEFT
FILE_PATH =
"player.txt"
STATUSES_BY_POSTURE =
{
  standup: %i[normal stunned running],
  crouching: %i[normal stunned],
}.freeze
FRAMES =
[1, 2].freeze
DIRECTIONS =
[Direction.new(RIGHT), Direction.new(LEFT)].freeze

Class Method Summary collapse

Class Method Details

.character(posture:, status:, direction:, attack_mode:) ⇒ Object



61
62
63
64
65
66
# File 'lib/road_to_rubykaigi/graphics/player.rb', line 61

def character(posture:, status:, direction:, attack_mode:)
  load_data unless @variants

  variant = @variants[[posture, status, direction]]
  attack_mode ? variant.attack_frames : variant.default_frames
end