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 CHANGED
@@ -1 +1 @@
1
- 0.1.26
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, command|
24
- @controllable.send(command) if @window.button_down? key
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
 
@@ -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
 
@@ -6,7 +6,7 @@ module Attachable extend Trait
6
6
 
7
7
  def move_relative pod
8
8
  self.position = pod.relative_position self
9
- self.rotation = pod.rotation
9
+ self.rotation = pod.rotation unless self.kind_of? Turnable
10
10
  end
11
11
 
12
12
  end
@@ -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 backwards strength = 1
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
@@ -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
@@ -2,6 +2,7 @@
2
2
  #
3
3
  module Turnable extend Trait
4
4
 
5
+
5
6
  Left = :turn_left
6
7
  Right = :turn_right
7
8
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 26
9
- version: 0.1.26
8
+ - 27
9
+ version: 0.1.27
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke