Graphics provides a simple framework to implement games and/or simulations and is designed to follow mathematical conventions, NOT game programming conventions. Particularly it:
These allow simple things like Trigonometry functions to work as expected. It means that all that stuff you were taught it grade school still work as intended. This makes one less thing you have to adjust when implementing your simulation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
class Ball < Graphics::Body def initialize w super # ... end def draw w.angle x, y, a, 10+3*m, :red w.circle x, y, 5, :white, :filled end def update fall move bounce end # ... end class BounceSimulation < Graphics::Simulation attr_accessor :bs def initialize super 640, 640, 16, "Bounce" self.bs = populate Ball end def update n bs.each(&:update) end def draw n clear bs.each(&:draw) fps n end # ... end BounceSimulation.new.run |
See examples/*.rb for more
gem install graphics
git clone git://github.com/seattlerb/graphics