🕷 software projects

by ryan davis



sitemap
Please support my OSS Development.

graphics

a simple framework to implement games and/or simulations

Description

Graphics provides a simple framework to implement games and/or simulations and is designed to follow mathematical conventions, NOT game programming conventions. Particularly it:

  • Uses degrees.
  • Draws in quadrant 1 (0-90 degrees).
  • Right hand rule: 0 degrees is east, 90 is north, etc.

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.

Features & Problems

  • REAL MATHS!
  • Simple drawing primitives.
  • PRETTY drawing primitives! Nearly everything is anti-aliased.
  • Plenty of helpers to make your code clean

Synopsis

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

Get The Code

If you just want to use graphics, you can install it via RubyGems:
gem install graphics
Fork me on GitHub If you want to hack on graphics, clone it from GitHub:
git clone git://github.com/seattlerb/graphics

Latest Activity

Please support my OSS Development.
“More matter, with less art” — Gertrude, Hamlet.

AltStyle によって変換されたページ (->オリジナル) /