chingu 0.5.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +21 -0
- data/LICENSE +504 -0
- data/Manifest.txt +72 -0
- data/README.rdoc +588 -0
- data/Rakefile +19 -0
- data/benchmarks/README.txt +1 -0
- data/benchmarks/benchmark.rb +6 -0
- data/benchmarks/benchmark3.rb +23 -0
- data/benchmarks/benchmark4.rb +71 -0
- data/benchmarks/benchmark5.rb +91 -0
- data/benchmarks/benchmark6.rb +23 -0
- data/benchmarks/meta_benchmark.rb +67 -0
- data/benchmarks/meta_benchmark2.rb +39 -0
- data/chingu.gemspec +34 -0
- data/examples/example1.rb +37 -0
- data/examples/example10.rb +75 -0
- data/examples/example11.rb +51 -0
- data/examples/example12.rb +67 -0
- data/examples/example2.rb +115 -0
- data/examples/example3.rb +40 -0
- data/examples/example4.rb +175 -0
- data/examples/example5.rb +107 -0
- data/examples/example6.rb +57 -0
- data/examples/example7.rb +133 -0
- data/examples/example8.rb +109 -0
- data/examples/example9.rb +106 -0
- data/examples/media/Parallax-scroll-example-layer-0.png +0 -0
- data/examples/media/Parallax-scroll-example-layer-1.png +0 -0
- data/examples/media/Parallax-scroll-example-layer-2.png +0 -0
- data/examples/media/Parallax-scroll-example-layer-3.png +0 -0
- data/examples/media/background1.png +0 -0
- data/examples/media/fire_bullet.png +0 -0
- data/examples/media/fireball.png +0 -0
- data/examples/media/particle.png +0 -0
- data/examples/media/ruby.png +0 -0
- data/examples/media/spaceship.png +0 -0
- data/examples/media/stickfigure.bmp +0 -0
- data/examples/media/stickfigure.png +0 -0
- data/examples/media/video_games.png +0 -0
- data/lib/chingu.rb +32 -0
- data/lib/chingu/actor.rb +17 -0
- data/lib/chingu/animation.rb +142 -0
- data/lib/chingu/assets.rb +64 -0
- data/lib/chingu/basic_game_object.rb +132 -0
- data/lib/chingu/core_extensions.rb +53 -0
- data/lib/chingu/effects.rb +36 -0
- data/lib/chingu/fpscounter.rb +62 -0
- data/lib/chingu/game_object.rb +127 -0
- data/lib/chingu/game_object_list.rb +91 -0
- data/lib/chingu/game_state.rb +137 -0
- data/lib/chingu/game_state_manager.rb +284 -0
- data/lib/chingu/game_states/debug.rb +65 -0
- data/lib/chingu/game_states/fade_to.rb +91 -0
- data/lib/chingu/game_states/pause.rb +57 -0
- data/lib/chingu/gfx_helpers.rb +89 -0
- data/lib/chingu/helpers.rb +166 -0
- data/lib/chingu/inflector.rb +34 -0
- data/lib/chingu/input.rb +100 -0
- data/lib/chingu/named_resource.rb +254 -0
- data/lib/chingu/parallax.rb +83 -0
- data/lib/chingu/particle.rb +21 -0
- data/lib/chingu/rect.rb +612 -0
- data/lib/chingu/require_all.rb +133 -0
- data/lib/chingu/text.rb +56 -0
- data/lib/chingu/traits/collision_detection.rb +172 -0
- data/lib/chingu/traits/effect.rb +113 -0
- data/lib/chingu/traits/input.rb +38 -0
- data/lib/chingu/traits/retrofy.rb +53 -0
- data/lib/chingu/traits/rotation_center.rb +84 -0
- data/lib/chingu/traits/timer.rb +90 -0
- data/lib/chingu/traits/velocity.rb +67 -0
- data/lib/chingu/window.rb +170 -0
- metadata +162 -0
- metadata.gz.sig +1 -0
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hoe'
|
3
|
+
require File.dirname(__FILE__) + '/lib/chingu'
|
4
|
+
|
5
|
+
include Chingu
|
6
|
+
|
7
|
+
Hoe.plugin :git
|
8
|
+
Hoe.spec "chingu" do
|
9
|
+
developer "ippa", "ippa@rubylicio.us"
|
10
|
+
self.readme_file = 'README.rdoc'
|
11
|
+
self.rubyforge_name = "chingu"
|
12
|
+
self.version = Chingu::VERSION
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Build a working gemspec"
|
16
|
+
task :gemspec do
|
17
|
+
system "rake git:manifest"
|
18
|
+
system "rake debug_gem | grep -v \"(in \" | grep -v \"erik\" > chingu.gemspec"
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Various chingu / gamedev related benchmark tests.. pretty sloppy but answers some questions.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
|
3
|
+
class A
|
4
|
+
attr_reader :variable
|
5
|
+
def initialize
|
6
|
+
@variable = "hello"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
a = A.new
|
11
|
+
# number of iterations
|
12
|
+
n = 1000000
|
13
|
+
|
14
|
+
Benchmark.bm(22) do |x|
|
15
|
+
x.report('getter') do
|
16
|
+
for i in 1..n; a.variable; end
|
17
|
+
end
|
18
|
+
|
19
|
+
x.report('direct access') do
|
20
|
+
@variable = "hello"
|
21
|
+
for i in 1..n; @variable; end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'randomr'
|
4
|
+
|
5
|
+
a = Array.new
|
6
|
+
n = 1000000
|
7
|
+
Benchmark.bm(22) do |x|
|
8
|
+
x.report('is_a?') do
|
9
|
+
n.times do
|
10
|
+
a.is_a?(Array)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
x.report('kind_of?') do
|
15
|
+
n.times do
|
16
|
+
a.kind_of?(Array)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
x.report('respond_to?') do
|
21
|
+
n.times do
|
22
|
+
a.respond_to?(:size)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
arr = [:a, :b, :c]
|
30
|
+
n = 1000000
|
31
|
+
Benchmark.bm(22) do |x|
|
32
|
+
x.report('arr.each') do
|
33
|
+
n.times do
|
34
|
+
arr.each { |item| item; }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
x.report('for item in arr') do
|
39
|
+
n.times do
|
40
|
+
for item in arr; item; end;
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
n = 1000000
|
47
|
+
Benchmark.bm(22) do |x|
|
48
|
+
x.report('randomr(100)') do
|
49
|
+
for i in 1..n; Randomr.randomr; end
|
50
|
+
end
|
51
|
+
|
52
|
+
x.report('rand(100)') do
|
53
|
+
for i in 1..n; rand(100); end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
n = 1000000
|
59
|
+
Benchmark.bm(12) do |test|
|
60
|
+
test.report("normal:") do
|
61
|
+
n.times do |x|
|
62
|
+
y = x + 1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
test.report("predefine:") do
|
66
|
+
x = y = 0
|
67
|
+
n.times do |x|
|
68
|
+
y = x + 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
class Foo
|
6
|
+
@list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
7
|
+
@@list2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
8
|
+
|
9
|
+
def self.list
|
10
|
+
@list
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.list2
|
14
|
+
@@list2
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_accessor :list
|
18
|
+
def initialize
|
19
|
+
@list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
20
|
+
end
|
21
|
+
|
22
|
+
def bar
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
foo = Foo.new
|
27
|
+
|
28
|
+
|
29
|
+
s = Set.new
|
30
|
+
a = Array.new
|
31
|
+
h = Hash.new
|
32
|
+
h[:a] = Array.new
|
33
|
+
|
34
|
+
n = 1000000
|
35
|
+
Benchmark.bm(22) do |x|
|
36
|
+
x.report('Array << ') do
|
37
|
+
n.times do
|
38
|
+
a << n
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
x.report('Set << ') do
|
43
|
+
n.times do
|
44
|
+
s << n
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
x.report('Hash[:a] << ') do
|
49
|
+
n.times do
|
50
|
+
h[:a] << n
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
n = 1000000
|
58
|
+
Benchmark.bm(22) do |x|
|
59
|
+
x.report('respond_to?') do
|
60
|
+
n.times do
|
61
|
+
foo.respond_to?(:bar)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
x.report('foo.bar method call') do
|
66
|
+
n.times do
|
67
|
+
foo.bar
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
n = 100000
|
73
|
+
Benchmark.bm(22) do |x|
|
74
|
+
x.report('ivar axx') do
|
75
|
+
n.times do
|
76
|
+
foo.list.each { |num| }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
x.report('class attribute axx') do
|
81
|
+
n.times do
|
82
|
+
Foo.list.each { |num| }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
x.report('class var axx') do
|
87
|
+
n.times do
|
88
|
+
Foo.list2.each { |num| }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
a = [1,2,3,4,5]
|
6
|
+
h = {1=>"b",2=>"b",3=>"b",4=>"b",5=>"b"}
|
7
|
+
|
8
|
+
n = 1000000
|
9
|
+
Benchmark.bm(22) do |x|
|
10
|
+
|
11
|
+
x.report('Array.each ') do
|
12
|
+
n.times do
|
13
|
+
a.each {}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
x.report('Hash.each') do
|
18
|
+
n.times do
|
19
|
+
h.each {}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
|
3
|
+
class A; def meth1; true; end; end
|
4
|
+
|
5
|
+
# defining using eval/class/instance
|
6
|
+
str = "def meth2; true; end"
|
7
|
+
a_binding = A.send(:binding)
|
8
|
+
|
9
|
+
# proc for class/instance
|
10
|
+
proc1 = Proc.new { def meth2; true; end }
|
11
|
+
|
12
|
+
# proc for define_method
|
13
|
+
$proc2 = Proc.new { true }
|
14
|
+
|
15
|
+
# unbound method for bind
|
16
|
+
um = A.instance_method(:meth1)
|
17
|
+
|
18
|
+
# number of iterations
|
19
|
+
n = 12000 * 600
|
20
|
+
n = 12000
|
21
|
+
|
22
|
+
Benchmark.bm(22) do |x|
|
23
|
+
|
24
|
+
x.report('instance_eval/str') do
|
25
|
+
for i in 1..n; A.instance_eval(str); end
|
26
|
+
end
|
27
|
+
|
28
|
+
x.report('class_eval/str') do
|
29
|
+
for i in 1..n; A.class_eval(str); end
|
30
|
+
end
|
31
|
+
|
32
|
+
x.report('eval/str') do
|
33
|
+
for i in 1..n; eval(str, a_binding); end
|
34
|
+
end
|
35
|
+
|
36
|
+
x.report('define_method/class') do
|
37
|
+
for i in 1..n; class A; define_method(:meth2, &$proc2); end; end
|
38
|
+
end
|
39
|
+
|
40
|
+
x.report('define_method/send') do
|
41
|
+
for i in 1..n; A.send(:define_method, :meth2, &$proc2); end
|
42
|
+
end
|
43
|
+
|
44
|
+
x.report('def/unbind/bind') do
|
45
|
+
for i in 1..n
|
46
|
+
class A; def meth2; true; end; end
|
47
|
+
A.instance_method(:meth2).bind(A.new)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
x.report('instance_eval/proc') do
|
52
|
+
for i in 1..n; A.instance_eval(&proc1); end
|
53
|
+
end
|
54
|
+
|
55
|
+
x.report('class_eval/proc') do
|
56
|
+
for i in 1..n; A.class_eval(&proc1); end
|
57
|
+
end
|
58
|
+
|
59
|
+
x.report('def') do
|
60
|
+
for i in 1..n; class A; def meth2; true; end; end; end
|
61
|
+
end
|
62
|
+
|
63
|
+
x.report('method/bind') do
|
64
|
+
for i in 1..n; um.bind(A.new); end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
|
3
|
+
class A; def meth1; true; end; end
|
4
|
+
|
5
|
+
# defining using eval/class/instance
|
6
|
+
str = "@var = 1"
|
7
|
+
a_binding = A.send(:binding)
|
8
|
+
|
9
|
+
# proc for class/instance
|
10
|
+
proc1 = Proc.new { def meth2; true; end }
|
11
|
+
|
12
|
+
# proc for define_method
|
13
|
+
$proc2 = Proc.new { true }
|
14
|
+
|
15
|
+
# unbound method for bind
|
16
|
+
um = A.instance_method(:meth1)
|
17
|
+
|
18
|
+
# number of iterations
|
19
|
+
n = 5 * 60 * 10
|
20
|
+
|
21
|
+
Benchmark.bm(22) do |x|
|
22
|
+
|
23
|
+
x.report('straight set') do
|
24
|
+
for i in 1..n; @var = 1; end
|
25
|
+
end
|
26
|
+
|
27
|
+
x.report('instance_eval/str') do
|
28
|
+
for i in 1..n; A.instance_eval(str); end
|
29
|
+
end
|
30
|
+
|
31
|
+
x.report('class_eval/str') do
|
32
|
+
for i in 1..n; A.class_eval(str); end
|
33
|
+
end
|
34
|
+
|
35
|
+
x.report('eval/str') do
|
36
|
+
for i in 1..n; eval(str, a_binding); end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/chingu.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{chingu}
|
5
|
+
s.version = "0.5.5.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["ippa"]
|
9
|
+
s.date = %q{2009-10-06}
|
10
|
+
s.description = %q{Game framework built on top of the OpenGL accelerated game lib Gosu.
|
11
|
+
It adds simple yet powerful game states, prettier input handling, deployment safe asset-handling, a basic re-usable game object and automation of common task.}
|
12
|
+
s.email = ["ippa@rubylicio.us"]
|
13
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "benchmarks/README.txt"]
|
14
|
+
s.files = ["History.txt", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "benchmarks/README.txt", "benchmarks/benchmark.rb", "benchmarks/benchmark3.rb", "benchmarks/benchmark4.rb", "benchmarks/benchmark5.rb", "benchmarks/benchmark6.rb", "benchmarks/meta_benchmark.rb", "benchmarks/meta_benchmark2.rb", "chingu.gemspec", "examples/example1.rb", "examples/example10.rb", "examples/example11.rb", "examples/example12.rb", "examples/example2.rb", "examples/example3.rb", "examples/example4.rb", "examples/example5.rb", "examples/example6.rb", "examples/example7.rb", "examples/example8.rb", "examples/example9.rb", "examples/media/Parallax-scroll-example-layer-0.png", "examples/media/Parallax-scroll-example-layer-1.png", "examples/media/Parallax-scroll-example-layer-2.png", "examples/media/Parallax-scroll-example-layer-3.png", "examples/media/background1.png", "examples/media/fire_bullet.png", "examples/media/fireball.png", "examples/media/particle.png", "examples/media/ruby.png", "examples/media/spaceship.png", "examples/media/stickfigure.bmp", "examples/media/stickfigure.png", "examples/media/video_games.png", "lib/chingu.rb", "lib/chingu/actor.rb", "lib/chingu/animation.rb", "lib/chingu/assets.rb", "lib/chingu/basic_game_object.rb", "lib/chingu/core_extensions.rb", "lib/chingu/effects.rb", "lib/chingu/fpscounter.rb", "lib/chingu/game_object.rb", "lib/chingu/game_object_list.rb", "lib/chingu/game_state.rb", "lib/chingu/game_state_manager.rb", "lib/chingu/game_states/debug.rb", "lib/chingu/game_states/fade_to.rb", "lib/chingu/game_states/pause.rb", "lib/chingu/gfx_helpers.rb", "lib/chingu/helpers.rb", "lib/chingu/inflector.rb", "lib/chingu/input.rb", "lib/chingu/named_resource.rb", "lib/chingu/parallax.rb", "lib/chingu/particle.rb", "lib/chingu/rect.rb", "lib/chingu/require_all.rb", "lib/chingu/text.rb", "lib/chingu/traits/collision_detection.rb", "lib/chingu/traits/effect.rb", "lib/chingu/traits/input.rb", "lib/chingu/traits/retrofy.rb", "lib/chingu/traits/rotation_center.rb", "lib/chingu/traits/timer.rb", "lib/chingu/traits/velocity.rb", "lib/chingu/window.rb"]
|
15
|
+
s.homepage = %q{http://github.com/ippa/chingu/tree/master}
|
16
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{chingu}
|
19
|
+
s.rubygems_version = %q{1.3.5}
|
20
|
+
s.summary = %q{Game framework built on top of the OpenGL accelerated game lib Gosu}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 3
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname($0), "..", "lib", "chingu")
|
3
|
+
include Gosu
|
4
|
+
|
5
|
+
#
|
6
|
+
# A minimalistic Chingu example.
|
7
|
+
# Chingu::Window provides #update and #draw which calls corresponding methods for all objects based on Chingu::Actors
|
8
|
+
#
|
9
|
+
# Image["picture.png"] is a deployment safe shortcut to Gosu's Image.new and supports multiple locations for "picture.png"
|
10
|
+
# By default current dir, media\ and gfx\ is searched. To add own directories:
|
11
|
+
#
|
12
|
+
# Image.autoload_dirs << File.join(self.root, "data", "my_image_dir")
|
13
|
+
#
|
14
|
+
class Game < Chingu::Window
|
15
|
+
def initialize
|
16
|
+
super(640,480,false) # leave it blank and it will be 800,600,non fullscreen
|
17
|
+
@player = Player.create(:x => 200, :y => 200, :image => Image["spaceship.png"])
|
18
|
+
@player.input = { :holding_left => :move_left, :holding_right => :move_right,
|
19
|
+
:holding_up => :move_up, :holding_down => :move_down, :escape => :exit}
|
20
|
+
p RUBY_VERSION
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
super
|
25
|
+
self.caption = "FPS: #{self.fps} milliseconds_since_last_tick: #{self.milliseconds_since_last_tick}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Player < Chingu::GameObject
|
30
|
+
def move_left; @x -= 1; end
|
31
|
+
def move_right; @x += 1; end
|
32
|
+
def move_up; @y -= 1; end
|
33
|
+
def move_down; @y += 1; end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
Game.new.show
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'opengl'
|
3
|
+
require File.join(File.dirname($0), "..", "lib", "chingu")
|
4
|
+
include Gosu
|
5
|
+
include Chingu
|
6
|
+
$stderr.sync = $stdout.sync = true
|
7
|
+
|
8
|
+
#
|
9
|
+
# Testing out a new module-only-super-chain trait system
|
10
|
+
#
|
11
|
+
class Game < Chingu::Window
|
12
|
+
def initialize
|
13
|
+
super(600,400)
|
14
|
+
self.caption = "Testing out new module-based traits (SPACE for more spaceships)"
|
15
|
+
self.input = { :space => :create_thing, :esc => :exit }
|
16
|
+
create_thing(200,200)
|
17
|
+
end
|
18
|
+
|
19
|
+
def update
|
20
|
+
puts "--- UPDATE ---"
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def draw
|
25
|
+
puts "--- DRAW ---"
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_thing(x=nil, y=nil)
|
30
|
+
Thing.create(:x => x||rand($window.width), :y => y||rand($window.height), :debug => true)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Thing < Chingu::GameObject
|
35
|
+
has_trait :effect
|
36
|
+
has_trait :velocity
|
37
|
+
|
38
|
+
def initialize(options)
|
39
|
+
super
|
40
|
+
@image = Image["spaceship.png"]
|
41
|
+
|
42
|
+
self.rotation_center(:center)
|
43
|
+
|
44
|
+
# Julians ninjahack to get that sweet pixely feeling when zooming :)
|
45
|
+
# glBindTexture(GL_TEXTURE_2D, @image.gl_tex_info.tex_name)
|
46
|
+
# glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
47
|
+
# glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
48
|
+
#
|
49
|
+
# The above code has been merged into chingu as @image.retrofy
|
50
|
+
#
|
51
|
+
@image.retrofy
|
52
|
+
|
53
|
+
|
54
|
+
self.factor = 8
|
55
|
+
self.rotating = 2
|
56
|
+
self.velocity_x = 2
|
57
|
+
end
|
58
|
+
|
59
|
+
def update
|
60
|
+
puts "Thing#update"
|
61
|
+
if outside_window?
|
62
|
+
@velocity_x = -@velocity_x
|
63
|
+
@rotating = -@rotating
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def draw
|
68
|
+
puts "Thing#draw"
|
69
|
+
super
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
Game.new.show
|