chingu 0.6.7 → 0.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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ pkg
3
+ .gem
4
+ .git
@@ -543,13 +543,20 @@ You can also scale the calculated rect with has_trait-options:
543
543
  # This would return a rect slightly smaller then the image.
544
544
  # Make player think he's better @ dodging bullets then he really is ;)
545
545
  has_trait :bounding_box, :scale => 0.80
546
+
547
+ # Make the bounding box bigger then the image
548
+ # :debug => true shows the actual box in red on the screen
549
+ has_trait :bounding_box, :scale => 1.5, :debug => true
546
550
 
547
551
  ==== Trait "bounding_circle"
548
552
  Adds accessor 'radius', which returns a Fixnum based on current image size,factor_x and factor_y
549
553
  You can also scale the calculated radius with has_trait-options:
550
554
 
551
555
  # This would return a radius slightly bigger then what initialize was calculated
552
- has_trait :radius, :scale => 1.10
556
+ has_trait :bounding_circle, :scale => 1.10
557
+
558
+ # :debug => true shows the actual circle in red on the screen
559
+ has_trait :bounding_circle, :debug => true
553
560
 
554
561
  ==== Trait "effect"
555
562
  Adds accessors rotation_rate, fade_rate and scale_rate to game object.
@@ -605,9 +612,9 @@ You also have:
605
612
  Song["intromusic.ogg"]
606
613
 
607
614
  The default settings are like this:
608
- Image["image.png"] -- searches directories ".", "images", "gfx" and "media"
609
- Sample["sample.wav"] -- searches directories ".", "sounds", "sfx" and "media"
610
- Song["song.ogg"] -- searches directories ".", "songs", "sounds", "sfx" and "media"
615
+ Image["image.png"] -- searches directories ".", "images", "gfx" and "media"
616
+ Sample["sample.wav"] -- searches directories ".", "sounds", "sfx" and "media"
617
+ Song["song.ogg"] -- searches directories ".", "songs", "sounds", "sfx" and "media"
611
618
 
612
619
  Add your own searchpaths like this:
613
620
  Gosu::Image.autoload_dirs << File.join(ROOT, "gfx")
data/Rakefile CHANGED
@@ -1,35 +1,22 @@
1
1
  require 'rubygems'
2
- require 'hoe'
3
2
  require File.dirname(__FILE__) + '/lib/chingu'
4
-
5
3
  include Chingu
6
4
 
7
- Hoe.plugin :git
8
- Hoe.spec "chingu" do
9
- developer "ippa", "ippa@rubylicio.us"
10
- self.readme_file = 'README.rdoc'
11
- self.rubyforge_name = "chingu"
12
- self.version = Chingu::VERSION
13
- end
14
-
15
- desc "Build a working gemspec"
16
- task :gemspec do
17
- system "rake git:manifest"
18
- system "rake debug_gem | grep -v \"(in \" | grep -v \"erik\" > chingu.gemspec"
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gemspec|
8
+ gemspec.name = "chingu"
9
+ gemspec.summary = "OpenGL accelerated 2D game framework for Ruby"
10
+ gemspec.description = "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."
11
+ gemspec.email = "ippa@rubylicio.us"
12
+ gemspec.homepage = "http://github.com/ippa/chingu"
13
+ gemspec.authors = ["ippa"]
14
+ gemspec.rubyforge_project = "chingu"
15
+ gemspec.version = Chingu::VERSION
16
+
17
+ gemspec.add_dependency 'gosu', '>= 0.7.15'
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
19
22
  end
