chingu 0.7.6.7 → 0.7.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +22 -16
- data/chingu.gemspec +3 -2
- data/lib/chingu.rb +1 -1
- data/lib/chingu/game_object_map.rb +39 -6
- data/lib/chingu/game_state.rb +8 -3
- data/lib/chingu/game_states/edit.rb +62 -13
- data/lib/chingu/game_states/pause.rb +6 -5
- data/lib/chingu/game_states/popup.rb +56 -0
- data/lib/chingu/helpers/game_state.rb +3 -10
- data/lib/chingu/helpers/input_dispatcher.rb +2 -1
- data/lib/chingu/rect.rb +1 -12
- data/lib/chingu/text.rb +2 -2
- data/lib/chingu/viewport.rb +4 -1
- metadata +6 -5
data/README.rdoc
CHANGED
@@ -456,33 +456,39 @@ The biggest and most usable is GameStates::Edit which enables fast 'n easy level
|
|
456
456
|
Start example19 and press 'E' to get a full example.
|
457
457
|
|
458
458
|
Edit commands / shortcuts:
|
459
|
+
F1: Help screen
|
459
460
|
1-5: create object 1..5 shown in toolbar at mousecursor
|
460
|
-
|
461
|
-
BACKSPACE: reset selected objects to default values
|
462
|
-
CTRL+A: select all objects (not code-created ones though)
|
461
|
+
CTRL+A: select all objects (not in-code-created ones though)
|
463
462
|
CTRL+S: Save
|
464
463
|
E: Save and Quit
|
464
|
+
Q: Quit (without saving)
|
465
465
|
ESC: Deselect all objects
|
466
|
-
Right Mouse Button Click: Copy object
|
466
|
+
Right Mouse Button Click: Copy object bellow cursor for fast duplication
|
467
467
|
Arrow-keys (with selected objects): Move objects 1 pixel at the time
|
468
468
|
Arrow-keys (with no selected objects): Scroll within a viewport
|
469
|
-
Page up/down: Modify the zorder of selected game objects
|
470
|
-
|
471
|
-
# The bellow keys works on all selected game objects
|
472
|
-
r: scale up
|
473
|
-
f: scale down
|
474
|
-
t: tilt left
|
475
|
-
g: tilt right
|
476
|
-
y: inc zorder
|
477
|
-
h: dec zorder
|
478
|
-
u: less transparency
|
479
|
-
j: more transparencty
|
480
469
|
|
470
|
+
|
471
|
+
Bellow keys operates on all currently selected game objects
|
472
|
+
-----------------------------------------------------------------------------------
|
473
|
+
DEL: delete selected objects
|
474
|
+
BACKSPACE: reset angle and scale to default values
|
475
|
+
Page Up: Increase zorder
|
476
|
+
Page Down: Decrease zorder
|
477
|
+
|
478
|
+
R: scale up
|
479
|
+
F: scale down
|
480
|
+
T: tilt left
|
481
|
+
G: tilt right
|
482
|
+
Y: inc zorder
|
483
|
+
H: dec zorder
|
484
|
+
U: less transparency
|
485
|
+
J: more transparency
|
486
|
+
|
481
487
|
Mouse Wheel (with no selected objects): Scroll viewport up/down
|
482
488
|
Mouse Wheel: Scale up/down
|
483
489
|
SHIFT + Mouse Wheel: Tilt left/right
|
484
490
|
CTRL + Mouse Wheel: Zorder up/down
|
485
|
-
ALT + Mouse Wheel:
|
491
|
+
ALT + Mouse Wheel: Transparency less/more
|
486
492
|
|
487
493
|
Move mouse cursor close to the window border to scroll a viewport if your game state has one.
|
488
494
|
|
data/chingu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{chingu}
|
8
|
-
s.version = "0.7.6.
|
8
|
+
s.version = "0.7.6.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ippa"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-15}
|
13
13
|
s.description = %q{OpenGL accelerated 2D game framework for Ruby. Builds on Gosu (Ruby/C++) which provides all the core functionality. Chingu adds simple yet powerful game states, prettier input handling, deployment safe asset-handling, a basic re-usable game object and stackable game logic.}
|
14
14
|
s.email = %q{ippa@rubylicio.us}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -119,6 +119,7 @@ Gem::Specification.new do |s|
|
|
119
119
|
"lib/chingu/game_states/edit.rb",
|
120
120
|
"lib/chingu/game_states/fade_to.rb",
|
121
121
|
"lib/chingu/game_states/pause.rb",
|
122
|
+
"lib/chingu/game_states/popup.rb",
|
122
123
|
"lib/chingu/gosu_ext/image.rb",
|
123
124
|
"lib/chingu/helpers/class_inheritable_accessor.rb",
|
124
125
|
"lib/chingu/helpers/game_object.rb",
|
data/lib/chingu.rb
CHANGED
@@ -34,7 +34,7 @@ module Chingu
|
|
34
34
|
# ** This class is under heavy development, API will most likely change! **
|
35
35
|
#
|
36
36
|
class GameObjectMap
|
37
|
-
attr_reader :map
|
37
|
+
attr_reader :map, :game_object_positions
|
38
38
|
|
39
39
|
def initialize(options = {})
|
40
40
|
@game_objects = options[:game_objects]
|
@@ -49,15 +49,26 @@ module Chingu
|
|
49
49
|
#
|
50
50
|
def create_map
|
51
51
|
@map = []
|
52
|
+
@game_object_positions = {}
|
53
|
+
|
52
54
|
@game_objects.each do |game_object|
|
53
55
|
puts "#{game_object.class} @ #{game_object.x} / #{game_object.y}" if @debug
|
54
|
-
|
56
|
+
|
55
57
|
start_x = (game_object.bb.left / @grid[0]).to_i
|
56
|
-
stop_x = (game_object.bb.right / @grid[0]).to_i
|
57
|
-
|
58
|
+
stop_x = ( (game_object.bb.right-1) / @grid[0] ).to_i
|
59
|
+
|
60
|
+
#if game_object.zorder == 80
|
61
|
+
# puts "x: #{game_object.x}, y: #{game_object.y}"
|
62
|
+
# puts "width: #{game_object.width}, height: #{game_object.height}"
|
63
|
+
# puts "start_x: #{start_x}, stop_x: #{stop_x}"
|
64
|
+
#end
|
65
|
+
|
66
|
+
|
58
67
|
(start_x .. stop_x).each do |x|
|
59
|
-
start_y = (game_object.bb.top / @grid[1]).to_i
|
60
|
-
stop_y = (game_object.bb.bottom / @grid[1]).to_i
|
68
|
+
start_y = (game_object.bb.top / @grid[1] ).to_i
|
69
|
+
stop_y = ( (game_object.bb.bottom-1) / @grid[1] ).to_i
|
70
|
+
|
71
|
+
@game_object_positions[game_object] = [(start_x .. stop_x), (start_y .. stop_y)]
|
61
72
|
|
62
73
|
@map[x] ||= []
|
63
74
|
(start_y .. stop_y).each do |y|
|
@@ -67,6 +78,28 @@ module Chingu
|
|
67
78
|
end
|
68
79
|
end
|
69
80
|
|
81
|
+
#
|
82
|
+
# Removes a specific game object from the map
|
83
|
+
#
|
84
|
+
def clear_game_object(game_object)
|
85
|
+
range_x, range_y = @game_object_positions[game_object]
|
86
|
+
|
87
|
+
range_x.each do |x|
|
88
|
+
range_y.each do |y|
|
89
|
+
@map[x][y] = nil
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# Clear game object from the array-map on a certain X/Y
|
96
|
+
#
|
97
|
+
def clear_at(x, y)
|
98
|
+
lookup_x = (x / @grid[0]).to_i
|
99
|
+
lookup_y = (y / @grid[1]).to_i
|
100
|
+
@map[lookup_x][lookup_y] = nil
|
101
|
+
end
|
102
|
+
|
70
103
|
#
|
71
104
|
# Gets a game object from the array-map on a certain X/Y
|
72
105
|
#
|
data/lib/chingu/game_state.rb
CHANGED
@@ -57,7 +57,7 @@ module Chingu
|
|
57
57
|
include Chingu::Helpers::ClassInheritableAccessor # adds classmethod class_inheritable_accessor
|
58
58
|
|
59
59
|
attr_reader :options
|
60
|
-
attr_accessor :game_objects, :game_state_manager
|
60
|
+
attr_accessor :game_objects, :game_state_manager, :previous_game_state
|
61
61
|
|
62
62
|
class_inheritable_accessor :trait_options
|
63
63
|
@trait_options = Hash.new
|
@@ -107,9 +107,14 @@ module Chingu
|
|
107
107
|
@options = options
|
108
108
|
@game_objects = GameObjectList.new
|
109
109
|
@input_clients = Array.new
|
110
|
-
|
111
|
-
# Game state
|
110
|
+
|
111
|
+
# Game state manager can be run alone
|
112
112
|
if defined?($window) && $window.respond_to?(:game_state_manager)
|
113
|
+
|
114
|
+
# Since we place the init of previous_game_state here, game states can use it even
|
115
|
+
# in initialize() if they call super first.
|
116
|
+
@previous_game_state = $window.game_state_manager.current_game_state
|
117
|
+
|
113
118
|
$window.game_state_manager.inside_state = self
|
114
119
|
end
|
115
120
|
|
@@ -49,7 +49,7 @@ module Chingu
|
|
49
49
|
|
50
50
|
def initialize(options = {})
|
51
51
|
super
|
52
|
-
|
52
|
+
|
53
53
|
options = {:draw_grid => true, :snap_to_grid => true, :resize_to_grid => true}.merge(options)
|
54
54
|
|
55
55
|
@grid = options[:grid] || [8,8]
|
@@ -69,6 +69,7 @@ module Chingu
|
|
69
69
|
@hud_color = Gosu::Color.new(200,70,70,70)
|
70
70
|
@selected_game_object = nil
|
71
71
|
self.input = {
|
72
|
+
:f1 => :display_help,
|
72
73
|
:left_mouse_button => :left_mouse_button,
|
73
74
|
:released_left_mouse_button => :released_left_mouse_button,
|
74
75
|
:right_mouse_button => :right_mouse_button,
|
@@ -128,6 +129,7 @@ module Chingu
|
|
128
129
|
}
|
129
130
|
|
130
131
|
@hud_height = 140
|
132
|
+
@toolbar_icon_size = [32,32]
|
131
133
|
x = 20
|
132
134
|
y = 60
|
133
135
|
@classes.each do |klass|
|
@@ -137,17 +139,18 @@ module Chingu
|
|
137
139
|
# so they're not overwritten by the class initialize/setup or simular
|
138
140
|
begin
|
139
141
|
game_object = klass.create(:paused => true)
|
140
|
-
game_object.x = x
|
142
|
+
game_object.x = x + 10
|
141
143
|
game_object.y = y
|
142
144
|
game_object.zorder = @zorder
|
143
145
|
game_object.options[:toolbar] = true
|
146
|
+
game_object.rotation_center = :center_center
|
144
147
|
|
145
148
|
# Scale down object to fit our toolbar
|
146
149
|
if game_object.image
|
147
|
-
Text.create("#{klass}\n#{game_object.width.to_i}x#{game_object.height.to_i}", :size =>
|
148
|
-
game_object.size =
|
150
|
+
Text.create("#{klass.to_s[0..9]}\n#{game_object.width.to_i}x#{game_object.height.to_i}", :size => 12, :x=>x-16, :y=>y+18, :zorder => @zorder, :max_width => 55, :rotation_center => :top_left, :align => :center, :factor => 1)
|
151
|
+
game_object.size = @toolbar_icon_size
|
149
152
|
game_object.cache_bounding_box if game_object.respond_to?(:cache_bounding_box)
|
150
|
-
x +=
|
153
|
+
x += 50
|
151
154
|
else
|
152
155
|
puts "Skipping #{klass} - no image" if @debug
|
153
156
|
game_object.destroy
|
@@ -158,10 +161,52 @@ module Chingu
|
|
158
161
|
end
|
159
162
|
end
|
160
163
|
|
164
|
+
def display_help
|
165
|
+
text = <<END_OF_STRING
|
166
|
+
F1: This help screen
|
167
|
+
ESC: Return to Edit
|
168
|
+
|
169
|
+
1-5: create object 1..5 shown in toolbar at mousecursor
|
170
|
+
CTRL+A: select all objects (not in-code-created ones though)
|
171
|
+
CTRL+S: Save
|
172
|
+
E: Save and Quit
|
173
|
+
Q: Quit (without saving)
|
174
|
+
ESC: Deselect all objects
|
175
|
+
Right Mouse Button Click: Copy object bellow cursor for fast duplication
|
176
|
+
Arrow-keys (with selected objects): Move objects 1 pixel at the time
|
177
|
+
Arrow-keys (with no selected objects): Scroll within a viewport
|
178
|
+
|
179
|
+
|
180
|
+
Bellow keys operates on all currently selected game objects
|
181
|
+
-----------------------------------------------------------------------------------
|
182
|
+
DEL: delete selected objects
|
183
|
+
BACKSPACE: reset angle and scale to default values
|
184
|
+
Page Up: Increase zorder
|
185
|
+
Page Down: Decrease zorder
|
186
|
+
|
187
|
+
R: scale up
|
188
|
+
F: scale down
|
189
|
+
T: tilt left
|
190
|
+
G: tilt right
|
191
|
+
Y: inc zorder
|
192
|
+
H: dec zorder
|
193
|
+
U: less transparency
|
194
|
+
J: more transparencty
|
195
|
+
|
196
|
+
Mouse Wheel (with no selected objects): Scroll viewport up/down
|
197
|
+
Mouse Wheel: Scale up/down
|
198
|
+
SHIFT + Mouse Wheel: Tilt left/right
|
199
|
+
CTRL + Mouse Wheel: Zorder up/down
|
200
|
+
ALT + Mouse Wheel: Transparency less/more
|
201
|
+
END_OF_STRING
|
202
|
+
|
203
|
+
push_game_state( GameStates::Popup.new(:text => text) )
|
204
|
+
end
|
205
|
+
|
161
206
|
def draw_grid
|
162
207
|
return unless @grid
|
163
208
|
|
164
|
-
start_x
|
209
|
+
start_x, start_y = 0,0
|
165
210
|
if defined?(previous_game_state.viewport)
|
166
211
|
start_x = -previous_game_state.viewport.x % @grid.first
|
167
212
|
start_y = -previous_game_state.viewport.y % @grid.last
|
@@ -190,7 +235,7 @@ module Chingu
|
|
190
235
|
@game_area_backup = previous_game_state.viewport.game_area.dup
|
191
236
|
previous_game_state.viewport.game_area.x -= @hud_height
|
192
237
|
previous_game_state.viewport.game_area.y -= @hud_height
|
193
|
-
end
|
238
|
+
end
|
194
239
|
end
|
195
240
|
|
196
241
|
#
|
@@ -243,7 +288,6 @@ module Chingu
|
|
243
288
|
scroll_up if $window.mouse_y < @scroll_border_thickness
|
244
289
|
scroll_down if $window.mouse_y > $window.height - @scroll_border_thickness
|
245
290
|
end
|
246
|
-
|
247
291
|
end
|
248
292
|
|
249
293
|
#
|
@@ -256,7 +300,7 @@ module Chingu
|
|
256
300
|
super
|
257
301
|
|
258
302
|
draw_grid if @draw_grid
|
259
|
-
|
303
|
+
|
260
304
|
#
|
261
305
|
# Draw an edit HUD
|
262
306
|
#
|
@@ -264,7 +308,7 @@ module Chingu
|
|
264
308
|
$window.width,0,@hud_color,
|
265
309
|
$window.width,@hud_height,@hud_color,
|
266
310
|
0,@hud_height,@hud_color, @zorder-1)
|
267
|
-
|
311
|
+
|
268
312
|
#
|
269
313
|
# Draw red rectangles/circles around all selected game objects
|
270
314
|
#
|
@@ -279,6 +323,7 @@ module Chingu
|
|
279
323
|
else
|
280
324
|
draw_cursor_at($window.mouse_x, $window.mouse_y)
|
281
325
|
end
|
326
|
+
|
282
327
|
end
|
283
328
|
|
284
329
|
#
|
@@ -589,13 +634,17 @@ module Chingu
|
|
589
634
|
def scroll_right(amount = 10)
|
590
635
|
self.previous_game_state.viewport.x += amount if defined?(self.previous_game_state.viewport)
|
591
636
|
end
|
637
|
+
|
592
638
|
def mouse_x
|
593
639
|
x = $window.mouse_x
|
594
640
|
x += self.previous_game_state.viewport.x if defined?(self.previous_game_state.viewport)
|
641
|
+
return x
|
595
642
|
end
|
643
|
+
|
596
644
|
def mouse_y
|
597
645
|
y = $window.mouse_y
|
598
646
|
y += self.previous_game_state.viewport.y if defined?(self.previous_game_state.viewport)
|
647
|
+
return y
|
599
648
|
end
|
600
649
|
|
601
650
|
def inside_window?(x = $window.mouse_x, y = $window.mouse_y)
|
@@ -609,7 +658,7 @@ module Chingu
|
|
609
658
|
game_object.options[:created_with_editor] = true
|
610
659
|
game_object.x = self.mouse_x
|
611
660
|
game_object.y = self.mouse_y
|
612
|
-
|
661
|
+
|
613
662
|
unless template.options[:toolbar]
|
614
663
|
game_object.angle = template.angle
|
615
664
|
game_object.factor_x = template.factor_x
|
@@ -625,8 +674,8 @@ module Chingu
|
|
625
674
|
game_object.factor_y = wanted_height.to_f / game_object.image.height.to_f
|
626
675
|
end
|
627
676
|
|
628
|
-
game_object.options[:mouse_x_offset] = game_object.x - self.mouse_x
|
629
|
-
game_object.options[:mouse_y_offset] = game_object.y - self.mouse_y
|
677
|
+
game_object.options[:mouse_x_offset] = (game_object.x - self.mouse_x) rescue 0
|
678
|
+
game_object.options[:mouse_y_offset] = (game_object.y - self.mouse_y) rescue 0
|
630
679
|
|
631
680
|
game_object.cache_bounding_box if game_object.respond_to?(:cache_bounding_box)
|
632
681
|
return game_object
|
@@ -30,16 +30,17 @@ module Chingu
|
|
30
30
|
# requires the global $window set to the instance of Gosu::Window (automaticly handled if you use Chingu::Window)
|
31
31
|
#
|
32
32
|
class Pause < Chingu::GameState
|
33
|
+
|
33
34
|
def initialize(options = {})
|
34
35
|
super
|
35
36
|
@white = Color.new(255,255,255,255)
|
36
37
|
@color = Gosu::Color.new(200,0,0,0)
|
37
38
|
@font = Gosu::Font.new($window, default_font_name, 35)
|
38
|
-
@text = "PAUSED - press
|
39
|
+
@text = "PAUSED - press ESC to return to game."
|
39
40
|
end
|
40
41
|
|
41
|
-
def
|
42
|
-
pop_game_state(:setup => false)
|
42
|
+
def button_up(id)
|
43
|
+
pop_game_state(:setup => false) if id == Gosu::KbEscape # Return the previous game state, dont call setup()
|
43
44
|
end
|
44
45
|
|
45
46
|
def draw
|
@@ -47,9 +48,9 @@ module Chingu
|
|
47
48
|
$window.draw_quad( 0,0,@color,
|
48
49
|
$window.width,0,@color,
|
49
50
|
$window.width,$window.height,@color,
|
50
|
-
0,$window.height,@color,
|
51
|
+
0,$window.height,@color, Chingu::DEBUG_ZORDER)
|
51
52
|
|
52
|
-
@font.draw(@text, ($window.width/2 - @font.text_width(@text)/2), $window.height/2 - @font.height,
|
53
|
+
@font.draw(@text, ($window.width/2 - @font.text_width(@text)/2), $window.height/2 - @font.height, Chingu::DEBUG_ZORDER + 1)
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Chingu -- OpenGL accelerated 2D game framework for Ruby
|
4
|
+
# Copyright (C) 2009 ippa / ippa@rubylicio.us
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
#
|
20
|
+
#++
|
21
|
+
|
22
|
+
module Chingu
|
23
|
+
module GameStates
|
24
|
+
|
25
|
+
#
|
26
|
+
# Premade game state for chingu - A simple way if pausing the game + displaying a text.
|
27
|
+
# Usage:
|
28
|
+
# push_game_state(Chingu::GameStates::Popup.new(:text => "bla bla bla"))
|
29
|
+
#
|
30
|
+
# TODO: Use Gosu's new flush() instead of mucking around with ZORDER + 1000...
|
31
|
+
#
|
32
|
+
class Popup < Chingu::GameState
|
33
|
+
|
34
|
+
def initialize(options = {})
|
35
|
+
super
|
36
|
+
@white = Color.new(255,255,255,255)
|
37
|
+
@color = Gosu::Color.new(200,0,0,0)
|
38
|
+
@string = options[:text] || "Press ESC to return."
|
39
|
+
@text = Text.new(@string, :x => 20, :y => 10, :align => :left, :zorder => Chingu::DEBUG_ZORDER + 1001, :factor => 1)
|
40
|
+
end
|
41
|
+
|
42
|
+
def button_up(id)
|
43
|
+
pop_game_state(:setup => false) if id == Gosu::KbEscape # Return the previous game state, dont call setup()
|
44
|
+
end
|
45
|
+
|
46
|
+
def draw
|
47
|
+
previous_game_state.draw # Draw prev game state
|
48
|
+
$window.draw_quad( 0,0,@color,
|
49
|
+
$window.width,0,@color,
|
50
|
+
$window.width,$window.height,@color,
|
51
|
+
0,$window.height,@color, Chingu::DEBUG_ZORDER + 1000)
|
52
|
+
@text.draw
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -34,37 +34,30 @@ module Chingu
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def push_game_state(state, options = {})
|
37
|
-
#$window.game_state_manager.push_game_state(state, options)
|
38
37
|
game_state_manager.push_game_state(state, options)
|
39
38
|
end
|
40
39
|
|
41
40
|
def pop_game_state(options = {})
|
42
|
-
#$window.game_state_manager.pop_game_state(options)
|
43
41
|
game_state_manager.pop_game_state(options)
|
44
42
|
end
|
45
43
|
|
46
44
|
def switch_game_state(state, options = {})
|
47
|
-
#$window.game_state_manager.switch_game_state(state, options)
|
48
45
|
game_state_manager.switch_game_state(state, options)
|
49
46
|
end
|
50
47
|
|
51
48
|
def transitional_game_state(state, options = {})
|
52
|
-
##$window.game_state_manager.transitional_game_state(state, options)
|
53
49
|
game_state_manager.transitional_game_state(state, options)
|
54
50
|
end
|
55
51
|
|
56
52
|
def current_game_state
|
57
|
-
##$window.game_state_manager.current_game_state
|
58
53
|
game_state_manager.current_game_state
|
59
54
|
end
|
60
55
|
|
61
|
-
def previous_game_state
|
62
|
-
|
63
|
-
|
64
|
-
end
|
56
|
+
#def previous_game_state
|
57
|
+
# game_state_manager.previous_game_state
|
58
|
+
#end
|
65
59
|
|
66
60
|
def clear_game_states
|
67
|
-
#$window.game_state_manager.clear_game_states
|
68
61
|
game_state_manager.clear_game_states
|
69
62
|
end
|
70
63
|
end
|
@@ -86,7 +86,8 @@ module Chingu
|
|
86
86
|
# * GameState-inherited class, create a new instance, cache it and push it on top of stack
|
87
87
|
#
|
88
88
|
def dispatch_action(action, object)
|
89
|
-
#
|
89
|
+
#puts "Dispatch Action: #{action} - Objects class: #{object.class.to_s}"
|
90
|
+
|
90
91
|
case action
|
91
92
|
when Symbol, String
|
92
93
|
object.send(action)
|
data/lib/chingu/rect.rb
CHANGED
@@ -49,8 +49,6 @@
|
|
49
49
|
# union, union!
|
50
50
|
# union_all, union_all!
|
51
51
|
#
|
52
|
-
# class Surface
|
53
|
-
# make_rect
|
54
52
|
#
|
55
53
|
#++
|
56
54
|
|
@@ -105,7 +103,6 @@ class Rect < Array
|
|
105
103
|
# 3. Elsif it has a +rect+ attribute., perform (1) and (2) on that.
|
106
104
|
# 4. Otherwise, raise TypeError.
|
107
105
|
#
|
108
|
-
# See also Surface#make_rect()
|
109
106
|
def Rect.new_from_object(object)
|
110
107
|
case(object)
|
111
108
|
when Rect
|
@@ -620,12 +617,4 @@ class Rect < Array
|
|
620
617
|
end # class Rect
|
621
618
|
|
622
619
|
|
623
|
-
|
624
|
-
# Return a Rect with the same width and height as the Surface, positioned
|
625
|
-
# at (0,0).
|
626
|
-
def make_rect()
|
627
|
-
return Rect.new(0,0,self.width,self.height)
|
628
|
-
end
|
629
|
-
end
|
630
|
-
|
631
|
-
end # module Rubygame
|
620
|
+
end # module Chingu
|
data/lib/chingu/text.rb
CHANGED
@@ -109,11 +109,11 @@ module Chingu
|
|
109
109
|
end
|
110
110
|
|
111
111
|
#
|
112
|
-
#
|
112
|
+
# Draws @background if present + our text in @image
|
113
113
|
#
|
114
114
|
def draw
|
115
115
|
@background.draw if @background # draw our background, if any
|
116
|
-
super # super -> GameObject#draw which draws out text
|
116
|
+
super # super -> GameObject#draw which draws out text in form of @image
|
117
117
|
end
|
118
118
|
|
119
119
|
private
|
data/lib/chingu/viewport.rb
CHANGED
@@ -146,8 +146,11 @@ module Chingu
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
#
|
150
|
+
# Apply the X/Y viewport-translation, used by trait "viewport"
|
151
|
+
#
|
149
152
|
def apply(&block)
|
150
|
-
$window.translate(-@x, -@y, &block)
|
153
|
+
$window.translate(-@x.to_i, -@y.to_i, &block)
|
151
154
|
end
|
152
155
|
|
153
156
|
def to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chingu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 127
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
9
|
- 6
|
10
|
-
-
|
11
|
-
version: 0.7.6.
|
10
|
+
- 8
|
11
|
+
version: 0.7.6.8
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- ippa
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-08-
|
19
|
+
date: 2010-08-15 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
hash: -
|
46
|
+
hash: -957518095
|
47
47
|
segments:
|
48
48
|
- 2
|
49
49
|
- 0
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- lib/chingu/game_states/edit.rb
|
194
194
|
- lib/chingu/game_states/fade_to.rb
|
195
195
|
- lib/chingu/game_states/pause.rb
|
196
|
+
- lib/chingu/game_states/popup.rb
|
196
197
|
- lib/chingu/gosu_ext/image.rb
|
197
198
|
- lib/chingu/helpers/class_inheritable_accessor.rb
|
198
199
|
- lib/chingu/helpers/game_object.rb
|