Class: Player

Inherits:
Figure show all
Defined in:
lib/figure.rb

Overview

Trida Player predstavuje postavu ovladanou hracem (PACMANA)

Instance Attribute Summary collapse

Attributes inherited from Figure

#direction, #left, #speed, #top

Instance Method Summary collapse

Methods inherited from Figure

#can_move, #move

Constructor Details

#initialize(left, top, speed, r) ⇒ Player

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



199
200
201
202
# File 'lib/figure.rb', line 199

def initialize(left, top, speed, r)
  super(left, top, speed, r)
  @score = 0
end

Instance Attribute Details

#scoreObject (readonly)

reprezentuje hodnotu skore, ktereho hrac dosahl



222
223
224
# File 'lib/figure.rb', line 222

def score
  @score
end

Instance Method Details

#collect_bonus(area) ⇒ Object

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

  • Args :

    • area -> mapa hry



209
210
211
212
213
# 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_themObject

Pricte skore za znezeni ducha.



217
218
219
# File 'lib/figure.rb', line 217

def you_eat_them
  @score += 100
end