Created
January 14, 2016 17:32
-
-
Save krokrob/27d91c4ff6e61977629c 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 'gosu' | |
class Star | |
attr_reader :x, :y | |
def initialize(animation) | |
@animation = animation | |
@color = Gosu::Color.new(0xff_000000) | |
@color.red = rand(256 - 40) + 40 | |
@color.green = rand(256 - 40) + 40 | |
@color.blue = rand(256 - 40) + 40 | |
@x = rand * 640 | |
@y = 10 | |
end | |
def move | |
@y += 5 | |
end | |
def draw | |
img = @animation[Gosu::milliseconds / 100 % @animation.size]; | |
img.draw(@x - img.width / 2.0, @y - img.height / 2.0, | |
ZOrder::Stars, 1, 1, @color, :add) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment