54 lines
1.1 KiB
Ruby
Executable file
54 lines
1.1 KiB
Ruby
Executable file
#!/usr/bin/ruby
|
|
require 'gosu'
|
|
include Gosu
|
|
require './particle.rb'
|
|
require './fountain.rb'
|
|
require './emitter.rb'
|
|
|
|
# Our window size
|
|
module Dimensions
|
|
Width, Height = 1280, 720
|
|
end
|
|
|
|
# Our layers for drawing.
|
|
module ZOrder
|
|
Background, Shadow, Shape, Highlight = *0..3
|
|
end
|
|
|
|
class GameWindow < Gosu::Window
|
|
def initialize
|
|
super(Dimensions::Width, Dimensions::Height, false)
|
|
self.caption = "Particle Effects"
|
|
|
|
@background_image = Gosu::Image.new(self, "images/background.png", true)
|
|
particles = Particles.new(self)
|
|
@fountain = Fountain.new
|
|
@emitter = Emitter.new(particles, @fountain)
|
|
end
|
|
|
|
# Called every tick by gosu to update object positions
|
|
def update
|
|
if self.button_down?(Gosu::MsLeft) then
|
|
@emitter.spawn(self.mouse_x, self.mouse_y)
|
|
end
|
|
@emitter.update
|
|
end
|
|
|
|
# Called every tick by gosu to draw things on the screen
|
|
def draw
|
|
@background_image.draw(0, 0, ZOrder::Background)
|
|
@emitter.draw
|
|
end
|
|
|
|
# Quit on ESC
|
|
def button_down(id)
|
|
close if id == Gosu::Button::KbEscape
|
|
end
|
|
|
|
def needs_cursor?; true; end
|
|
end
|
|
|
|
# Create the gosu window
|
|
window = GameWindow.new
|
|
window.show
|