ippa-chingu 0.5.3 → 0.5.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/LICENSE +504 -0
- data/Manifest.txt +6 -2
- data/README.rdoc +7 -6
- data/benchmarks/benchmark5.rb +29 -0
- data/chingu.gemspec +3 -3
- data/examples/example10.rb +71 -0
- data/examples/example9.rb +25 -14
- data/lib/chingu.rb +24 -47
- data/lib/chingu/basic_game_object.rb +6 -50
- data/lib/chingu/core_extensions.rb +22 -0
- data/lib/chingu/effects.rb +22 -0
- data/lib/chingu/fpscounter.rb +22 -0
- data/lib/chingu/game_object.rb +24 -1
- data/lib/chingu/game_state.rb +22 -0
- data/lib/chingu/game_state_manager.rb +22 -0
- data/lib/chingu/game_states/debug.rb +22 -0
- data/lib/chingu/game_states/fade_to.rb +22 -0
- data/lib/chingu/game_states/pause.rb +23 -0
- data/lib/chingu/gfx_helpers.rb +22 -0
- data/lib/chingu/helpers.rb +22 -0
- data/lib/chingu/inflector.rb +22 -0
- data/lib/chingu/require_all.rb +133 -0
- data/lib/chingu/traits/collision_detection.rb +98 -5
- data/lib/chingu/traits/effect.rb +89 -56
- data/lib/chingu/traits/effect_module.rb +86 -0
- data/lib/chingu/traits/input.rb +23 -0
- data/lib/chingu/traits/rotation_center.rb +22 -0
- data/lib/chingu/traits/velocity.rb +52 -44
- data/lib/chingu/traits/velocity_module.rb +44 -0
- data/lib/chingu/window.rb +1 -1
- metadata +8 -4
- data/lib/chingu/traits/deprecated_module_visual.rb +0 -108
- data/lib/chingu/traits/deprecated_visual.rb +0 -100
data/lib/chingu/window.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ippa-chingu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ippa
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -35,6 +35,7 @@ extra_rdoc_files:
|
|
35
35
|
- benchmarks/README.txt
|
36
36
|
files:
|
37
37
|
- History.txt
|
38
|
+
- LICENSE
|
38
39
|
- Manifest.txt
|
39
40
|
- README.rdoc
|
40
41
|
- Rakefile
|
@@ -42,10 +43,12 @@ files:
|
|
42
43
|
- benchmarks/benchmark.rb
|
43
44
|
- benchmarks/benchmark3.rb
|
44
45
|
- benchmarks/benchmark4.rb
|
46
|
+
- benchmarks/benchmark5.rb
|
45
47
|
- benchmarks/meta_benchmark.rb
|
46
48
|
- benchmarks/meta_benchmark2.rb
|
47
49
|
- chingu.gemspec
|
48
50
|
- examples/example1.rb
|
51
|
+
- examples/example10.rb
|
49
52
|
- examples/example2.rb
|
50
53
|
- examples/example3.rb
|
51
54
|
- examples/example4.rb
|
@@ -89,14 +92,15 @@ files:
|
|
89
92
|
- lib/chingu/parallax.rb
|
90
93
|
- lib/chingu/particle.rb
|
91
94
|
- lib/chingu/rect.rb
|
95
|
+
- lib/chingu/require_all.rb
|
92
96
|
- lib/chingu/text.rb
|
93
97
|
- lib/chingu/traits/collision_detection.rb
|
94
|
-
- lib/chingu/traits/deprecated_module_visual.rb
|
95
|
-
- lib/chingu/traits/deprecated_visual.rb
|
96
98
|
- lib/chingu/traits/effect.rb
|
99
|
+
- lib/chingu/traits/effect_module.rb
|
97
100
|
- lib/chingu/traits/input.rb
|
98
101
|
- lib/chingu/traits/rotation_center.rb
|
99
102
|
- lib/chingu/traits/velocity.rb
|
103
|
+
- lib/chingu/traits/velocity_module.rb
|
100
104
|
- lib/chingu/window.rb
|
101
105
|
has_rdoc: false
|
102
106
|
homepage: http://github.com/ippa/chingu/tree/master
|
@@ -1,108 +0,0 @@
|
|
1
|
-
module Chingu
|
2
|
-
module Traits
|
3
|
-
module Visual
|
4
|
-
attr_accessor :image, :x, :y, :angle, :center_x, :center_y, :factor_x, :factor_y, :color, :mode, :zorder
|
5
|
-
|
6
|
-
#
|
7
|
-
# :x screen x-coordinate (default 0, to the left)
|
8
|
-
# :y screen y-coordinate (default 0, top of screen)
|
9
|
-
# :angle angle of object, used in draw_rot, (default 0, no rotation)
|
10
|
-
# :zorder a gameclass "foo" with higher zorder then gameclass "bar" is drawn on top of "foo".
|
11
|
-
# :center_x relative horizontal position of the rotation center on the image.
|
12
|
-
# 0 is the left border, 1 is the right border, 0.5 is the center (default 0.5)
|
13
|
-
# :center_y see center_x. (default 0.5)
|
14
|
-
# :factor_x horizontal zoom-factor, use >1.0 to zoom in. (default 1.0, no zoom).
|
15
|
-
# :factor_y vertical zoom-factor, use >1.0 to zoom in. (default 1.0, no zoom).
|
16
|
-
#
|
17
|
-
# :update [true|false] Automaticly call #update on object each gameloop. Default +true+.
|
18
|
-
# :draw [true|false] Automaticly call #update on object each gameloop. Default +true+.
|
19
|
-
#
|
20
|
-
|
21
|
-
def self.included(base)
|
22
|
-
#base.__send__(:alias_method, :orig_initialize, :initialize)
|
23
|
-
#base.__send__(:alias_method, :initialize, :orig_initialize)
|
24
|
-
|
25
|
-
#base.__send__( :alias_method, :initialize_without_extras, :initialize )
|
26
|
-
#base.__send__( :alias_method, :initialize, :initialize_with_extras )
|
27
|
-
end
|
28
|
-
|
29
|
-
alias_method :orig_initialize, :initialize
|
30
|
-
def initialize(options = {})
|
31
|
-
|
32
|
-
puts "Visual#initialize"
|
33
|
-
|
34
|
-
# draw_rot arguments
|
35
|
-
@image = options[:image] if options[:image].is_a? Gosu::Image
|
36
|
-
@image = Image[options[:image]] if options[:image].is_a? String
|
37
|
-
@x = options[:x] || 0
|
38
|
-
@y = options[:y] || 0
|
39
|
-
@angle = options[:angle] || 0
|
40
|
-
@zorder = options[:zorder] || 100
|
41
|
-
@center_x = options[:center_x] || options[:center] || 0.5
|
42
|
-
@center_y = options[:center_y] || options[:center] || 0.5
|
43
|
-
@factor_x = options[:factor_x] || options[:factor] || 1.0
|
44
|
-
@factor_y = options[:factor_y] || options[:factor] || 1.0
|
45
|
-
@mode = options[:mode] || :default # :additive is also available.
|
46
|
-
@color = Gosu::Color.new(options[:color]) if options[:color].is_a? Bignum
|
47
|
-
@color = options[:color] if options[:color].respond_to?(:alpha)
|
48
|
-
@color = Gosu::Color.new(0xFFFFFFFF) if @color.nil?
|
49
|
-
|
50
|
-
# Shortcuts for draw_rot arguments
|
51
|
-
@factor = 1
|
52
|
-
|
53
|
-
# gameloop/framework logic
|
54
|
-
@update = options[:update] || true
|
55
|
-
@draw = options[:draw] || true
|
56
|
-
|
57
|
-
orig_initialize(options)
|
58
|
-
#orig_initialize
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
# Quick way of setting both factor_x and factor_y
|
63
|
-
#
|
64
|
-
def factor=(factor)
|
65
|
-
@factor_x = @factor_y = factor
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
# Quick way of setting both center_x and center_y
|
70
|
-
#
|
71
|
-
def center=(factor)
|
72
|
-
@center_x = @center_y = factor
|
73
|
-
end
|
74
|
-
|
75
|
-
#
|
76
|
-
# Returns true if object is inside the game window, false if outside
|
77
|
-
#
|
78
|
-
def inside_window?(x = @x, y = @y)
|
79
|
-
x >= 0 && x <= $window.width && y >= 0 && y <= $window.height
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# Returns true object is outside the game window
|
84
|
-
#
|
85
|
-
def outside_window?(x = @x, y = @y)
|
86
|
-
not inside_window?(x,y)
|
87
|
-
end
|
88
|
-
|
89
|
-
#
|
90
|
-
# The core of the gameclass, the draw_rot encapsulation. Draws the sprite on screen.
|
91
|
-
# Calling #to_i on @x and @y enables thoose to be Float's, for subpixel slow movement in #update
|
92
|
-
#
|
93
|
-
def draw(parent)
|
94
|
-
@image.draw_rot(@x.to_i, @y.to_i, @zorder, @angle, @center_x, @center_y, @factor_x, @factor_y, @color, @mode)
|
95
|
-
#parent.image.draw_rot( parent.x.to_i,
|
96
|
-
# parent.y.to_i,
|
97
|
-
# parent.zorder,
|
98
|
-
# parent.angle,
|
99
|
-
# parent.center_x,
|
100
|
-
# parent.center_y,
|
101
|
-
# parent.factor_x,
|
102
|
-
# parent.factor_y,
|
103
|
-
# parent.color,
|
104
|
-
# parent.mode)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
module Chingu
|
2
|
-
module Traits
|
3
|
-
class Visual
|
4
|
-
|
5
|
-
def initialize(parent_class, options)
|
6
|
-
@parent_class = parent_class
|
7
|
-
@parent_class.class_eval do
|
8
|
-
attr_accessor :image, :x, :y, :angle, :center_x, :center_y, :factor_x, :factor_y, :color, :mode, :zorder
|
9
|
-
|
10
|
-
# Quick way of setting both factor_x and factor_y
|
11
|
-
def factor=(factor)
|
12
|
-
@factor_x = @factor_y = factor
|
13
|
-
end
|
14
|
-
|
15
|
-
# Quick way of setting both center_x and center_y
|
16
|
-
def center=(factor)
|
17
|
-
@center_x = @center_y = factor
|
18
|
-
end
|
19
|
-
|
20
|
-
# Returns true if object is inside the game window, false if outside
|
21
|
-
def inside_window?(x = @x, y = @y)
|
22
|
-
x >= 0 && x <= $window.width && y >= 0 && y <= $window.height
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns true object is outside the game window
|
26
|
-
def outside_window?(x = @x, y = @y)
|
27
|
-
not inside_window?(x,y)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# :x screen x-coordinate (default 0, to the left)
|
35
|
-
# :y screen y-coordinate (default 0, top of screen)
|
36
|
-
# :angle angle of object, used in draw_rot, (default 0, no rotation)
|
37
|
-
# :zorder a gameclass "foo" with higher zorder then gameclass "bar" is drawn on top of "foo".
|
38
|
-
# :center_x relative horizontal position of the rotation center on the image.
|
39
|
-
# 0 is the left border, 1 is the right border, 0.5 is the center (default 0.5)
|
40
|
-
# :center_y see center_x. (default 0.5)
|
41
|
-
# :factor_x horizontal zoom-factor, use >1.0 to zoom in. (default 1.0, no zoom).
|
42
|
-
# :factor_y vertical zoom-factor, use >1.0 to zoom in. (default 1.0, no zoom).
|
43
|
-
#
|
44
|
-
# :update [true|false] Automaticly call #update on object each gameloop. Default +true+.
|
45
|
-
# :draw [true|false] Automaticly call #update on object each gameloop. Default +true+.
|
46
|
-
#
|
47
|
-
def setup(parent_instance, options)
|
48
|
-
@parent_instance = parent_instance
|
49
|
-
@parent_instance.instance_eval do
|
50
|
-
# draw_rot arguments
|
51
|
-
@image = options[:image] if options[:image].is_a? Gosu::Image
|
52
|
-
@image = Image[options[:image]] if options[:image].is_a? String
|
53
|
-
@x = options[:x] || 0
|
54
|
-
@y = options[:y] || 0
|
55
|
-
@angle = options[:angle] || 0
|
56
|
-
@zorder = options[:zorder] || 100
|
57
|
-
@center_x = options[:center_x] || options[:center] || 0.5
|
58
|
-
@center_y = options[:center_y] || options[:center] || 0.5
|
59
|
-
@factor_x = options[:factor_x] || options[:factor] || 1.0
|
60
|
-
@factor_y = options[:factor_y] || options[:factor] || 1.0
|
61
|
-
|
62
|
-
@color = Gosu::Color.new(options[:color]) if options[:color].is_a? Bignum
|
63
|
-
@color = options[:color] if options[:color].respond_to?(:alpha)
|
64
|
-
@color = Gosu::Color.new(0xFFFFFFFF) if @color.nil?
|
65
|
-
|
66
|
-
@mode = options[:mode] || :default # :additive is also available.
|
67
|
-
|
68
|
-
# Shortcuts for draw_rot arguments
|
69
|
-
@factor = 1
|
70
|
-
|
71
|
-
# gameloop/framework logic
|
72
|
-
@update = options[:update] || true
|
73
|
-
@draw = options[:draw] || true
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
def update(parent)
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
# The core of the gameclass, the draw_rot encapsulation. Draws the sprite on screen.
|
83
|
-
# Calling #to_i on @x and @y enables thoose to be Float's, for subpixel slow movement in #update
|
84
|
-
#
|
85
|
-
def draw(parent)
|
86
|
-
## @image.draw_rot(@x.to_i, @y.to_i, @zorder, @angle, @center_x, @center_y, @factor_x, @factor_y, @color, @mode)
|
87
|
-
parent.image.draw_rot( parent.x.to_i,
|
88
|
-
parent.y.to_i,
|
89
|
-
parent.zorder,
|
90
|
-
parent.angle,
|
91
|
-
parent.center_x,
|
92
|
-
parent.center_y,
|
93
|
-
parent.factor_x,
|
94
|
-
parent.factor_y,
|
95
|
-
parent.color,
|
96
|
-
parent.mode)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|