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 CHANGED
Binary file
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{chingu}
5
- s.version = "0.6.3"
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-26}
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.}
@@ -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
- #[Box, Circle].each_collision(Box, Circle) { |o, o2| o.color, o2.color = @blue, @blue }
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
@@ -33,7 +33,7 @@ require_all "#{CHINGU_ROOT}/chingu/traits"
33
33
  require_all "#{CHINGU_ROOT}/chingu"
34
34
 
35
35
  module Chingu
36
- VERSION = "0.6.3"
36
+ VERSION = "0.6.4"
37
37
 
38
38
  DEBUG_COLOR = Gosu::Color.new(0xFFFF0000)
39
39
  DEBUG_ZORDER = 9999
@@ -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
- @manager = options[:game_state_manager] || self
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
- @manager.switch_game_state(@new_game_state, :transitional => false)
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
- game_state_manager.pop_game_state(:setup => false) # Return the previous game state, dont call setup()
42
+ pop_game_state(:setup => false) # Return the previous game state, dont call setup()
43
43
  end
44
44
 
45
45
  def draw
46
- game_state_manager.previous_game_state.draw # Draw prev game state onto screen (in this case our level)
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,
@@ -34,7 +34,7 @@ module Gosu
34
34
  begin
35
35
  self.get_pixel(x,y)[3] == 0
36
36
  rescue
37
- puts "Error in get_pixel at x/y: #{x}/#{y}"
37
+ puts "Error in get_pixel at x/y: #{x}/#{y}: #{$!}"
38
38
  end
39
39
  end
40
40
 
@@ -30,31 +30,38 @@ module Chingu
30
30
  #
31
31
  module GameState
32
32
  def push_game_state(state, options = {})
33
- $window.game_state_manager.push_game_state(state, options)
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
- $window.game_state_manager.pop_game_state(options)
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
- $window.game_state_manager.switch_game_state(state, options)
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
- $window.game_state_manager.transitional_game_state(state, options)
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
- $window.game_state_manager.current_game_state
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
- $window.game_state_manager.previous_game_state
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
- $window.game_state_manager.clear_game_states
63
+ #$window.game_state_manager.clear_game_states
64
+ game_state_manager.clear_game_states
58
65
  end
59
66
  end
60
67
 
@@ -78,6 +78,7 @@ module Chingu
78
78
 
79
79
  def update_trait
80
80
  ms = Gosu::milliseconds()
81
+
81
82
  @_timers.each do |start_time, end_time, block|
82
83
  block.call if ms > start_time && (end_time == nil || ms < end_time)
83
84
  end
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.3
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-26 00:00:00 +01:00
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