gosu_extensions 0.1.26 → 0.1.27
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/core/control.rb +2 -2
- data/lib/gosu_extensions.rb +2 -2
- data/lib/traits/attachable.rb +1 -1
- data/lib/traits/moveable.rb +15 -15
- data/lib/traits/shooter.rb +1 -0
- data/lib/traits/turnable.rb +1 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.27
|
data/lib/core/control.rb
CHANGED
@@ -20,8 +20,8 @@ class Control
|
|
20
20
|
#
|
21
21
|
def handle
|
22
22
|
return if @controllable.destroyed?
|
23
|
-
@mapping.each do |key,
|
24
|
-
@controllable.send(
|
23
|
+
@mapping.each do |key, send_params|
|
24
|
+
@controllable.send(*send_params) if @window.button_down? key
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/gosu_extensions.rb
CHANGED
@@ -14,13 +14,13 @@ rescue LoadError => e
|
|
14
14
|
raise e
|
15
15
|
end
|
16
16
|
|
17
|
-
require 'resources'
|
18
|
-
|
19
17
|
$:.unshift File.join(File.dirname(__FILE__), '/extensions')
|
20
18
|
require 'module'
|
21
19
|
require 'numeric'
|
22
20
|
|
23
21
|
$:.unshift File.join(File.dirname(__FILE__), '/core')
|
22
|
+
require 'resources'
|
23
|
+
|
24
24
|
require 'vector_utilities'
|
25
25
|
require 'initializer_hooks'
|
26
26
|
|
data/lib/traits/attachable.rb
CHANGED
data/lib/traits/moveable.rb
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
#
|
5
5
|
module Moveable extend Trait
|
6
6
|
|
7
|
-
Accelerate = :accelerate
|
8
|
-
Left = :move_left
|
9
|
-
Right = :move_right
|
10
|
-
Up = :move_up
|
11
|
-
Down = :move_down
|
12
|
-
Backwards = :backwards
|
13
|
-
# Jump = :jump
|
7
|
+
def self::Accelerate strength = 1.0; [:accelerate, strength] end
|
8
|
+
def self::Left strength = 1.0; [:move_left, strength] end
|
9
|
+
def self::Right strength = 1.0; [:move_right, strength] end
|
10
|
+
def self::Up strength = 1.0; [:move_up, strength] end
|
11
|
+
def self::Down strength = 1.0; [:move_down, strength] end
|
12
|
+
def self::Backwards strength = 1.0; [:backwards, strength] end
|
13
|
+
# TODO Jump = :jump
|
14
14
|
|
15
15
|
def self.included klass
|
16
16
|
klass.extend ClassMethods
|
@@ -128,24 +128,24 @@ module Moveable extend Trait
|
|
128
128
|
|
129
129
|
# Methods for controls.
|
130
130
|
#
|
131
|
-
def accelerate strength = 1
|
131
|
+
def accelerate strength = 1.0
|
132
132
|
self.speed += self.rotation_vector * strength/SUBSTEPS
|
133
133
|
end
|
134
|
-
def
|
135
|
-
accelerate -0.5*strength
|
136
|
-
end
|
137
|
-
def move_left strength = 1
|
134
|
+
def move_left strength = 1.0
|
138
135
|
self.speed += CP::Vec2.new(-strength.to_f/SUBSTEPS, 0)
|
139
136
|
end
|
140
|
-
def move_right strength = 1
|
137
|
+
def move_right strength = 1.0
|
141
138
|
self.speed += CP::Vec2.new(strength.to_f/SUBSTEPS, 0)
|
142
139
|
end
|
143
|
-
def move_up strength = 1
|
140
|
+
def move_up strength = 1.0
|
144
141
|
self.speed += CP::Vec2.new(0, -strength.to_f/SUBSTEPS)
|
145
142
|
end
|
146
|
-
def move_down strength = 1
|
143
|
+
def move_down strength = 1.0
|
147
144
|
self.speed += CP::Vec2.new(0, strength.to_f/SUBSTEPS)
|
148
145
|
end
|
146
|
+
def backwards strength = 1.0
|
147
|
+
accelerate -0.5*strength
|
148
|
+
end
|
149
149
|
# def jump strength = 100
|
150
150
|
# self.speed += CP::Vec2.new(0, -strength.to_f/SUBSTEPS) if self.current_speed <= 1
|
151
151
|
# end
|
data/lib/traits/shooter.rb
CHANGED
@@ -97,6 +97,7 @@ module Shooter extend Trait
|
|
97
97
|
sometimes :loading, self.shooting_rate do
|
98
98
|
projectile = self.shot.shoot_from self
|
99
99
|
projectile.rotation = self.muzzle_rotation
|
100
|
+
# projectile.velocity = self.muzzle_rotation.normalize
|
100
101
|
projectile.speed = self.muzzle_velocity * projectile.velocity + self.speed
|
101
102
|
end
|
102
103
|
end
|
data/lib/traits/turnable.rb
CHANGED