gosu_extensions 0.1.0 → 0.1.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -36,11 +36,11 @@ require 'shot'
36
36
  require 'targetable'
37
37
  require 'turnable'
38
38
  require 'controllable'
39
+ require 'moveable'
40
+ require 'short_lived'
39
41
 
40
42
  $:.unshift File.join(File.dirname(__FILE__), '/units')
41
43
  require 'thing'
42
- require 'moveable'
43
- require 'short_lived'
44
44
 
45
45
  require 'controls'
46
46
  require 'game_window'
@@ -1,7 +1,8 @@
1
1
  # Use this for a thing that damages.
2
2
  #
3
3
  # Example:
4
- # class Rocket < ShortLived
4
+ # class Rocket
5
+ # it_is ShortLived
5
6
  # it_is Damaging
6
7
  # end
7
8
  #
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # TODO moveable should only have active components, like accelerate etc. Positioning etc. should go to Thing.
4
4
  #
5
- class Moveable < Thing
5
+ module Moveable
6
6
 
7
7
  Accelerate = :accelerate
8
8
  Left = :move_left
@@ -12,7 +12,11 @@ class Moveable < Thing
12
12
  Backwards = :backwards
13
13
  # Jump = :jump
14
14
 
15
- class << self
15
+ def self.included klass
16
+ klass.extend ClassMethods
17
+ end
18
+
19
+ module ClassMethods
16
20
 
17
21
  # Initial setting.
18
22
  #
@@ -76,9 +80,7 @@ class Moveable < Thing
76
80
  @shape.body.v
77
81
  end
78
82
  def current_speed
79
- # TODO use built-in function
80
- #
81
- Math.sqrt(speed.x**2 + speed.y**2)
83
+ speed.length
82
84
  end
83
85
 
84
86
  # Directly set the rotation of our Moveable.
@@ -1,4 +1,8 @@
1
- class ShortLived < Moveable
1
+ module ShortLived
2
+
3
+ def self.included klass
4
+ klass.extend ClassMethods
5
+ end
2
6
 
3
7
  def initialize window
4
8
  super window
@@ -8,7 +12,7 @@ class ShortLived < Moveable
8
12
  end
9
13
  end
10
14
 
11
- class << self
15
+ module ClassMethods
12
16
 
13
17
  def lifetime lifetime = nil, &block
14
18
  block = lambda { lifetime } unless block_given?
data/lib/units/thing.rb CHANGED
@@ -4,6 +4,10 @@ class Thing
4
4
  include InitializerHooks
5
5
  include ItIsA
6
6
 
7
+ # TODO Move this.
8
+ #
9
+ it_is Moveable
10
+
7
11
  attr_writer :layer
8
12
  attr_reader :window, :shape
9
13
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -75,8 +75,8 @@ files:
75
75
  - lib/traits/targeting.rb
76
76
  - lib/traits/targeting/closest.rb
77
77
  - lib/traits/turnable.rb
78
- - lib/units/moveable.rb
79
- - lib/units/short_lived.rb
78
+ - lib/traits/moveable.rb
79
+ - lib/traits/short_lived.rb
80
80
  - lib/units/thing.rb
81
81
  - lib/vector_utilities.rb
82
82
  - lib/waves.rb