chingu 0.9rc6 → 0.9rc7

Sign up to get free protection for your applications and to get access to all the features.
@@ -124,7 +124,8 @@ class Level < Chingu::GameState
124
124
  :holding_right => :move_right,
125
125
  :holding_up => :move_up,
126
126
  :holding_down => :move_down,
127
- :space => :fire }
127
+ :space => :fire,
128
+ :holding_a => :fire }
128
129
 
129
130
  #
130
131
  # The input-handler understands gamestates. P is pressed --> push_gamegate(Pause)
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems' rescue nil
3
+ $LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
4
+ require 'chingu'
5
+ include Gosu
6
+
7
+ class Game < Chingu::Window
8
+ def initialize
9
+ super(640,480,false) # leave it blank and it will be 800,600,non fullscreen
10
+ self.input = { :escape => :exit } # exits example on Escape
11
+
12
+ @player = Player.create(:x => 200, :y => 200, :image => Image["spaceship.png"])
13
+ @player.input = [ :holding_left, :holding_right, :holding_up, :holding_down, :holding_a ]
14
+ end
15
+
16
+ def update
17
+ super
18
+ self.caption = "FPS: #{self.fps} milliseconds_since_last_tick: #{self.milliseconds_since_last_tick}"
19
+ end
20
+ end
21
+
22
+ class Player < Chingu::GameObject
23
+ def holding_left; @x -= 3; end
24
+ def holding_right; @x += 3; end
25
+ def holding_up; @y -= 3; end
26
+ def holding_down; @y += 3; end
27
+ def holding_a
28
+ Bullet.create(:x => @x, :y => @y)
29
+ end
30
+ end
31
+
32
+ class Bullet < Chingu::GameObject
33
+ def setup
34
+ @image = Image["fire_bullet.png"]
35
+ end
36
+
37
+ def update
38
+ @y -= 2
39
+ end
40
+ end
41
+
42
+
43
+ Game.new.show
@@ -38,7 +38,7 @@ require_all "#{CHINGU_ROOT}/chingu/async_tasks"
38
38
  require_all "#{CHINGU_ROOT}/chingu"
39
39
 
40
40
  module Chingu
41
- VERSION = "0.9rc6"
41
+ VERSION = "0.9rc7"
42
42
 
43
43
  DEBUG_COLOR = Gosu::Color.new(0xFFFF0000)
44
44
  DEBUG_ZORDER = 9999
@@ -1,27 +1,35 @@
1
- class Array
2
-
3
- def each_collision(*klasses)
4
- self.each do |object1|
5
- object1.each_collision(*klasses) do |object1, object2|
6
- yield object1, object2
7
- end
8
- end
9
- end
10
-
11
- def each_bounding_circle_collision(*klasses)
12
- self.each do |object1|
13
- object1.each_bounding_circle_collision(*klasses) do |object1, object2|
14
- yield object1, object2
15
- end
16
- end
17
- end
18
-
19
- def each_bounding_box_collision(*klasses)
20
- self.each do |object1|
21
- object1.each_bounding_box_collision(*klasses) do |object1, object2|
22
- yield object1, object2
23
- end
24
- end
25
- end
26
-
1
+ class Array
2
+
3
+ def each_collision(*klasses)
4
+ self.each do |object1|
5
+ object1.each_collision(*klasses) do |object, object2|
6
+ yield object, object2
7
+ end
8
+ end
9
+ end
10
+
11
+ def each_bounding_circle_collision(*klasses)
12
+ self.each do |object1|
13
+ object1.each_bounding_circle_collision(*klasses) do |object1, object2|
14
+ yield object1, object2
15
+ end
16
+ end
17
+ end
18
+
19
+ def each_bounding_box_collision(*klasses)
20
+ self.each do |object1|
21
+ object1.each_bounding_box_collision(*klasses) do |object1, object2|
22
+ yield object1, object2
23
+ end
24
+ end
25
+ end
26
+
27
+ def each_at(x, y)
28
+ self.each do |object|
29
+ object.each_at(x, y) do |obj|
30
+ yield obj
31
+ end
32
+ end
33
+ end
34
+
27
35
  end
@@ -56,7 +56,7 @@ module Chingu
56
56
  return @cached_bounding_box
57
57
  end
58
58
 
59
- width, height = self.size
59
+ width, height = self.width, self.height
60
60
 
61
61
  if scale = trait_options[:bounding_box][:scale]
62
62
  width_scale, height_scale = scale.is_a?(Array) ? [scale[0],scale[1]] : [scale,scale]
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.9rc6
4
+ version: 0.9rc7
5
5
  prerelease: 3
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-25 00:00:00.000000000Z
12
+ date: 2011-06-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gosu
16
- requirement: &25668120 !ruby/object:Gem::Requirement
16
+ requirement: &27817008 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.7.33
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *25668120
24
+ version_requirements: *27817008
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: gosu
27
- requirement: &25667832 !ruby/object:Gem::Requirement
27
+ requirement: &27816648 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.7.33
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *25667832
35
+ version_requirements: *27816648
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &25667544 !ruby/object:Gem::Requirement
38
+ requirement: &27816288 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.1.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *25667544
46
+ version_requirements: *27816288
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: watchr
49
- requirement: &25667256 !ruby/object:Gem::Requirement
49
+ requirement: &27815988 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *25667256
57
+ version_requirements: *27815988
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &25666968 !ruby/object:Gem::Requirement
60
+ requirement: &27815616 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *25666968
68
+ version_requirements: *27815616
69
69
  description: OpenGL accelerated 2D game framework for Ruby. Builds on Gosu (Ruby/C++)
70
70
  which provides all the core functionality. Chingu adds simple yet powerful game
71
71
  states, prettier input handling, deployment safe asset-handling, a basic re-usable
@@ -221,7 +221,8 @@ files:
221
221
  - examples/media/tube.png
222
222
  - examples/media/video_games.png
223
223
  - examples/media/wood.png
224
- - examples/tool1_input_codes.rb
224
+ - examples/tests/holding_a_test.rb
225
+ - examples/tests/tool1_input_codes.rb
225
226
  - benchmarks/arrays_bench.rb
226
227
  - benchmarks/array_vs_hash.rb
227
228
  - benchmarks/benchmark.rb