class LifeGameWindow
Keybinds: s - Start and stop (pause) the game c - Clear the grid r - Randomize the grid Left Click - Invert the state of the cell clicked q/Esc - Quit
Public Class Methods
new()
click to toggle source
Initialize Gosu window and LifeGrid
Calls superclass method
# File lib/NanoLife.rb, line 23 def initialize # Gosu window super WIN_WIDTH, WIN_HEIGHT, false, 1000.0 / MAX_FPS self.caption = 'NanoLife - Conway\'s Game of Life' # Create a game of life grid and start randomly @grid = LifeGrid.new(self) @grid.randomize # Set running to true. Game can be paused with keyboard @running = true end
Public Instance Methods
draw()
click to toggle source
Draw screen
# File lib/NanoLife.rb, line 45 def draw @grid.draw end
needs_cursor?()
click to toggle source
Turn on cursor
# File lib/NanoLife.rb, line 35 def needs_cursor?; true; end
update()
click to toggle source
Update everything each frame before drawing
# File lib/NanoLife.rb, line 38 def update if @running # and delta is met @grid.update end end