Created
March 22, 2013 09:06
-
-
Save ntijoh-daniel-berg/5219913 to your computer and use it in GitHub Desktop.
This file contains 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 Game < Chingu::Window | |
def initialize | |
super | |
self.input = {esc: :exit} | |
8.times {|i| Cursor.create(angle: i * 45 ) } | |
end | |
end | |
class Cursor < Chingu::GameObject | |
has_traits :velocity | |
def setup | |
@image = Gosu::Image["cursor.png"] | |
@x = 400 | |
@y = 300 | |
self.input = {holding_left: :left, holding_right: :right, holding_up: :forward} | |
end | |
def update | |
@velocity_x *= 0.95 | |
@velocity_y *= 0.95 | |
Dot.create(x: @x, y: @y) | |
end | |
def forward | |
@velocity_x += Gosu::offset_x(@angle, 0.5) | |
@velocity_y += Gosu::offset_y(@angle, 0.5) | |
end | |
def left | |
@angle -= 2.5 | |
end | |
def right | |
@angle += 2.5 | |
end | |
end | |
class Dot < Chingu::GameObject | |
has_traits :timer | |
def setup | |
@image = Gosu::Image["cursor.png"] | |
after(6000) { self.destroy } | |
end | |
end | |
Game.new.show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment