chingu 0.5.9.3 → 0.5.9.4
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.tar.gz.sig +0 -0
- data/chingu.gemspec +2 -2
- data/lib/chingu.rb +1 -1
- data/lib/chingu/basic_game_object.rb +2 -5
- data/lib/chingu/game_state.rb +26 -1
- data/lib/chingu/game_state_manager.rb +8 -2
- data/lib/chingu/game_states/edit.rb +1 -0
- data/lib/chingu/game_states/fade_to.rb +3 -0
- data/lib/chingu/helpers/gfx.rb +2 -2
- 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.5.9.
|
5
|
+
s.version = "0.5.9.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-16}
|
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/lib/chingu.rb
CHANGED
@@ -10,17 +10,14 @@ module Chingu
|
|
10
10
|
attr_accessor :parent
|
11
11
|
|
12
12
|
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# Executes a ruby "include" the specified module
|
13
|
+
# Adds a trait or traits to a certain game class
|
14
|
+
# Executes a standard ruby "include" the specified module
|
16
15
|
#
|
17
16
|
def self.has_trait(*traits)
|
18
17
|
has_traits(*traits)
|
19
18
|
end
|
20
19
|
|
21
|
-
#
|
22
20
|
# See #has_trait
|
23
|
-
#
|
24
21
|
def self.has_traits(*traits)
|
25
22
|
Array(traits).each do |trait|
|
26
23
|
if trait.is_a?(::Symbol) || trait.is_a?(::String)
|
data/lib/chingu/game_state.rb
CHANGED
@@ -58,6 +58,24 @@ module Chingu
|
|
58
58
|
attr_reader :options
|
59
59
|
attr_accessor :game_state_manager, :game_objects
|
60
60
|
|
61
|
+
#
|
62
|
+
# Adds a trait or traits to a certain game class
|
63
|
+
# Executes a standard ruby "include" the specified module
|
64
|
+
#
|
65
|
+
def self.has_trait(*traits)
|
66
|
+
has_traits(*traits)
|
67
|
+
end
|
68
|
+
|
69
|
+
# See #has_trait
|
70
|
+
def self.has_traits(*traits)
|
71
|
+
Array(traits).each do |trait|
|
72
|
+
if trait.is_a?(::Symbol) || trait.is_a?(::String)
|
73
|
+
include Chingu::Traits.const_get(Chingu::Inflector.camelize(trait))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
61
79
|
def initialize(options = {})
|
62
80
|
@options = options
|
63
81
|
@game_objects = GameObjectList.new
|
@@ -67,6 +85,8 @@ module Chingu
|
|
67
85
|
if defined?($window) && $window.respond_to?(:game_state_manager)
|
68
86
|
$window.game_state_manager.inside_state = self
|
69
87
|
end
|
88
|
+
|
89
|
+
setup_trait(options)
|
70
90
|
end
|
71
91
|
|
72
92
|
#
|
@@ -100,7 +120,7 @@ module Chingu
|
|
100
120
|
dispatch_button_up(id, self)
|
101
121
|
@input_clients.each { |object| dispatch_button_up(id, object) } if @input_clients
|
102
122
|
end
|
103
|
-
|
123
|
+
|
104
124
|
#
|
105
125
|
# Calls update on each game object that has current game state as parent (created inside that game state)
|
106
126
|
#
|
@@ -118,6 +138,11 @@ module Chingu
|
|
118
138
|
def draw
|
119
139
|
@game_objects.draw
|
120
140
|
end
|
141
|
+
|
142
|
+
# Placeholder for trait-system to override
|
143
|
+
def setup_trait(options);end
|
144
|
+
def update_trait;end
|
145
|
+
def draw_trait;end
|
121
146
|
|
122
147
|
#
|
123
148
|
# Closes game state by poping it off the stack (and activating the game state below)
|
@@ -262,7 +262,10 @@ module Chingu
|
|
262
262
|
# If you're using Chingu::Window instead of Gosu::Window this will automaticly be called.
|
263
263
|
#
|
264
264
|
def update
|
265
|
-
|
265
|
+
if current_game_state
|
266
|
+
current_game_state.update_trait
|
267
|
+
current_game_state.update
|
268
|
+
end
|
266
269
|
end
|
267
270
|
|
268
271
|
#
|
@@ -272,7 +275,10 @@ module Chingu
|
|
272
275
|
# If you're using Chingu::Window instead of Gosu::Window this will automaticly be called.
|
273
276
|
#
|
274
277
|
def draw
|
275
|
-
|
278
|
+
if current_game_state
|
279
|
+
current_game_state.draw_trait
|
280
|
+
current_game_state.draw
|
281
|
+
end
|
276
282
|
end
|
277
283
|
|
278
284
|
private
|
@@ -42,6 +42,7 @@ module Chingu
|
|
42
42
|
self.input = { :left_mouse_button => :left_mouse_button,
|
43
43
|
:released_left_mouse_button => :released_left_mouse_button,
|
44
44
|
:delete => :destroy_selected_game_objects,
|
45
|
+
:backspace => :destroy_selected_game_objects,
|
45
46
|
:e => :save_and_quit,
|
46
47
|
:s => :save,
|
47
48
|
:esc => :quit,
|
@@ -37,7 +37,10 @@ module Chingu
|
|
37
37
|
|
38
38
|
def initialize(new_game_state, options = {})
|
39
39
|
@options = {:speed => 3}.merge(options)
|
40
|
+
|
40
41
|
@new_game_state = new_game_state
|
42
|
+
@new_game_state = new_game_state.new if new_game_state.is_a? Class
|
43
|
+
|
41
44
|
@manager = options[:game_state_manager] || self
|
42
45
|
#@manager = game_state_manager
|
43
46
|
end
|
data/lib/chingu/helpers/gfx.rb
CHANGED
@@ -48,12 +48,12 @@ module Chingu
|
|
48
48
|
# :orientation - Either :vertical (top to bottom) or :horizontal (left to right)
|
49
49
|
#
|
50
50
|
|
51
|
-
def fill(options)
|
51
|
+
def fill(options, zorder = 99)
|
52
52
|
#
|
53
53
|
# if only 1 color-argument is given, assume fullscreen simple color fill.
|
54
54
|
#
|
55
55
|
if options.is_a?(Gosu::Color)
|
56
|
-
$window.draw_quad(0, 0,
|
56
|
+
$window.draw_quad(0, 0, options,
|
57
57
|
$window.width, 0, options,
|
58
58
|
$window.width, $window.height, options,
|
59
59
|
0, $window.height, options, 0, :default)
|
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.5.9.
|
4
|
+
version: 0.5.9.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-16 00:00:00 +01:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|