Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created January 14, 2016 17:32
Show Gist options
  • Save krokrob/27d91c4ff6e61977629c to your computer and use it in GitHub Desktop.
Save krokrob/27d91c4ff6e61977629c to your computer and use it in GitHub Desktop.
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