Created
June 26, 2012 01:31
-
-
Save Jared-Prime/2992565 to your computer and use it in GitHub Desktop.
Q: how do I load the image?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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