gemini 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/gemini +20 -12
- data/package/jar/gemini.jar +0 -0
- data/src/base_state.rb +6 -12
- data/src/behaviors/animated_sprite.rb +6 -2
- data/src/behaviors/audible.rb +6 -1
- data/src/behaviors/axis_stateful.rb +2 -0
- data/src/behaviors/big_sprite.rb +2 -1
- data/src/behaviors/bounding_box_collidable.rb +2 -0
- data/src/behaviors/camera_anchored_drawable.rb +1 -1
- data/src/behaviors/cardinal_movable.rb +18 -11
- data/src/behaviors/clickable.rb +1 -0
- data/src/behaviors/countable.rb +1 -0
- data/src/behaviors/debug_physical.rb +25 -13
- data/src/behaviors/debug_tangible.rb +1 -0
- data/src/behaviors/drawable.rb +1 -0
- data/src/behaviors/drawable_shape.rb +4 -3
- data/src/behaviors/fading_image_trail_emittable.rb +4 -0
- data/src/behaviors/game_object_emittable.rb +1 -0
- data/src/behaviors/gravity_source.rb +3 -2
- data/src/behaviors/inertial.rb +3 -0
- data/src/behaviors/movable2d.rb +1 -0
- data/src/behaviors/multi_animated_sprite.rb +7 -1
- data/src/behaviors/physical.rb +123 -77
- data/src/behaviors/physical_cardinal_movable.rb +14 -13
- data/src/behaviors/physical_sprite.rb +25 -9
- data/src/behaviors/platformer_controllable.rb +9 -2
- data/src/behaviors/pointer.rb +2 -0
- data/src/behaviors/pressable.rb +4 -0
- data/src/behaviors/receives_events.rb +3 -0
- data/src/behaviors/regional.rb +5 -0
- data/src/behaviors/repulsive.rb +28 -0
- data/src/behaviors/rotates_to_point.rb +2 -1
- data/src/behaviors/spatial.rb +4 -4
- data/src/behaviors/sprite.rb +17 -6
- data/src/behaviors/stateful.rb +2 -0
- data/src/behaviors/taggable.rb +1 -0
- data/src/behaviors/tangible.rb +8 -0
- data/src/behaviors/timeable.rb +9 -0
- data/src/behaviors/top_down_vehicle.rb +1 -0
- data/src/behaviors/triangle_trail_emittable.rb +5 -0
- data/src/behaviors/updates.rb +1 -0
- data/src/behaviors/updates_at_consistant_rate.rb +1 -0
- data/src/behaviors/vectored_movement.rb +1 -0
- data/src/behaviors/world_collidable.rb +1 -0
- data/src/game_objects/static_sprite.rb +3 -2
- data/src/game_objects/triangle_trail.rb +1 -1
- data/src/gemini_version.rb +1 -1
- data/src/managers/input_support/input_mapping.rb +10 -10
- data/src/managers/scrolling_render_manager.rb +8 -6
- data/src/project_generator.rb +6 -0
- data/src/vector.rb +19 -7
- metadata +4 -3
data/src/behaviors/timeable.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#Makes an object receive an event when a given time period has elapsed.
|
1
2
|
class Timeable < Gemini::Behavior
|
2
3
|
depends_on :Updates
|
3
4
|
|
@@ -9,10 +10,14 @@ class Timeable < Gemini::Behavior
|
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
13
|
+
#Add a countdown delay of the given number of seconds to the object.
|
14
|
+
#When the specified time has elapsed, a :countdown_complete event with the specified name will be passed to the object.
|
15
|
+
#If notify_frequency is specified, a :timer_tick event with the Timer object will be passed to the object each time the specified interval elapses.
|
12
16
|
def add_countdown(name, seconds, notify_frequency = nil)
|
13
17
|
@timers[name] = Timer.new(name, Timer::COUNTDOWN, seconds, notify_frequency) {|timer| @target.notify :timer_tick, timer }
|
14
18
|
end
|
15
19
|
|
20
|
+
#Add a countup delay to the object. See add_countdown.
|
16
21
|
def add_countup(name, seconds, notify_frequency = nil)
|
17
22
|
@timers[name] = Timer.new(name, Timer::COUNTUP, seconds, notify_frequency) {|timer| @target.notify :timer_tick, timer }
|
18
23
|
end
|
@@ -30,6 +35,7 @@ private
|
|
30
35
|
end
|
31
36
|
end
|
32
37
|
|
38
|
+
#Used to track how much time has elapsed.
|
33
39
|
class Timer
|
34
40
|
COUNTDOWN = :countdown
|
35
41
|
COUNTUP = :countup
|
@@ -43,6 +49,7 @@ class Timer
|
|
43
49
|
@milliseconds_since_last_notify = 0
|
44
50
|
end
|
45
51
|
|
52
|
+
#Use the given elapsed time to determine if callbacks should be triggered.
|
46
53
|
def apply_delta(delta_in_milliseconds)
|
47
54
|
return if @countdown_complete
|
48
55
|
|
@@ -61,10 +68,12 @@ class Timer
|
|
61
68
|
@countdown_complete = false
|
62
69
|
end
|
63
70
|
|
71
|
+
#Number of timer ticks (notification periods) that have passed.
|
64
72
|
def ticks_elapsed
|
65
73
|
(@current_milliseconds / (@notify_frequency)).round
|
66
74
|
end
|
67
75
|
|
76
|
+
#Number of timer ticks (notification periods) left before the countdown/countup is complete.
|
68
77
|
def ticks_left
|
69
78
|
((@milliseconds - @current_milliseconds) / (@notify_frequency)).round
|
70
79
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'behaviors/drawable'
|
2
2
|
|
3
|
+
#Makes an object draw a shrinking trail behind itself as it moves.
|
3
4
|
class TriangleTrailEmittable < Gemini::Behavior
|
4
5
|
#depends_on :Movable2d
|
5
6
|
depends_on :Updates
|
@@ -19,6 +20,7 @@ class TriangleTrailEmittable < Gemini::Behavior
|
|
19
20
|
@target.game_state.remove @emitter
|
20
21
|
end
|
21
22
|
|
23
|
+
#Transparency to use. 1.0 is opaque. Default is 0.5.
|
22
24
|
def alpha
|
23
25
|
@emitter.alpha
|
24
26
|
end
|
@@ -27,14 +29,17 @@ class TriangleTrailEmittable < Gemini::Behavior
|
|
27
29
|
@emitter.alpha = alpha
|
28
30
|
end
|
29
31
|
|
32
|
+
#Takes an Array with the relative x and y coordinates to begin the trail.
|
30
33
|
def emit_triangle_trail_from_offset(offset)
|
31
34
|
@emitter_offset = offset
|
32
35
|
end
|
33
36
|
|
37
|
+
#Specifies the half-width of the widest part of the trail.
|
34
38
|
def emit_triangle_trail_with_radius(radius)
|
35
39
|
@emitter.radius = radius
|
36
40
|
end
|
37
41
|
|
42
|
+
#Name of layer to draw trail on.
|
38
43
|
def layer=(layer_name)
|
39
44
|
@target.game_state.manager(:game_object).move_game_object_to_layer(@emitter, layer_name)
|
40
45
|
end
|
data/src/behaviors/updates.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
class StaticSprite < Gemini::GameObject
|
2
|
-
has_behavior :
|
2
|
+
has_behavior :PhysicalSprite
|
3
|
+
|
3
4
|
def load(sprite_name_or_image, x=nil, y=nil, width=nil, height=nil, *tags)
|
4
5
|
set_image sprite_name_or_image
|
5
6
|
if width.nil? || height.nil?
|
@@ -7,7 +8,7 @@ class StaticSprite < Gemini::GameObject
|
|
7
8
|
else
|
8
9
|
set_shape :Box, width, height
|
9
10
|
end
|
10
|
-
set_mass
|
11
|
+
set_mass :infinite
|
11
12
|
set_static_body
|
12
13
|
set_restitution 1.0
|
13
14
|
set_friction 0.0
|
data/src/gemini_version.rb
CHANGED
@@ -32,17 +32,17 @@ module Gemini
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def poll(raw_input)
|
35
|
-
@
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
@poll_result = case @device
|
36
|
+
when :key
|
37
|
+
poll_key(raw_input)
|
38
|
+
when :mouse
|
39
|
+
when :joystick
|
40
|
+
poll_joystick(raw_input)
|
41
|
+
end
|
42
42
|
if post_canceled?
|
43
43
|
nil
|
44
44
|
else
|
45
|
-
to_game_message(raw_input)
|
45
|
+
to_game_message(raw_input, @poll_result)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -116,8 +116,8 @@ module Gemini
|
|
116
116
|
end
|
117
117
|
|
118
118
|
# eventually, raw_input will need to be wrapped
|
119
|
-
def to_game_message(raw_input)
|
120
|
-
game_message = InputMessage.new(@game_message,
|
119
|
+
def to_game_message(raw_input, game_value)
|
120
|
+
game_message = InputMessage.new(@game_message, game_value)
|
121
121
|
game_message.player = @player
|
122
122
|
@input_callback.call(game_message, raw_input) unless @input_callback.nil?
|
123
123
|
game_message
|
@@ -34,11 +34,13 @@ class ScrollingRenderManager < BasicRenderManager
|
|
34
34
|
|
35
35
|
def calculate_object_position
|
36
36
|
#TODO: This should go once declared method overriding is possible.
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
Vector.new(-(body_position.x - (@game_state.screen_width / 2)), -(body_position.y - (@game_state.screen_height / 2)))
|
42
|
-
|
37
|
+
position = @tracking_game_object.position
|
38
|
+
Vector.new(-(position.x - (@game_state.screen_width / 2)), -(position.y - (@game_state.screen_height / 2)))
|
39
|
+
# if @tracking_game_object.kind_of? TangibleSprite
|
40
|
+
# body_position = @tracking_game_object.body_position
|
41
|
+
# Vector.new(-(body_position.x - (@game_state.screen_width / 2)), -(body_position.y - (@game_state.screen_height / 2)))
|
42
|
+
# else
|
43
|
+
# Vector.new(-(body_position.x - (@game_state.screen_width / 2)), -(body_position.y - (@game_state.screen_height / 2)))
|
44
|
+
# end
|
43
45
|
end
|
44
46
|
end
|
data/src/project_generator.rb
CHANGED
@@ -31,6 +31,9 @@ require 'java'
|
|
31
31
|
|
32
32
|
$LOAD_PATH.clear
|
33
33
|
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
|
34
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), 'game_objects'))
|
35
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), 'managers'))
|
36
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), 'states'))
|
34
37
|
|
35
38
|
# only when running in non-standalone
|
36
39
|
if File.exist? File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'java'))
|
@@ -39,6 +42,9 @@ if File.exist? File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', '
|
|
39
42
|
$CLASSPATH << jar
|
40
43
|
end
|
41
44
|
end
|
45
|
+
%w{behaviors game_objects input_helpers input_mappings states}.each do |dir|
|
46
|
+
$LOAD_PATH << "src/\#{dir}"
|
47
|
+
end
|
42
48
|
|
43
49
|
require 'gemini'
|
44
50
|
|
data/src/vector.rb
CHANGED
@@ -1,22 +1,26 @@
|
|
1
1
|
class Vector
|
2
|
+
SlickVector = Java::org::newdawn::slick::geom::Vector2f
|
3
|
+
|
2
4
|
attr_reader :native_vector
|
3
5
|
|
4
|
-
def dup
|
5
|
-
self.new(x, y)
|
6
|
-
end
|
7
|
-
|
8
6
|
def self.from_polar_vector(magnitude, angle)
|
9
7
|
w = Math.sin(Gemini::Math.degrees_to_radians(angle))
|
10
8
|
h = -Math.cos(Gemini::Math.degrees_to_radians(angle))
|
11
9
|
return new(w * magnitude, h * magnitude)
|
12
10
|
end
|
13
|
-
|
11
|
+
|
14
12
|
def initialize(x = 0.0, y = 0.0, z = nil)
|
15
|
-
@native_vector =
|
13
|
+
@native_vector = SlickVector.new(x, y)
|
14
|
+
end
|
15
|
+
|
16
|
+
ORIGIN = new(0.0, 0.0).freeze
|
17
|
+
|
18
|
+
def dup
|
19
|
+
self.class.new(x, y)
|
16
20
|
end
|
17
21
|
|
18
22
|
def +(other_vector)
|
19
|
-
|
23
|
+
self.class.new(x + other_vector.x, y + other_vector.y)
|
20
24
|
end
|
21
25
|
|
22
26
|
def x
|
@@ -57,6 +61,10 @@ class Vector
|
|
57
61
|
Gemini::Math.radians_to_degrees(Math.atan2(y - other_vector.y, x - other_vector.x)) + 90.0
|
58
62
|
end
|
59
63
|
|
64
|
+
def midpoint_of(other_vector)
|
65
|
+
Vector.new((x + other_vector.x) / 2.0, (y + other_vector.y) / 2.0)
|
66
|
+
end
|
67
|
+
|
60
68
|
def pivot_around_degrees(other_vector, rotation)
|
61
69
|
pivot_around(other_vector, Gemini::Math.degrees_to_radians(rotation))
|
62
70
|
end
|
@@ -82,6 +90,10 @@ class Vector
|
|
82
90
|
def negate
|
83
91
|
self.class.new(-x, -y)
|
84
92
|
end
|
93
|
+
|
94
|
+
def to_s
|
95
|
+
"<#{self.class} - X: #{x} Y: #{y}>"
|
96
|
+
end
|
85
97
|
end
|
86
98
|
|
87
99
|
class Java::net::phys2d::math::Vector2f
|
metadata
CHANGED
@@ -5,9 +5,9 @@ homepage: http://rubyforge.org/projects/gemini/
|
|
5
5
|
executables:
|
6
6
|
- gemini
|
7
7
|
version: !ruby/object:Gem::Version
|
8
|
-
version: 1.0.
|
8
|
+
version: 1.0.1
|
9
9
|
post_install_message:
|
10
|
-
date: 2009-
|
10
|
+
date: 2009-07-04 07:00:00 +00:00
|
11
11
|
files:
|
12
12
|
- lib/ibxm.jar
|
13
13
|
- lib/jinput.jar
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- src/behaviors/pressable.rb
|
79
79
|
- src/behaviors/receives_events.rb
|
80
80
|
- src/behaviors/regional.rb
|
81
|
+
- src/behaviors/repulsive.rb
|
81
82
|
- src/behaviors/rotates_to_point.rb
|
82
83
|
- src/behaviors/spatial.rb
|
83
84
|
- src/behaviors/spline_stretchable_sprite.rb
|
@@ -166,7 +167,7 @@ dependencies:
|
|
166
167
|
requirements:
|
167
168
|
- - '>='
|
168
169
|
- !ruby/object:Gem::Version
|
169
|
-
version:
|
170
|
+
version: 1.3.7
|
170
171
|
description: ""
|
171
172
|
email: logustus@gmail.com
|
172
173
|
authors:
|