Skip to content

Instantly share code, notes, and snippets.

@wbyoko
Created June 26, 2012 01:55
Show Gist options
  • Save wbyoko/2992688 to your computer and use it in GitHub Desktop.
Save wbyoko/2992688 to your computer and use it in GitHub Desktop.
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,
:holding_up => :move_up,
:holding_down => :move_down }
end
def move_left; @x -= 3; end
def move_right; @x += 3; end
def move_up; @y -= 3; end
def move_down; @y += 3; end
end
class Game < Chingu::Window
def initialize
super(600,600,false)
self.input = { :y => :exit }
@player = Player.create
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