chingu 0.5.9.4 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +25 -21
- data/Manifest.txt +3 -0
- data/README.rdoc +27 -3
- data/chingu.gemspec +3 -3
- data/examples/example11.rb +15 -14
- data/examples/example13.rb +1 -1
- data/examples/example14.rb +124 -0
- data/examples/example2.rb +10 -6
- data/examples/example9.rb +4 -14
- data/examples/game1.rb +87 -76
- data/examples/high_score_list.yml +2 -2
- data/lib/chingu.rb +4 -1
- data/lib/chingu/basic_game_object.rb +34 -23
- data/lib/chingu/game_state.rb +24 -8
- data/lib/chingu/helpers/gfx.rb +13 -1
- data/lib/chingu/helpers/input_client.rb +39 -2
- data/lib/chingu/helpers/rotation_center.rb +7 -1
- data/lib/chingu/input.rb +14 -9
- data/lib/chingu/traits/bounding_box.rb +63 -0
- data/lib/chingu/traits/collision_detection.rb +8 -39
- data/lib/chingu/traits/effect.rb +3 -8
- data/lib/chingu/traits/radius.rb +55 -0
- data/lib/chingu/traits/retrofy.rb +9 -11
- data/lib/chingu/traits/timer.rb +3 -4
- data/lib/chingu/traits/velocity.rb +3 -12
- metadata +5 -2
- metadata.gz.sig +0 -0
data/lib/chingu/traits/effect.rb
CHANGED
@@ -42,14 +42,11 @@ module Chingu
|
|
42
42
|
|
43
43
|
module Effect
|
44
44
|
attr_accessor :rotation_rate, :fade_rate, :scale_rate
|
45
|
-
|
45
|
+
|
46
46
|
#
|
47
47
|
# Setup
|
48
48
|
#
|
49
|
-
def setup_trait(options)
|
50
|
-
@effect_options = {:debug => false}.merge(options)
|
51
|
-
puts "Effect#setup" if @effect_options[:debug]
|
52
|
-
|
49
|
+
def setup_trait(options)
|
53
50
|
@rotation_rate = options[:rotation_rate] || nil
|
54
51
|
@scale_rate = options[:scale_rate] || nil
|
55
52
|
@fade_rate = options[:fade_rate] || nil
|
@@ -60,9 +57,7 @@ module Chingu
|
|
60
57
|
super
|
61
58
|
end
|
62
59
|
|
63
|
-
def update_trait
|
64
|
-
puts "Effect#update" if @effect_options[:debug]
|
65
|
-
|
60
|
+
def update_trait
|
66
61
|
rotate(@rotation_rate) if @rotation_rate
|
67
62
|
fade(@fade_rate) if @fade_rate
|
68
63
|
scale(@scale_rate) if @scale_rate
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Chingu -- OpenGL accelerated 2D game framework for Ruby
|
4
|
+
# Copyright (C) 2009 ippa / ippa@rubylicio.us
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
#
|
20
|
+
#++
|
21
|
+
|
22
|
+
module Chingu
|
23
|
+
module Traits
|
24
|
+
#
|
25
|
+
# Providing a bounding_box and keeps it up to date by reading:
|
26
|
+
# image, factor_x, factor_y
|
27
|
+
#
|
28
|
+
# ...only makes sense with rotation_center = :center
|
29
|
+
#
|
30
|
+
module Radius
|
31
|
+
|
32
|
+
module ClassMethods
|
33
|
+
def initialize_trait(options = {})
|
34
|
+
@trait_options[:radius] = options
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def radius
|
39
|
+
width = self.image.width * self.factor_x.abs
|
40
|
+
height = self.image.height * self.factor_y.abs
|
41
|
+
radius = (width + height) / 2
|
42
|
+
radius = radius * trait_options[:radius][:scale] if trait_options[:radius][:scale]
|
43
|
+
return radius
|
44
|
+
end
|
45
|
+
|
46
|
+
def draw_trait
|
47
|
+
if trait_options[:radius][:debug]
|
48
|
+
$window.draw_circle(self.x, self.y, self.radius, Chingu::DEBUG_COLOR)
|
49
|
+
end
|
50
|
+
super
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -23,38 +23,37 @@ module Chingu
|
|
23
23
|
module Traits
|
24
24
|
#
|
25
25
|
# A chingu trait providing easier handling of the "retrofy" effect (non-blurry zoom)
|
26
|
-
# Aims to help out when using
|
27
|
-
# Provides screen_x and screen_y which takes the
|
26
|
+
# Aims to help out when using scaling with "factor" to create a retrofeeling with big pixels.
|
27
|
+
# Provides screen_x and screen_y which takes the scaling into account
|
28
28
|
# Also provides new code for draw() which uses screen_x / screen_y instead of x / y
|
29
29
|
#
|
30
30
|
module Retrofy
|
31
|
-
|
31
|
+
|
32
32
|
def setup_trait(options)
|
33
33
|
@retrofy_options = {:debug => false}.merge(options)
|
34
|
-
|
35
34
|
super
|
36
35
|
end
|
37
36
|
|
38
37
|
def screen_width
|
39
|
-
(
|
38
|
+
(self.image.width * self.factor).to_i
|
40
39
|
end
|
41
40
|
|
42
41
|
def screen_height
|
43
|
-
(
|
42
|
+
(self.image.heigt * self.factor).to_i
|
44
43
|
end
|
45
44
|
|
46
45
|
def screen_x
|
47
|
-
(
|
46
|
+
(self.x * self.factor).to_i
|
48
47
|
end
|
49
48
|
|
50
49
|
def screen_y
|
51
|
-
(
|
50
|
+
(self.y * self.factor).to_i
|
52
51
|
end
|
53
|
-
|
52
|
+
|
54
53
|
# Returns true if object is inside the game window, false if outside
|
55
54
|
# this special version takes @factor into consideration
|
56
55
|
def inside_window?
|
57
|
-
|
56
|
+
self.x >= 0 && self.x <= $window.width/self.factor && self.y >= 0 && self.y <= $window.height/self.factor
|
58
57
|
end
|
59
58
|
|
60
59
|
# Returns true object is outside the game window
|
@@ -66,7 +65,6 @@ module Chingu
|
|
66
65
|
def draw
|
67
66
|
@image.draw_rot(self.screen_x, self.screen_y, @zorder, @angle, @center_x, @center_y, @factor_x, @factor_y, @color, @mode)
|
68
67
|
end
|
69
|
-
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
data/lib/chingu/traits/timer.rb
CHANGED
@@ -31,10 +31,9 @@ module Chingu
|
|
31
31
|
# All the above can be combined with a 'then { do_something }'. For example, a classic shmup damage effect:
|
32
32
|
# during(100) { @color.alpha = 100 }.then { @color.alpha = 255 }
|
33
33
|
#
|
34
|
-
module Timer
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
module Timer
|
35
|
+
|
36
|
+
def setup_trait(options)
|
38
37
|
#
|
39
38
|
# Timers are saved as an array of arrays where each entry contains:
|
40
39
|
# [start_time, end_time (or nil if one-shot), &block]
|
@@ -27,15 +27,8 @@ module Chingu
|
|
27
27
|
module Velocity
|
28
28
|
attr_accessor :velocity_x, :velocity_y, :acceleration_x, :acceleration_y, :max_velocity
|
29
29
|
|
30
|
-
#def self.initialize_trait(options)
|
31
|
-
# @velocity_options = {:debug => false}.merge(options)
|
32
|
-
# puts "Velocity#initialize" if @velocity_options[:debug]
|
33
|
-
# super
|
34
|
-
#end
|
35
|
-
|
36
30
|
def setup_trait(options)
|
37
31
|
@velocity_options = {:debug => false}.merge(options)
|
38
|
-
puts "Velocity#setup" if @velocity_options[:debug]
|
39
32
|
|
40
33
|
@velocity_x = options[:velocity_x] || 0
|
41
34
|
@velocity_y = options[:velocity_y] || 0
|
@@ -48,13 +41,11 @@ module Chingu
|
|
48
41
|
#
|
49
42
|
# Modifies X & Y of parent
|
50
43
|
#
|
51
|
-
def update_trait
|
52
|
-
puts "Velocity#update" if @velocity_options[:debug]
|
53
|
-
|
44
|
+
def update_trait
|
54
45
|
@velocity_y += @acceleration_y if (@velocity_y + @acceleration_y).abs < @max_velocity
|
55
46
|
@velocity_x += @acceleration_x if (@velocity_x + @acceleration_x).abs < @max_velocity
|
56
|
-
|
57
|
-
|
47
|
+
self.y += @velocity_y
|
48
|
+
self.x += @velocity_x
|
58
49
|
super
|
59
50
|
end
|
60
51
|
|
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.
|
4
|
+
version: "0.6"
|
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-21 00:00:00 +01:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- examples/example11.rb
|
78
78
|
- examples/example12.rb
|
79
79
|
- examples/example13.rb
|
80
|
+
- examples/example14.rb
|
80
81
|
- examples/example2.rb
|
81
82
|
- examples/example3.rb
|
82
83
|
- examples/example4.rb
|
@@ -143,8 +144,10 @@ files:
|
|
143
144
|
- lib/chingu/rect.rb
|
144
145
|
- lib/chingu/require_all.rb
|
145
146
|
- lib/chingu/text.rb
|
147
|
+
- lib/chingu/traits/bounding_box.rb
|
146
148
|
- lib/chingu/traits/collision_detection.rb
|
147
149
|
- lib/chingu/traits/effect.rb
|
150
|
+
- lib/chingu/traits/radius.rb
|
148
151
|
- lib/chingu/traits/retrofy.rb
|
149
152
|
- lib/chingu/traits/timer.rb
|
150
153
|
- lib/chingu/traits/velocity.rb
|
metadata.gz.sig
CHANGED
Binary file
|