chingu 0.6.3 → 0.6.4
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/examples/example14.rb +1 -1
- data/lib/chingu.rb +1 -1
- data/lib/chingu/game_state_manager.rb +8 -4
- data/lib/chingu/game_states/fade_to.rb +7 -4
- data/lib/chingu/game_states/pause.rb +2 -2
- data/lib/chingu/gosu_ext/image.rb +1 -1
- data/lib/chingu/helpers/game_state.rb +14 -7
- data/lib/chingu/traits/timer.rb +1 -0
- metadata +2 -2
- 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.6.
|
5
|
+
s.version = "0.6.4"
|
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-11-
|
9
|
+
s.date = %q{2009-11-29}
|
10
10
|
s.description = %q{OpenGL accelerated 2D game framework for Ruby.
|
11
11
|
Builds on the awesome Gosu (Ruby/C++) which provides all the core functionality.
|
12
12
|
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.}
|
data/examples/example14.rb
CHANGED
@@ -41,7 +41,7 @@ class Game < Chingu::Window
|
|
41
41
|
# Before optmization: 25 FPS (20 boxes and 20 circles)
|
42
42
|
# Cached radius and rects:
|
43
43
|
#
|
44
|
-
|
44
|
+
[Box, Circle].each_collision(Box, Circle) { |o, o2| o.color, o2.color = @blue, @blue }
|
45
45
|
|
46
46
|
#
|
47
47
|
# Only collide boxes with other boxes
|
data/lib/chingu.rb
CHANGED
@@ -123,6 +123,7 @@ module Chingu
|
|
123
123
|
if @transitional_game_state && options[:transitional]
|
124
124
|
# If we have a transitional, switch to that instead, with new_state as first argument
|
125
125
|
transitional_game_state = @transitional_game_state.new(new_state, @transitional_game_state_options)
|
126
|
+
transitional_game_state.game_state_manager = self
|
126
127
|
self.switch_game_state(transitional_game_state, :transitional => false)
|
127
128
|
else
|
128
129
|
if current_game_state.nil?
|
@@ -156,19 +157,20 @@ module Chingu
|
|
156
157
|
# So BasicGameObject#create connects object to new state in its setup()
|
157
158
|
self.inside_state = new_state
|
158
159
|
|
159
|
-
# Call setup
|
160
|
-
new_state.setup if new_state.respond_to?(:setup) && options[:setup]
|
161
|
-
|
162
160
|
# Make sure the game state knows about the manager
|
163
161
|
# Is this doubled in GameState.initialize() ?
|
164
162
|
new_state.game_state_manager = self
|
165
163
|
|
164
|
+
# Call setup
|
165
|
+
new_state.setup if new_state.respond_to?(:setup) && options[:setup]
|
166
|
+
|
166
167
|
# Give the soon-to-be-disabled state a chance to clean up by calling finalize() on it.
|
167
168
|
current_game_state.finalize if current_game_state.respond_to?(:finalize) && options[:finalize]
|
168
169
|
|
169
170
|
if @transitional_game_state && options[:transitional]
|
170
171
|
# If we have a transitional, push that instead, with new_state as first argument
|
171
172
|
transitional_game_state = @transitional_game_state.new(new_state, @transitional_game_state_options)
|
173
|
+
transitional_game_state.game_state_manager = self
|
172
174
|
self.push_game_state(transitional_game_state, :transitional => false)
|
173
175
|
else
|
174
176
|
# Push new state on top of stack and therefore making it active
|
@@ -210,6 +212,7 @@ module Chingu
|
|
210
212
|
if @transitional_game_state && options[:transitional]
|
211
213
|
# If we have a transitional, push that instead, with new_state as first argument
|
212
214
|
transitional_game_state = @transitional_game_state.new(current_game_state, @transitional_game_state_options)
|
215
|
+
transitional_game_state.game_state_manager = self
|
213
216
|
self.switch_game_state(transitional_game_state, :transitional => false)
|
214
217
|
end
|
215
218
|
|
@@ -270,7 +273,8 @@ module Chingu
|
|
270
273
|
#
|
271
274
|
# If you're using Chingu::Window instead of Gosu::Window this will automaticly be called.
|
272
275
|
#
|
273
|
-
def update
|
276
|
+
def update(options = {})
|
277
|
+
puts current_game_state.to_s if options[:debug]
|
274
278
|
if current_game_state
|
275
279
|
current_game_state.update_trait
|
276
280
|
current_game_state.update
|
@@ -41,13 +41,14 @@ module Chingu
|
|
41
41
|
@new_game_state = new_game_state
|
42
42
|
@new_game_state = new_game_state.new if new_game_state.is_a? Class
|
43
43
|
|
44
|
-
|
44
|
+
#@manager = options[:game_state_manager] || self
|
45
45
|
#@manager = game_state_manager
|
46
46
|
end
|
47
47
|
|
48
48
|
def setup
|
49
49
|
@color = Gosu::Color.new(0,0,0,0)
|
50
|
-
if @manager.previous_game_state
|
50
|
+
## if @manager.previous_game_state
|
51
|
+
if previous_game_state
|
51
52
|
@fading_in = false
|
52
53
|
@alpha = 0.0
|
53
54
|
else
|
@@ -76,7 +77,8 @@ module Chingu
|
|
76
77
|
if @fading_in
|
77
78
|
@new_game_state.draw
|
78
79
|
else
|
79
|
-
@manager.previous_game_state.draw
|
80
|
+
## @manager.previous_game_state.draw
|
81
|
+
previous_game_state.draw
|
80
82
|
end
|
81
83
|
|
82
84
|
$window.draw_quad( 0,0,@color,
|
@@ -86,7 +88,8 @@ module Chingu
|
|
86
88
|
end
|
87
89
|
|
88
90
|
if @fading_in && @alpha == 0
|
89
|
-
|
91
|
+
##@manager.switch_game_state(@new_game_state, :transitional => false)
|
92
|
+
switch_game_state(@new_game_state, :transitional => false)
|
90
93
|
end
|
91
94
|
|
92
95
|
end
|
@@ -39,11 +39,11 @@ module Chingu
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def button_down(id)
|
42
|
-
|
42
|
+
pop_game_state(:setup => false) # Return the previous game state, dont call setup()
|
43
43
|
end
|
44
44
|
|
45
45
|
def draw
|
46
|
-
|
46
|
+
previous_game_state.draw # Draw prev game state onto screen (in this case our level)
|
47
47
|
$window.draw_quad( 0,0,@color,
|
48
48
|
$window.width,0,@color,
|
49
49
|
$window.width,$window.height,@color,
|
@@ -30,31 +30,38 @@ module Chingu
|
|
30
30
|
#
|
31
31
|
module GameState
|
32
32
|
def push_game_state(state, options = {})
|
33
|
-
|
33
|
+
#$window.game_state_manager.push_game_state(state, options)
|
34
|
+
game_state_manager.push_game_state(state, options)
|
34
35
|
end
|
35
36
|
|
36
37
|
def pop_game_state(options = {})
|
37
|
-
|
38
|
+
#$window.game_state_manager.pop_game_state(options)
|
39
|
+
game_state_manager.pop_game_state(options)
|
38
40
|
end
|
39
41
|
|
40
42
|
def switch_game_state(state, options = {})
|
41
|
-
|
43
|
+
#$window.game_state_manager.switch_game_state(state, options)
|
44
|
+
game_state_manager.switch_game_state(state, options)
|
42
45
|
end
|
43
46
|
|
44
47
|
def transitional_game_state(state, options = {})
|
45
|
-
|
48
|
+
##$window.game_state_manager.transitional_game_state(state, options)
|
49
|
+
game_state_manager.transitional_game_state(state, options)
|
46
50
|
end
|
47
51
|
|
48
52
|
def current_game_state
|
49
|
-
|
53
|
+
##$window.game_state_manager.current_game_state
|
54
|
+
game_state_manager.current_game_state
|
50
55
|
end
|
51
56
|
|
52
57
|
def previous_game_state
|
53
|
-
|
58
|
+
##$window.game_state_manager.previous_game_state
|
59
|
+
game_state_manager.previous_game_state
|
54
60
|
end
|
55
61
|
|
56
62
|
def clear_game_states
|
57
|
-
|
63
|
+
#$window.game_state_manager.clear_game_states
|
64
|
+
game_state_manager.clear_game_states
|
58
65
|
end
|
59
66
|
end
|
60
67
|
|
data/lib/chingu/traits/timer.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chingu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ippa
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
hxtMlw==
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2009-11-
|
33
|
+
date: 2009-11-29 00:00:00 +01:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|