chingu 0.8.0.3 → 0.8.0.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/README.rdoc +2 -0
- data/chingu.gemspec +2 -2
- data/lib/chingu.rb +1 -1
- data/lib/chingu/animation.rb +14 -4
- data/lib/chingu/game_object_list.rb +6 -2
- data/lib/chingu/game_state_manager.rb +2 -4
- data/lib/chingu/helpers/input_client.rb +2 -0
- data/spec/chingu/animation_spec.rb +12 -0
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -26,6 +26,8 @@ There's also more complex examples, like a clone of Conways game of life (http:/
|
|
26
26
|
|
27
27
|
== PROJECTS USING CHINGU
|
28
28
|
Links to some of the projects using/depending on Chingu:
|
29
|
+
* http://ippa.se/games/unexpected_outcome.zip (LD#19 game compo entry by ippa)
|
30
|
+
* https://bitbucket.org/philomory/ld19/ (LD#19 game compo entry by philomory)
|
29
31
|
* https://github.com/Spooner/fidgit (GUI-lib )
|
30
32
|
* https://github.com/Spooner/sidney (Sleep Is Death remake in ruby)
|
31
33
|
* https://github.com/ippa/the_light_at_the_end_of_the_tunnel (LD#16 game compo entry)
|
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.8.0.
|
8
|
+
s.version = "0.8.0.4"
|
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{
|
12
|
+
s.date = %q{2011-01-02}
|
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 = [
|
data/lib/chingu.rb
CHANGED
data/lib/chingu/animation.rb
CHANGED
@@ -30,8 +30,6 @@ module Chingu
|
|
30
30
|
@loop = options[:loop]
|
31
31
|
@bounce = options[:bounce]
|
32
32
|
@file = options[:file]
|
33
|
-
@height = options[:height]
|
34
|
-
@width = options[:width]
|
35
33
|
@index = options[:index]
|
36
34
|
@delay = options[:delay]
|
37
35
|
@step = options[:step] || 1
|
@@ -39,12 +37,24 @@ module Chingu
|
|
39
37
|
|
40
38
|
@sub_animations = {}
|
41
39
|
@frame_actions = []
|
42
|
-
|
40
|
+
|
41
|
+
unless File.exists?(@file)
|
42
|
+
Gosu::Image.autoload_dirs.each do |autoload_dir|
|
43
|
+
full_path = File.join(autoload_dir, @file)
|
44
|
+
if File.exists?(full_path)
|
45
|
+
@file = full_path
|
46
|
+
break
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
43
50
|
|
44
51
|
#
|
45
52
|
# Various ways of determening the framesize
|
46
53
|
#
|
47
|
-
if options[:
|
54
|
+
if options[:height] && options[:width]
|
55
|
+
@height = options[:height]
|
56
|
+
@width = options[:width]
|
57
|
+
elsif options[:size] && options[:size].is_a?(Array)
|
48
58
|
@width = options[:size][0]
|
49
59
|
@height = options[:size][1]
|
50
60
|
elsif options[:size]
|
@@ -56,7 +56,7 @@ module Chingu
|
|
56
56
|
@game_objects.delete(object)
|
57
57
|
#@remove_game_objects.push(object)
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def destroy_if
|
61
61
|
@game_objects.reject! { |object| yield(object) }
|
62
62
|
end
|
@@ -101,7 +101,11 @@ module Chingu
|
|
101
101
|
def select
|
102
102
|
@game_objects.dup.select { |object| yield object }
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
|
+
def map
|
106
|
+
@game_objects.map { |object| yield object }
|
107
|
+
end
|
108
|
+
|
105
109
|
def first
|
106
110
|
@game_objects.first
|
107
111
|
end
|
@@ -269,10 +269,8 @@ module Chingu
|
|
269
269
|
#
|
270
270
|
def update(options = {})
|
271
271
|
puts current_game_state.to_s if options[:debug]
|
272
|
-
if current_game_state
|
273
|
-
|
274
|
-
current_game_state.update
|
275
|
-
end
|
272
|
+
current_game_state.update_trait if current_game_state
|
273
|
+
current_game_state.update if current_game_state
|
276
274
|
end
|
277
275
|
|
278
276
|
#
|
@@ -202,8 +202,10 @@ module Chingu
|
|
202
202
|
end
|
203
203
|
|
204
204
|
# Backwards compatibility function. Use on_inputs or on_input instead.
|
205
|
+
# On object.input = nil we make object not respond to any key.
|
205
206
|
def input=(input_list)
|
206
207
|
@input = nil
|
208
|
+
return if input_list == nil
|
207
209
|
input_list.is_a?(Array) ? add_inputs(*input_list) : add_inputs(input_list)
|
208
210
|
end
|
209
211
|
|
@@ -5,6 +5,7 @@ module Chingu
|
|
5
5
|
before :each do
|
6
6
|
@game = Chingu::Window.new
|
7
7
|
@test_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'images')
|
8
|
+
Gosu::Image.autoload_dirs << @test_dir
|
8
9
|
@animation_clean = Animation.new(:file => File.join(@test_dir, "droid_11x15.bmp"))
|
9
10
|
@animation = Animation.new(:file => File.join(@test_dir, "droid_11x15.bmp"), :delay => 0)
|
10
11
|
end
|
@@ -21,6 +22,17 @@ module Chingu
|
|
21
22
|
@animation_clean.index.should == 0
|
22
23
|
@animation_clean.step.should == 1
|
23
24
|
end
|
25
|
+
|
26
|
+
it "should find single filename in Image.autoload_dirs" do
|
27
|
+
@anim = Animation.new(:file => "droid_11x15.bmp")
|
28
|
+
@anim.frames.count.should == 14
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should find relative filename path" do
|
32
|
+
Dir.chdir(File.dirname(File.expand_path(__FILE__)))
|
33
|
+
@anim = Animation.new(:file => "images/droid_11x15.bmp")
|
34
|
+
@anim.frames.count.should == 14
|
35
|
+
end
|
24
36
|
end
|
25
37
|
|
26
38
|
describe "Animation loading file: droid_11x15.bmp" do
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 8
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.8.0.
|
9
|
+
- 4
|
10
|
+
version: 0.8.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- ippa
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-02 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|