chingu 0.5.7 → 0.5.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/chingu.gemspec +2 -2
- data/lib/chingu.rb +1 -1
- data/lib/chingu/traits/collision_detection.rb +30 -2
- metadata +1 -1
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/chingu.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{chingu}
|
5
|
-
s.version = "0.5.7"
|
5
|
+
s.version = "0.5.7.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["ippa"]
|
9
|
-
s.date = %q{2009-10-
|
9
|
+
s.date = %q{2009-10-15}
|
10
10
|
s.description = %q{Game framework built on top of the OpenGL accelerated game lib Gosu.
|
11
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
12
|
s.email = ["ippa@rubylicio.us"]
|
data/lib/chingu.rb
CHANGED
@@ -109,6 +109,7 @@ module Chingu
|
|
109
109
|
end
|
110
110
|
|
111
111
|
#
|
112
|
+
# Explicit radius-collision
|
112
113
|
# Works like each_collsion but with inline-code for speedups
|
113
114
|
#
|
114
115
|
def each_radius_collision(klasses = [])
|
@@ -120,11 +121,23 @@ module Chingu
|
|
120
121
|
end
|
121
122
|
|
122
123
|
|
124
|
+
#
|
125
|
+
# Explicit bounding_box-collision
|
126
|
+
# Works like each_collision but with inline-code for speedups
|
127
|
+
#
|
128
|
+
def each_bounding_box_collision(klasses = [])
|
129
|
+
Array(klasses).each do |klass|
|
130
|
+
klass.all.each do |object|
|
131
|
+
yield(self, object) if @bounding_box.collide_rect?(object.bounding_box)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
123
136
|
|
124
137
|
module ClassMethods
|
125
138
|
|
126
139
|
#
|
127
|
-
# Works like
|
140
|
+
# Works like each_collision but with inline-code for speedups
|
128
141
|
#
|
129
142
|
def each_radius_collision(klasses = [])
|
130
143
|
Array(klasses).each do |klass|
|
@@ -140,6 +153,21 @@ module Chingu
|
|
140
153
|
end
|
141
154
|
end
|
142
155
|
|
156
|
+
#
|
157
|
+
# Works like each_collsion but with explicit bounding_box collisions (inline-code for speedups)
|
158
|
+
#
|
159
|
+
def each_bounding_box_collision(klasses = [])
|
160
|
+
Array(klasses).each do |klass|
|
161
|
+
object2_list = klass.all
|
162
|
+
self.all.each do |object1|
|
163
|
+
object2_list.each do |object2|
|
164
|
+
next if object1 == object2 # Don't collide objects with themselves
|
165
|
+
yield object1, object2 if object1.bounding_box.collide_rect?(object2.bounding_box)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
143
171
|
#
|
144
172
|
# Class method that will check for collisions between all instances of two classes
|
145
173
|
# and yield the 2 colliding game object instances.
|
@@ -157,7 +185,7 @@ module Chingu
|
|
157
185
|
object2_list = klass.all
|
158
186
|
|
159
187
|
self.all.each do |object1|
|
160
|
-
object2_list.
|
188
|
+
object2_list.each do |object2|
|
161
189
|
next if object1 == object2 # Don't collide objects with themselves
|
162
190
|
yield object1, object2 if object1.collides?(object2)
|
163
191
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|