gosu_extensions 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -58,6 +58,7 @@ require 'imageable'
58
58
  require 'short_lived'
59
59
 
60
60
  $:.unshift File.join(File.dirname(__FILE__), '/units')
61
+ require 'sprite'
61
62
  require 'thing'
62
63
 
63
64
  DEFAULT_SCREEN_WIDTH = 1200 unless defined?(DEFAULT_SCREEN_WIDTH)
@@ -1,5 +1,10 @@
1
1
  module Generator extend Trait
2
2
 
3
+ def self.start klass, *args
4
+ [:start_generating, klass, *args]
5
+ end
6
+ Start = :start_generating
7
+
3
8
  def self.included base
4
9
  base.extend ClassMethods
5
10
  end
@@ -34,9 +39,8 @@ end
34
39
 
35
40
  module InstanceMethods
36
41
 
37
- def destroy!
42
+ def destroyed!
38
43
  stop_generating!
39
- super
40
44
  end
41
45
 
42
46
  def stop_generating!
data/lib/traits/lives.rb CHANGED
@@ -19,6 +19,7 @@ module Lives extend Trait
19
19
 
20
20
  def self.included target_class
21
21
  target_class.extend IncludeMethods
22
+ target_class.send :include, InstanceMethods
22
23
  end
23
24
 
24
25
  module IncludeMethods
@@ -26,19 +27,21 @@ module Lives extend Trait
26
27
  # Define the amount of lives in the class.
27
28
  #
28
29
  def lives amount
29
- include InstanceMethods
30
- class_inheritable_accessor :prototype_lives
31
- self.prototype_lives = amount
32
-
33
- hook = lambda { self.lives = self.class.prototype_lives }
34
- InitializerHooks.register self, &hook
30
+ InitializerHooks.register self do
31
+ self.lives = amount
32
+ end
33
+ attr_reader :lives # override the default
35
34
  end
36
35
 
37
36
  end
38
37
 
39
38
  module InstanceMethods
40
39
 
41
- attr_accessor :lives
40
+ attr_writer :lives
41
+
42
+ def lives
43
+ 3
44
+ end
42
45
 
43
46
  # Does three things:
44
47
  # * Deduct 1 live.
@@ -0,0 +1,5 @@
1
+ class Sprite
2
+
3
+ include VectorUtilities
4
+
5
+ end
data/lib/units/thing.rb CHANGED
@@ -1,6 +1,5 @@
1
- class Thing
1
+ class Thing < Sprite
2
2
 
3
- include VectorUtilities
4
3
  include InitializerHooks
5
4
  include ItIsA
6
5
 
@@ -111,8 +110,12 @@ class Thing
111
110
  def destroyed?
112
111
  @destroyed
113
112
  end
113
+ def destroyed!
114
+ # Override
115
+ end
114
116
  def destroy!
115
117
  return if self.destroyed?
118
+ self.destroyed!
116
119
  self.window.unregister self
117
120
  self.destroyed = true
118
121
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -88,6 +88,7 @@ files:
88
88
  - lib/traits/targeting.rb
89
89
  - lib/traits/targeting/closest.rb
90
90
  - lib/traits/turnable.rb
91
+ - lib/units/sprite.rb
91
92
  - lib/units/thing.rb
92
93
  has_rdoc: true
93
94
  homepage: http://www.github.com/floere/gosu_extensions