Skip to content

Instantly share code, notes, and snippets.

@Jared-Prime
Created June 26, 2012 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jared-Prime/2992565 to your computer and use it in GitHub Desktop.
Save Jared-Prime/2992565 to your computer and use it in GitHub Desktop.
Q: how do I load the image?
require 'chingu'
class Player < Chingu::GameObject
def initialize
super
self.x, self.y = 200, 200
self.image = Gosu::Image["ship1.jpg"]
self.input = {
:holding_left => :move_left,
:holding_right => :move_right }
end
def move_left; @x -= 3; end
def move_right; @x += 3; end
end
class Game < Chingu::Window
def initialize
super(600,600,false)
self.input = { :y => :exit }
@player = Player.create
end
def draw
# answer: you did, but you overwrite a reserved method!
# just add super... or dont use this method at all
super
fill_rect([0,0,600,600], 0x00ffffff, -2)
end
def update
super
self.caption = "FPS: #{self.fps}"
end
end
@game = Game.new
@game.show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment