class Player

Trida Player predstavuje postavu ovladanou hracem (PACMANA)

Attributes

score[R]

reprezentuje hodnotu skore, ktereho hrac dosahl

Public Class Methods

new(left, top, speed, r) click to toggle source

Vytvori noveho hrace umesteneho na mape v poloze left a top, pohybujiciho se rychlosti speed a vychozim smerem pohybu r.

  • Args :

    • left -> poloha na ose X

    • top -> poloha na ose Y

    • speed -> poloha na ose rychlost pohybu

    • r -> vychozi smer pohybu

Calls superclass method Figure::new
# File lib/figure.rb, line 199
def initialize(left, top, speed, r)
  super(left, top, speed, r)
  @score = 0
end

Public Instance Methods

collect_bonus(area) click to toggle source

Zkontroluje, jestli hrac sebral bonus v mape area. Pokud ano, zvysi skore.

  • Args :

    • area -> mapa hry

# File lib/figure.rb, line 209
def collect_bonus(area)
  score = area.bonus(@left + CROFTWIDTH / 2, @top + CROFTWIDTH / 2)
  @score += score
  score
end
you_eat_them() click to toggle source

Pricte skore za znezeni ducha.

# File lib/figure.rb, line 217
def you_eat_them
  @score += 100
end