-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
I get a black screen. Am I using these GameStates correctly?
require 'rubygems' rescue nil
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
require 'chingu'
include Gosu
include Chingu
class Game < Chingu::Window
def initialize
super
end
def setup
switch_game_state(MainState)
end
end
class MainState < Chingu::GameState
def initialize
super
$name = "Player"
$points = 500
$high_score_list = Chingu::HighScoreList.load(:size => 10)
$window.push_game_state(GameStates::EnterName.new(:callback => method(:got_name)))
end
def got_name(name)
$name = name
$newscore = $high_score_list.add({name: $name, score: $points})
puts "Got name: #{name}"
pop_game_state
$window.switch_game_state(HighScores)
end
end
class HighScores < Chingu::GameState
def initialize
super
create_text
end
def create_text
$high_score_list.each_with_index do |high_score, index|
y = index * 25 + 100
Text.create(high_score[:name], :x => 200, :y => y, :size => 20)
Text.create(high_score[:score], :x => 400, :y => y, :size => 20)
end
end
end
Game.new.show
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels