class Pacman::Screen

Rendering of game

Public Class Methods

new(window, game) click to toggle source
# File lib/pacman/Screen.rb, line 5
def initialize(window, game)
  @game = game
  @window = window
  @font = Gosu::Font.new(window, Gosu.default_font_name, 20)
end

Public Instance Methods

draw() click to toggle source
# File lib/pacman/Screen.rb, line 33
def draw
  @game.points.each { |point| point.draw }
  @game.grid.each do
    |row| row.each do
      |cel| cel.draw if cel.class == Block || cel.class == Point
    end
  end
  @game.ghosts.each { |ghost| ghost.draw }
  @game.player.draw
  draw_info
  draw_end
end
draw_end() click to toggle source
# File lib/pacman/Screen.rb, line 18
def draw_end
  if @game.win == true
    s = 'WIN'
    @font.draw(s, 170, 250, ZOrder::UI, 3.0, 3.0, 0xffffff00)
  end
  if @game.lose == true
    s = 'LOSE'
    @font.draw(s, 170, 250, ZOrder::UI, 3.0, 3.0, 0xffffff00)
  end
  if @game.lose == true || @game.win == true
    s = 'Press [Enter] for new game'
    @font.draw(s, 130, 350, ZOrder::UI, 1.0, 1.0, 0xffffff00)
  end
end
draw_info() click to toggle source
# File lib/pacman/Screen.rb, line 11
def draw_info
  s = "Score: #{@game.player.score}"
  @font.draw(s, 10, 10, ZOrder::UI, 1.0, 1.0, 0xffffff00)
  s =  "FPS: #{@window.fps}"
  @font.draw(s, 120, 10, ZOrder::UI, 1.0, 1.0, 0xffffff00)
end