20
-
21
-
22
- #begin
23
- # require 'jeweler'
24
- # Jeweler::Tasks.new do |gemspec|
25
- # gemspec.name = "chingu"
26
- # gemspec.summary = "Game framework built on top of the OpenGL accelerated game lib Gosu"
27
- # gemspec.description = "Game framework built on top of the OpenGL accelerated game lib Gosu"
28
- # gemspec.email = "ippa@rubylicio.us"
29
- # gemspec.homepage = "http://github.com/ippa/chingu"
30
- # gemspec.authors = ["ippa"]
31
- # gemspec.rubyforge_project = "chingu"
32
- # end
33
- #rescue LoadError
34
- # puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
35
- #end
@@ -1,35 +1,167 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{chingu}
5
- s.version = "0.6.7"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["ippa"]
9
- s.date = %q{2009-12-13}
10
- s.description = %q{OpenGL accelerated 2D game framework for Ruby.
11
- Builds on the awesome Gosu (Ruby/C++) which provides all the core functionality.
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.}
13
- s.email = ["ippa@rubylicio.us"]
14
- s.extra_rdoc_files = ["History.txt", "Manifest.txt", "benchmarks/README.txt"]
15
- s.files = ["History.txt", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "benchmarks/README.txt", "benchmarks/benchmark.rb", "benchmarks/benchmark3.rb", "benchmarks/benchmark4.rb", "benchmarks/benchmark5.rb", "benchmarks/benchmark6.rb", "benchmarks/meta_benchmark.rb", "benchmarks/meta_benchmark2.rb", "chingu.gemspec", "examples/example1.rb", "examples/example10.rb", "examples/example11.rb", "examples/example12.rb", "examples/example13.rb", "examples/example14.rb", "examples/example15.rb", "examples/example16.rb", "examples/example2.rb", "examples/example3.rb", "examples/example4.rb", "examples/example5.rb", "examples/example6.rb", "examples/example7.rb", "examples/example8.rb", "examples/example9.rb", "examples/game1.rb", "examples/high_score_list.yml", "examples/media/Parallax-scroll-example-layer-0.png", "examples/media/Parallax-scroll-example-layer-1.png", "examples/media/Parallax-scroll-example-layer-2.png", "examples/media/Parallax-scroll-example-layer-3.png", "examples/media/background1.png", "examples/media/bullet.png", "examples/media/bullet_hit.wav", "examples/media/circle.png", "examples/media/city1.csv", "examples/media/city1.png", "examples/media/city2.png", "examples/media/droid.bmp", "examples/media/enemy_bullet.png", "examples/media/explosion.wav", "examples/media/fire_bullet.png", "examples/media/fireball.png", "examples/media/laser.wav", "examples/media/particle.png", "examples/media/plane.csv", "examples/media/plane.png", "examples/media/rect.png", "examples/media/ruby.png", "examples/media/saucer.csv", "examples/media/saucer.gal", "examples/media/saucer.png", "examples/media/spaceship.png", "examples/media/stickfigure.bmp", "examples/media/stickfigure.png", "examples/media/video_games.png", "examples/media/wood.png", "lib/chingu.rb", "lib/chingu/animation.rb", "lib/chingu/assets.rb", "lib/chingu/basic_game_object.rb", "lib/chingu/core_ext/array.rb", "lib/chingu/fpscounter.rb", "lib/chingu/game_object.rb", "lib/chingu/game_object_list.rb", "lib/chingu/game_state.rb", "lib/chingu/game_state_manager.rb", "lib/chingu/game_states/debug.rb", "lib/chingu/game_states/edit.rb", "lib/chingu/game_states/fade_to.rb", "lib/chingu/game_states/pause.rb", "lib/chingu/gosu_ext/image.rb", "lib/chingu/helpers/class_inheritable_accessor.rb", "lib/chingu/helpers/game_object.rb", "lib/chingu/helpers/game_state.rb", "lib/chingu/helpers/gfx.rb", "lib/chingu/helpers/input_client.rb", "lib/chingu/helpers/input_dispatcher.rb", "lib/chingu/helpers/rotation_center.rb", "lib/chingu/high_score_list.rb", "lib/chingu/inflector.rb", "lib/chingu/input.rb", "lib/chingu/named_resource.rb", "lib/chingu/online_high_score_list.rb", "lib/chingu/parallax.rb", "lib/chingu/particle.rb", "lib/chingu/rect.rb", "lib/chingu/require_all.rb", "lib/chingu/text.rb", "lib/chingu/traits/bounding_box.rb", "lib/chingu/traits/bounding_circle.rb", "lib/chingu/traits/collision_detection.rb", "lib/chingu/traits/effect.rb", "lib/chingu/traits/retrofy.rb", "lib/chingu/traits/timer.rb", "lib/chingu/traits/velocity.rb", "lib/chingu/window.rb"]
16
- s.homepage = %q{http://github.com/ippa/chingu/tree/master}
17
- s.rdoc_options = ["--main", "README.rdoc"]
18
- s.require_paths = ["lib"]
19
- s.rubyforge_project = %q{chingu}
20
- s.rubygems_version = %q{1.3.5}
21
- s.summary = %q{OpenGL accelerated 2D game framework for Ruby}
22
-
23
- if s.respond_to? :specification_version then
24
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
- s.specification_version = 3
26
-
27
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<hoe>, [">= 2.4.0"])
29
- else
30
- s.add_dependency(%q<hoe>, [">= 2.4.0"])
31
- end
32
- else
33
- s.add_dependency(%q<hoe>, [">= 2.4.0"])
34
- end
35
- end
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{chingu}
8
+ s.version = "0.6.8"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["ippa"]
12
+ s.date = %q{2009-12-27}
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
+ s.email = %q{ippa@rubylicio.us}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "History.txt",
22
+ "LICENSE",
23
+ "Manifest.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "benchmarks/README.txt",
27
+ "benchmarks/benchmark.rb",
28
+ "benchmarks/benchmark3.rb",
29
+ "benchmarks/benchmark4.rb",
30
+ "benchmarks/benchmark5.rb",
31
+ "benchmarks/benchmark6.rb",
32
+ "benchmarks/meta_benchmark.rb",
33
+ "benchmarks/meta_benchmark2.rb",
34
+ "chingu.gemspec",
35
+ "examples/example10_traits_retrofy.rb",
36
+ "examples/example11_animation.rb",
37
+ "examples/example12_trait_timer.rb",
38
+ "examples/example13_high_scores.rb",
39
+ "examples/example14_bounding_box_circle.rb",
40
+ "examples/example15_trait_timer2.rb",
41
+ "examples/example16_online_high_scores.rb",
42
+ "examples/example17_gosu_tutorial.rb",
43
+ "examples/example1_basics.rb",
44
+ "examples/example2_gamestate_basics.rb",
45
+ "examples/example3_parallax.rb",
46
+ "examples/example4_gamestates.rb",
47
+ "examples/example5_gamestates_in_pure_gosu.rb",
48
+ "examples/example6_transitional_game_state.rb",
49
+ "examples/example7_gfx_helpers.rb",
50
+ "examples/example8_traits.rb",
51
+ "examples/example9_collision_detection.rb",
52
+ "examples/game1.rb",
53
+ "examples/high_score_list.yml",
54
+ "examples/media/Parallax-scroll-example-layer-0.png",
55
+ "examples/media/Parallax-scroll-example-layer-1.png",
56
+ "examples/media/Parallax-scroll-example-layer-2.png",
57
+ "examples/media/Parallax-scroll-example-layer-3.png",
58
+ "examples/media/Star.png",
59
+ "examples/media/Starfighter.bmp",
60
+ "examples/media/background1.png",
61
+ "examples/media/bullet.png",
62
+ "examples/media/bullet_hit.wav",
63
+ "examples/media/circle.png",
64
+ "examples/media/city1.csv",
65
+ "examples/media/city1.png",
66
+ "examples/media/city2.png",
67
+ "examples/media/droid.bmp",
68
+ "examples/media/enemy_bullet.png",
69
+ "examples/media/explosion.wav",
70
+ "examples/media/fire_bullet.png",
71
+ "examples/media/fireball.png",
72
+ "examples/media/laser.wav",
73
+ "examples/media/particle.png",
74
+ "examples/media/plane.csv",
75
+ "examples/media/plane.png",
76
+ "examples/media/rect.png",
77
+ "examples/media/ruby.png",
78
+ "examples/media/saucer.csv",
79
+ "examples/media/saucer.gal",
80
+ "examples/media/saucer.png",
81
+ "examples/media/spaceship.png",
82
+ "examples/media/stickfigure.bmp",
83
+ "examples/media/stickfigure.png",
84
+ "examples/media/video_games.png",
85
+ "examples/media/wood.png",
86
+ "lib/chingu.rb",
87
+ "lib/chingu/animation.rb",
88
+ "lib/chingu/assets.rb",
89
+ "lib/chingu/basic_game_object.rb",
90
+ "lib/chingu/core_ext/array.rb",
91
+ "lib/chingu/fpscounter.rb",
92
+ "lib/chingu/game_object.rb",
93
+ "lib/chingu/game_object_list.rb",
94
+ "lib/chingu/game_state.rb",
95
+ "lib/chingu/game_state_manager.rb",
96
+ "lib/chingu/game_states/debug.rb",
97
+ "lib/chingu/game_states/edit.rb",
98
+ "lib/chingu/game_states/fade_to.rb",
99
+ "lib/chingu/game_states/pause.rb",
100
+ "lib/chingu/gosu_ext/image.rb",
101
+ "lib/chingu/helpers/class_inheritable_accessor.rb",
102
+ "lib/chingu/helpers/game_object.rb",
103
+ "lib/chingu/helpers/game_state.rb",
104
+ "lib/chingu/helpers/gfx.rb",
105
+ "lib/chingu/helpers/input_client.rb",
106
+ "lib/chingu/helpers/input_dispatcher.rb",
107
+ "lib/chingu/helpers/rotation_center.rb",
108
+ "lib/chingu/high_score_list.rb",
109
+ "lib/chingu/inflector.rb",
110
+ "lib/chingu/input.rb",
111
+ "lib/chingu/named_resource.rb",
112
+ "lib/chingu/online_high_score_list.rb",
113
+ "lib/chingu/parallax.rb",
114
+ "lib/chingu/particle.rb",
115
+ "lib/chingu/rect.rb",
116
+ "lib/chingu/require_all.rb",
117
+ "lib/chingu/text.rb",
118
+ "lib/chingu/traits/bounding_box.rb",
119
+ "lib/chingu/traits/bounding_circle.rb",
120
+ "lib/chingu/traits/collision_detection.rb",
121
+ "lib/chingu/traits/effect.rb",
122
+ "lib/chingu/traits/retrofy.rb",
123
+ "lib/chingu/traits/timer.rb",
124
+ "lib/chingu/traits/velocity.rb",
125
+ "lib/chingu/window.rb"
126
+ ]
127
+ s.homepage = %q{http://github.com/ippa/chingu}
128
+ s.rdoc_options = ["--charset=UTF-8"]
129
+ s.require_paths = ["lib"]
130
+ s.rubyforge_project = %q{chingu}
131
+ s.rubygems_version = %q{1.3.5}
132
+ s.summary = %q{OpenGL accelerated 2D game framework for Ruby}
133
+ s.test_files = [
134
+ "examples/example10_traits_retrofy.rb",
135
+ "examples/example11_animation.rb",
136
+ "examples/example12_trait_timer.rb",
137
+ "examples/example13_high_scores.rb",
138
+ "examples/example14_bounding_box_circle.rb",
139
+ "examples/example15_trait_timer2.rb",
140
+ "examples/example16_online_high_scores.rb",
141
+ "examples/example17_gosu_tutorial.rb",
142
+ "examples/example1_basics.rb",
143
+ "examples/example2_gamestate_basics.rb",
144
+ "examples/example3_parallax.rb",
145
+ "examples/example4_gamestates.rb",
146
+ "examples/example5_gamestates_in_pure_gosu.rb",
147
+ "examples/example6_transitional_game_state.rb",
148
+ "examples/example7_gfx_helpers.rb",
149
+ "examples/example8_traits.rb",
150
+ "examples/example9_collision_detection.rb",
151
+ "examples/game1.rb"
152
+ ]
153
+
154
+ if s.respond_to? :specification_version then
155
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
156
+ s.specification_version = 3
157
+
158
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
159
+ s.add_runtime_dependency(%q<gosu>, [">= 0.7.15"])
160
+ else
161
+ s.add_dependency(%q<gosu>, [">= 0.7.15"])
162
+ end
163
+ else
164
+ s.add_dependency(%q<gosu>, [">= 0.7.15"])
165
+ end
166
+ end
167
+
@@ -51,7 +51,8 @@ class Thing < Chingu::GameObject
51
51
  @image.retrofy
52
52
 
53
53
 
54
- self.factor = 8
54
+ self.scale = 8
55
+ puts "scale: " + scale.to_i.to_s
55
56
  self.rotation_rate = 2
56
57
  self.velocity_x = 2
57
58
  end
@@ -73,3 +74,4 @@ end
73
74
 
74
75
 
75
76
  Game.new.show
77
+
@@ -3,6 +3,9 @@ require File.join(File.dirname($0), "..", "lib", "chingu")
3
3
  include Gosu
4
4
  include Chingu
5
5
 
6
+ #
7
+ # Using trait "timer" to achieve various moves
8
+ #
6
9
  class Game < Chingu::Window
7
10
  def initialize
8
11
  super(640,400)
@@ -4,7 +4,7 @@ include Gosu
4
4
  include Chingu
5
5
 
6
6
  #
7
- # Demonstrating Chingutrait radius, bounding_box and collision_detection.
7
+ # Demonstrating Chingu-traits bounding_circle, bounding_box and collision_detection.
8
8
  #
9
9
  class Game < Chingu::Window
10
10
  def initialize
@@ -0,0 +1,103 @@
1
+ require 'rubygems'
2
+ require File.join(File.dirname($0), "..", "lib", "chingu")
3
+ include Gosu
4
+ include Chingu
5
+
6
+ # Set to true to see bounding circles used for collision detection
7
+ DEBUG = false
8
+
9
+ class Game < Chingu::Window
10
+ def initialize
11
+ super(640,400)
12
+ self.input = {:esc => :exit}
13
+
14
+ @player = Player.create(:zorder => 2, :x=>320, :y=>240)
15
+ @score = 0
16
+ @score_text = Text.create("Score: #{@score}", :x => 10, :y => 10, :zorder => 55, :size=>20)
17
+ end
18
+
19
+ def update
20
+ super
21
+
22
+ if rand(100) < 4 && Star.all.size < 25
23
+ Star.create
24
+ end
25
+
26
+ #
27
+ # Collide @player with all instances of class Star
28
+ #
29
+ @player.each_collision(Star) do |player, star|
30
+ star.destroy
31
+ @score+=10
32
+ end
33
+
34
+ @score_text.text = "Score: #{@score}"
35
+ self.caption = "Chingu Game - " + @score_text.text
36
+ end
37
+ end
38
+
39
+ class Player < GameObject
40
+ has_trait :bounding_circle, :debug => DEBUG
41
+ has_traits :collision_detection, :effect, :velocity
42
+
43
+ def initialize(options={})
44
+ super(options)
45
+ @image = Image["Starfighter.bmp"]
46
+ self.input = {:holding_right=>:turn_right, :holding_left=>:turn_left, :holding_up=>:accelerate}
47
+ self.max_velocity = 10
48
+ end
49
+
50
+ def accelerate
51
+ self.velocity_x = Gosu::offset_x(self.angle, 0.5)*self.max_velocity
52
+ self.velocity_y = Gosu::offset_y(self.angle, 0.5)*self.max_velocity
53
+ end
54
+
55
+ def turn_right
56
+ # The same can be achieved without trait 'effect' as: self.angle += 4.5
57
+ rotate(4.5)
58
+ end
59
+
60
+ def turn_left
61
+ # The same can be achieved without trait 'effect' as: self.angle -= 4.5
62
+ rotate(-4.5)
63
+ end
64
+
65
+ def update
66
+ self.velocity_x *= 0.95 # dampen the movement
67
+ self.velocity_y *= 0.95
68
+
69
+ @x %= $window.width # wrap around the screen
70
+ @y %= $window.height
71
+ end
72
+ end
73
+
74
+ class Star < GameObject
75
+ has_trait :bounding_circle, :debug => DEBUG
76
+ has_trait :collision_detection
77
+
78
+ def initialize(options={})
79
+ super(:zorder=>1)
80
+ @animation = Chingu::Animation.new(:file => media_path("Star.png"), :size => 25)
81
+ @image = @animation.next
82
+ self.color = Gosu::Color.new(0xff000000)
83
+ self.color.red = rand(255 - 40) + 40
84
+ self.color.green = rand(255 - 40) + 40
85
+ self.color.blue = rand(255 - 40) + 40
86
+ self.x =rand * 640
87
+ self.y =rand * 480
88
+
89
+ #
90
+ # A cached bounding circle will not adapt to changes in size, but it will follow objects X / Y
91
+ # Same is true for "cache_bounding_box"
92
+ #
93
+ cache_bounding_circle
94
+ end
95
+
96
+ def update
97
+ # Move the animation forward by fetching the next frame and putting it into @image
98
+ # @image is drawn by default by GameObject#draw
99
+ @image = @animation.next
100
+ end
101
+ end
102
+
103
+ Game.new.show
Binary file
@@ -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.7"
36
+ VERSION = "0.6.8"
37
37
 
38
38
  DEBUG_COLOR = Gosu::Color.new(0xFFFF0000)
39
39
  DEBUG_ZORDER = 9999
@@ -20,7 +20,7 @@ module Chingu
20
20
  # - file: Tile-file to cut up animation frames from. Could be a full path or just a name -- then it will look for media_path(file)
21
21
  # - width: width of each frame in the tileanimation
22
22
  # - height: width of each frame in the tileanimation
23
- # - size: [x,y] specify width/height with 1 argument (an array)
23
+ # - size: [width, height]-Array or just one fixnum which will spez both height and width
24
24
  # - delay: milliseconds between each frame
25
25
  # - step: [steps] move animation forward [steps] frames each time we call #next
26
26
  #
@@ -37,9 +37,12 @@ module Chingu
37
37
  @step = options[:step] || 1
38
38
  @dt = 0
39
39
 
40
- if options[:size]
40
+ if options[:size] && options[:size].is_a?(Array)
41
41
  @width = options[:size][0]
42
42
  @height = options[:size][1]
43
+ elsif options[:size]
44
+ @width = options[:size]
45
+ @height = options[:size]
43
46
  end
44
47
 
45
48
  @file = media_path(@file) unless File.exist?(@file)
@@ -51,13 +51,12 @@ module Chingu
51
51
  @y = options[:y] || 0
52
52
  @angle = options[:angle] || 0
53
53
 
54
- self.factor = options[:factor] || 1.0
54
+ self.factor = options[:factor] || options[:scale] || 1.0
55
55
  @factor_x = options[:factor_x] if options[:factor_x]
56
56
  @factor_y = options[:factor_y] if options[:factor_y]
57
57
 
58
58
  self.center = options[:center] || 0.5
59
59
 
60
-
61
60
  @rotation_center = options[:rotation_center]
62
61
  self.rotation_center(options[:rotation_center]) if options[:rotation_center]
63
62
 
@@ -74,8 +73,6 @@ module Chingu
74
73
 
75
74
  @mode = options[:mode] || :default # :additive is also available.
76
75
  @zorder = options[:zorder] || 100
77
-
78
- #setup_trait(options) if self.respond_to?(:setup_trait)
79
76
  end
80
77
 
81
78
  # Quick way of setting both factor_x and factor_y
@@ -83,6 +80,8 @@ module Chingu
83
80
  @factor = factor
84
81
  @factor_x = @factor_y = factor
85
82
  end
83
+ alias scale= factor=
84
+ alias scale factor
86
85
 
87
86
  # Quick way of setting both center_x and center_y
88
87
  def center=(center)
@@ -31,6 +31,12 @@ module Chingu
31
31
  attr_accessor :velocity_x, :velocity_y, :acceleration_x, :acceleration_y, :max_velocity
32
32
  attr_reader :previous_x, :previous_y
33
33
 
34
+ module ClassMethods
35
+ def initialize_trait(options = {})
36
+ trait_options[:velocity] = {:apply => true}.merge(options)
37
+ end
38
+ end
39
+
34
40
  def setup_trait(options)
35
41
  @velocity_options = {:debug => false}.merge(options)
36
42
 
@@ -52,8 +58,13 @@ module Chingu
52
58
  @previous_y = @y
53
59
  @previous_x = @x
54
60
 
55
- self.y += @velocity_y
56
- self.x += @velocity_x
61
+ #
62
+ # if option :apply is false, just calculate velocities, don't apply them to x/y
63
+ #
64
+ if trait_options[:velocity][:apply]
65
+ self.y += @velocity_y
66
+ self.x += @velocity_x
67
+ end
57
68
  super
58
69
  end
59
70
 
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.7
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ippa
@@ -9,34 +9,30 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-13 00:00:00 +01:00
12
+ date: 2009-12-27 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: hoe
17
- type: :development
16
+ name: gosu
17
+ type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.4.0
23
+ version: 0.7.15
24
24
  version:
25
- description: |-
26
- OpenGL accelerated 2D game framework for Ruby.
27
- Builds on the awesome Gosu (Ruby/C++) which provides all the core functionality.
28
- 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.
29
- email:
30
- - ippa@rubylicio.us
25
+ description: 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.
26
+ email: ippa@rubylicio.us
31
27
  executables: []
32
28
 
33
29
  extensions: []
34
30
 
35
31
  extra_rdoc_files:
36
- - History.txt
37
- - Manifest.txt
38
- - benchmarks/README.txt
32
+ - LICENSE
33
+ - README.rdoc
39
34
  files:
35
+ - .gitignore
40
36
  - History.txt
41
37
  - LICENSE
42
38
  - Manifest.txt
@@ -51,28 +47,31 @@ files:
51
47
  - benchmarks/meta_benchmark.rb
52
48
  - benchmarks/meta_benchmark2.rb
53
49
  - chingu.gemspec
54
- - examples/example1.rb
55
- - examples/example10.rb
56
- - examples/example11.rb
57
- - examples/example12.rb
58
- - examples/example13.rb
59
- - examples/example14.rb
60
- - examples/example15.rb
61
- - examples/example16.rb
62
- - examples/example2.rb
63
- - examples/example3.rb
64
- - examples/example4.rb
65
- - examples/example5.rb
66
- - examples/example6.rb
67
- - examples/example7.rb
68
- - examples/example8.rb
69
- - examples/example9.rb
50
+ - examples/example10_traits_retrofy.rb
51
+ - examples/example11_animation.rb
52
+ - examples/example12_trait_timer.rb
53
+ - examples/example13_high_scores.rb
54
+ - examples/example14_bounding_box_circle.rb
55
+ - examples/example15_trait_timer2.rb
56
+ - examples/example16_online_high_scores.rb
57
+ - examples/example17_gosu_tutorial.rb
58
+ - examples/example1_basics.rb
59
+ - examples/example2_gamestate_basics.rb
60
+ - examples/example3_parallax.rb
61
+ - examples/example4_gamestates.rb
62
+ - examples/example5_gamestates_in_pure_gosu.rb
63
+ - examples/example6_transitional_game_state.rb
64
+ - examples/example7_gfx_helpers.rb
65
+ - examples/example8_traits.rb
66
+ - examples/example9_collision_detection.rb
70
67
  - examples/game1.rb
71
68
  - examples/high_score_list.yml
72
69
  - examples/media/Parallax-scroll-example-layer-0.png
73
70
  - examples/media/Parallax-scroll-example-layer-1.png
74
71
  - examples/media/Parallax-scroll-example-layer-2.png
75
72
  - examples/media/Parallax-scroll-example-layer-3.png
73
+ - examples/media/Star.png
74
+ - examples/media/Starfighter.bmp
76
75
  - examples/media/background1.png
77
76
  - examples/media/bullet.png
78
77
  - examples/media/bullet_hit.wav
@@ -140,13 +139,12 @@ files:
140
139
  - lib/chingu/traits/velocity.rb
141
140
  - lib/chingu/window.rb
142
141
  has_rdoc: true
143
- homepage: http://github.com/ippa/chingu/tree/master
142
+ homepage: http://github.com/ippa/chingu
144
143
  licenses: []
145
144
 
146
145
  post_install_message:
147
146
  rdoc_options:
148
- - --main
149
- - README.rdoc
147
+ - --charset=UTF-8
150
148
  require_paths:
151
149
  - lib
152
150
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -168,5 +166,22 @@ rubygems_version: 1.3.5
168
166
  signing_key:
169
167
  specification_version: 3
170
168
  summary: OpenGL accelerated 2D game framework for Ruby
171
- test_files: []
172
-
169
+ test_files:
170
+ - examples/example10_traits_retrofy.rb
171
+ - examples/example11_animation.rb
172
+ - examples/example12_trait_timer.rb
173
+ - examples/example13_high_scores.rb
174
+ - examples/example14_bounding_box_circle.rb
175
+ - examples/example15_trait_timer2.rb
176
+ - examples/example16_online_high_scores.rb
177
+ - examples/example17_gosu_tutorial.rb
178
+ - examples/example1_basics.rb
179
+ - examples/example2_gamestate_basics.rb
180
+ - examples/example3_parallax.rb
181
+ - examples/example4_gamestates.rb
182
+ - examples/example5_gamestates_in_pure_gosu.rb
183
+ - examples/example6_transitional_game_state.rb
184
+ - examples/example7_gfx_helpers.rb
185
+ - examples/example8_traits.rb
186
+ - examples/example9_collision_detection.rb
187
+ - examples/game1.rb