Created
December 16, 2012 01:52
-
-
Save homelinen/4302225 to your computer and use it in GitHub Desktop.
My animated objects in Chingu. Bullet doesn't animate, for some reason.
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
class Bullet < Chingu::GameObject | |
traits :velocity, :bounding_circle | |
trait :animation, :delay => 200, :size => [16,16], :width => 16 | |
def initialize(options = {}) | |
super(options.merge(:image => Image["cannon-ball.png"])) | |
end | |
def update | |
@image = self.animation.next if self.animation | |
if (self.velocity_x < 1 || self.velocity_y < 1) || | |
(@x < 0 || @x > $window.width) || | |
(@y < 0 || @y > $window.height) | |
self.destroy | |
end | |
end | |
end | |
class Sea < Chingu::GameObject | |
trait :animation, :delay => 200, :size => [64,64] | |
def initialize(options = {}) | |
super(options.merge(:image => Image["sea.png"])) | |
end | |
def update | |
@image = self.animation.next if self.animation | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment