Class: Pacman
- Inherits:
-
Object
- Object
- Pacman
- Defined in:
- lib/pacman.rb
Overview
Trida Pacman je hlavni trida ktera reprezentuje celou hru.
Instance Attribute Summary collapse
-
#area ⇒ Object
readonly
mapa hry.
-
#ghosts ⇒ Object
readonly
pole duchu ve hre.
-
#player ⇒ Object
readonly
postava ovladana hracem.
Instance Method Summary collapse
-
#initialize ⇒ Pacman
constructor
Vytvori novou instanci hry.
-
#move(direction) ⇒ Object
Zmeni smer pohybu hrace na
direction
* Args : -direction
-> novy smer pohybu hrace. -
#update ⇒ Object
Aktualizuje stav hry * Returns : - GAME_OVER -> Konec hry.
Constructor Details
Instance Attribute Details
#area ⇒ Object (readonly)
mapa hry
100 101 102 |
# File 'lib/pacman.rb', line 100 def area @area end |
#ghosts ⇒ Object (readonly)
pole duchu ve hre
97 98 99 |
# File 'lib/pacman.rb', line 97 def ghosts @ghosts end |
#player ⇒ Object (readonly)
postava ovladana hracem
103 104 105 |
# File 'lib/pacman.rb', line 103 def player @player end |
Instance Method Details
#move(direction) ⇒ Object
Zmeni smer pohybu hrace na direction
-
Args :
-
direction
-> novy smer pohybu hrace
-
42 43 44 |
# File 'lib/pacman.rb', line 42 def move(direction) @player.direction = direction end |
#update ⇒ Object
Aktualizuje stav hry
-
Returns :
-
GAME_OVER -> Konec hry
-
50 51 52 53 54 55 56 57 58 |
# File 'lib/pacman.rb', line 50 def update try_time @player.move if @player.can_move(@area) if @player.collect_bonus(@area) == 10 make_ghosts_blue @time_mark = Time.now end update_ghosts end |