class Object
Constants
- CROFTWIDTH
Velikost jednoho policka na mape
- HEIGHT
Vyska okna hry
- WIDTH
Sirka okna hry
- Y_START
Pozice pro zacatek vykreslovani na ose Y
Public Instance Methods
area_build()
click to toggle source
vykresli mapu
# File lib/pacman_semestral.rb, line 31 def area_build @game.area.crofts.each do |line_crofts| line_crofts.each do |croft| rect croft.left, croft.top, @c, @c, fill: blue if croft.type == '#' end end draw_bonuses end
draw(ghost, ind, color)
click to toggle source
vykresli barvu ducha
-
Args :
-
ghost
-> duch -
ind
-> index ducha -
color
-> barva ducha
-
# File lib/pacman_semestral.rb, line 77 def draw(ghost, ind, color) ghost.style(fill: blue) if @ghs[ind].am_i_blue ghost.style(fill: color) unless @ghs[ind].am_i_blue end
draw_bonuses()
click to toggle source
vykresli bonusy
# File lib/pacman_semestral.rb, line 84 def draw_bonuses @game.area.crofts.each do |line_crofts| line_crofts.each do |cr| t = cr.top + @c / 3 push_small_bonus(cr, t) push_big_bonus(cr, t) end end end
draw_colors()
click to toggle source
vykresli barvy pro vsechny duchy
# File lib/pacman_semestral.rb, line 64 def draw_colors draw(@red, 0, red) draw(@pink, 1, deeppink) draw(@green, 2, green) draw(@orange, 3, orange) end
draw_figures()
click to toggle source
vykresli vsechny postavy
# File lib/pacman_semestral.rb, line 42 def draw_figures move(@player, @plr.left, @plr.top) move(@red, @ghs[0].left + 5, @ghs[0].top + 5) move(@pink, @ghs[1].left + 5, @ghs[1].top + 5) move(@green, @ghs[2].left + 5, @ghs[2].top + 5) move(@orange, @ghs[3].left + 5, @ghs[3].top + 5) draw_colors end
move(itm, left, top)
click to toggle source
Posune obraz postavy
-
Args :
-
itm
-> postava -
left
-> poloha na ose X -
top
-> poloha na ose Y
-
# File lib/pacman_semestral.rb, line 57 def move(itm, left, top) itm.left = left itm.top = top end
push_big_bonus(cr, t)
click to toggle source
prida do pole bonusu velky bonus
# File lib/pacman_semestral.rb, line 105 def push_big_bonus(cr, t) return unless cr.type == '@' o = oval left: cr.left + @c / 3.8, top: t, radius: @c / 4, fill: red @bonuses.push(o) cr.index = @bonuses.length - 1 end
push_small_bonus(cr, t)
click to toggle source
prida do pole bonusu maly bonus
# File lib/pacman_semestral.rb, line 96 def push_small_bonus(cr, t) return unless cr.type == '*' o = oval left: cr.left + @c / 3, top: t, radius: @c / 6, fill: white @bonuses.push(o) cr.index = @bonuses.length - 1 end
update_bonuses()
click to toggle source
prekresli bonusy
# File lib/pacman_semestral.rb, line 114 def update_bonuses @game.area.crofts.each do |line_crofts| line_crofts.each do |croft| @bonuses[croft.index].clear if croft.visited end end end