lotu 0.1.13 → 0.1.14

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.13
1
+ 0.1.14
@@ -16,7 +16,7 @@ include Lotu
16
16
  # We want to move something around the screen so we create a new Actor
17
17
  # subclass, set the image all instances of it are going to use and
18
18
  # define the movement methods
19
- class Lobo < Actor
19
+ class Portrait < Actor
20
20
 
21
21
  def initialize(opts={})
22
22
  # It's important to call super so we take advantage of automatic
@@ -64,7 +64,7 @@ class Portraits < Game
64
64
  # This method is called when we call super inside initialize
65
65
  def setup_actors
66
66
  # Create a lobo in the middle of the screen
67
- @lobo1 = Lobo.new(:x => width/2, :y => height/2)
67
+ @lobo1 = Portrait.new(:x => width/2, :y => height/2)
68
68
  # Map keys to some methods
69
69
  @lobo1.set_keys(KbRight => :move_right,
70
70
  KbLeft => :move_left,
@@ -72,7 +72,7 @@ class Portraits < Game
72
72
  KbDown => :move_down)
73
73
 
74
74
  # Rinse and repeat... but invert some keys
75
- @lobo2 = Lobo.new(:x => width/2, :y => height/2)
75
+ @lobo2 = Portrait.new(:x => width/2, :y => height/2)
76
76
  @lobo2.set_keys(KbRight => :move_left,
77
77
  KbLeft => :move_right,
78
78
  KbUp => :move_up,
@@ -89,11 +89,11 @@ class Cursors < Game
89
89
  :width => 100,
90
90
  :rand_color => true,
91
91
  :mode => :additive)
92
- # Use the transformation system to change our angle over time,
93
- # with an initial value of 0 degrees, to 359 degrees (full
92
+ # Use the interpolation system to change our angle over time,
93
+ # with an initial value of 0 degrees, up to 359 degrees (full
94
94
  # circle), do it in a time frame of 10 seconds, and when done,
95
95
  # start over again
96
- @cursor1.transform_angle(:init => 0, :end => 359, :duration => 10, :start_in => 3, :bounce => true, :loop => true)
96
+ @cursor1.interpolate_angle(:init => 0, :end => 359, :duration => 10, :start_in => 3, :bounce => true, :loop => true)
97
97
 
98
98
  @cursor2 = Cursor.new(:image => 'crosshair-2.png',
99
99
  :use_mouse => false,
@@ -107,10 +107,10 @@ class Cursors < Game
107
107
  :rand_color => true,
108
108
  :mode => :additive)
109
109
  # Use the transformation system to change our angle over time,
110
- # with an initial value of 359 degrees, to 0 degrees (full
110
+ # with an initial value of 359 degrees, up to 0 degrees (full
111
111
  # circle in reverse), do it in a time frame of 1 second, and
112
112
  # when done, start over again
113
- @cursor2.transform_angle(:init => 359, :end => 0, :duration => 1, :loop => true, :start_in => 2)
113
+ @cursor2.interpolate_angle(:init => 359, :end => 0, :duration => 1, :loop => true, :start_in => 2)
114
114
 
115
115
  # Center @cursor2 vertically and move it to the right 3/4 of the
116
116
  # screen
data/lib/lotu/actor.rb CHANGED
@@ -36,7 +36,7 @@ module Lotu
36
36
  self.extend Eventful
37
37
  self.extend Collidable
38
38
  use(AnimationSystem)
39
- use(TransformationSystem)
39
+ use(InterpolationSystem)
40
40
  end
41
41
 
42
42
  # Easy access to delta-time
@@ -1,15 +1,16 @@
1
+ # -*- coding: utf-8 -*-
1
2
  module Lotu
2
- class TransformationSystem < System
3
+ class InterpolationSystem < System
3
4
 
4
5
  def initialize(user, opts={})
5
6
  super
6
7
  user.extend(UserMethods)
7
- @transformations = []
8
+ @interpolations = []
8
9
  @tagged_for_deletion = []
9
10
  end
10
11
 
11
- def transform(object, property, opts)
12
- transformation = {
12
+ def interpolate(object, property, opts)
13
+ interpolation = {
13
14
  :object => object,
14
15
  :property_getter => property,
15
16
  :property_setter => "#{property}=",
@@ -24,11 +25,12 @@ module Lotu
24
25
  :bounce => opts[:bounce],
25
26
  :bouncing_back => false
26
27
  }
27
- @transformations << transformation
28
+ @interpolations << interpolation
28
29
  end
29
30
 
31
+ # TODO: incluir código para :loop_for => n
30
32
  def update
31
- @transformations.each do |t|
33
+ @interpolations.each do |t|
32
34
  t[:accum_time] += dt
33
35
  if t[:accum_time] > t[:start_in]
34
36
  step = (t[:end] - t[:init])/t[:duration] * dt
@@ -53,64 +55,64 @@ module Lotu
53
55
  end
54
56
 
55
57
  @tagged_for_deletion.each do |to_delete|
56
- @transformations.delete(to_delete)
58
+ @interpolations.delete(to_delete)
57
59
  end.clear
58
60
  end
59
61
 
60
- def tag_for_deletion(transform)
61
- @tagged_for_deletion << transform
62
+ def tag_for_deletion(interpolation)
63
+ @tagged_for_deletion << interpolation
62
64
  end
63
65
 
64
66
  def to_s
65
- ["@transformations.length #{@transformations.length}",
67
+ ["@interpolations.length #{@interpolations.length}",
66
68
  "@tagged_for_deletion.length #{@tagged_for_deletion.length}"]
67
69
  end
68
70
 
69
71
  module UserMethods
70
- def transform(object, property, opts)
71
- @systems[TransformationSystem].transform(object, property, opts)
72
+ def interpolate(object, property, opts)
73
+ @systems[InterpolationSystem].interpolate(object, property, opts)
72
74
  end
73
75
 
74
76
  # Image helpers
75
- def transform_angle(opts)
76
- transform(self, :angle, opts)
77
+ def interpolate_angle(opts)
78
+ interpolate(self, :angle, opts)
77
79
  end
78
80
 
79
- def transform_width(opts)
80
- transform(self, :width, opts)
81
+ def interpolate_width(opts)
82
+ interpolate(self, :width, opts)
81
83
  end
82
84
 
83
- def transform_height(opts)
84
- transform(self, :height, opts)
85
+ def interpolate_height(opts)
86
+ interpolate(self, :height, opts)
85
87
  end
86
88
 
87
89
  # Color helpers
88
- def transform_alpha(opts)
89
- transform(@color, :alpha, opts.merge!(:on_result => :to_i))
90
+ def interpolate_alpha(opts)
91
+ interpolate(@color, :alpha, opts.merge!(:on_result => :to_i))
90
92
  end
91
93
 
92
- def transform_red(opts)
93
- transform(@color, :red, opts.merge!(:on_result => :to_i))
94
+ def interpolate_red(opts)
95
+ interpolate(@color, :red, opts.merge!(:on_result => :to_i))
94
96
  end
95
97
 
96
- def transform_green(opts)
97
- transform(@color, :green, opts.merge!(:on_result => :to_i))
98
+ def interpolate_green(opts)
99
+ interpolate(@color, :green, opts.merge!(:on_result => :to_i))
98
100
  end
99
101
 
100
- def transform_blue(opts)
101
- transform(@color, :blue, opts.merge!(:on_result => :to_i))
102
+ def interpolate_blue(opts)
103
+ interpolate(@color, :blue, opts.merge!(:on_result => :to_i))
102
104
  end
103
105
 
104
- def transform_hue(opts)
105
- transform(@color, :hue, opts)
106
+ def interpolate_hue(opts)
107
+ interpolate(@color, :hue, opts)
106
108
  end
107
109
 
108
- def transform_saturation(opts)
109
- transform(@color, :saturation, opts)
110
+ def interpolate_saturation(opts)
111
+ interpolate(@color, :saturation, opts)
110
112
  end
111
113
 
112
- def transform_value(opts)
113
- transform(@color, :value, opts)
114
+ def interpolate_value(opts)
115
+ interpolate(@color, :value, opts)
114
116
  end
115
117
  end
116
118
 
data/lib/lotu.rb CHANGED
@@ -5,4 +5,4 @@ require 'gosu'
5
5
  %w{vector2d string}.each{|file| require "misc/#{file}"}
6
6
  %w{system_user collidable controllable eventful}.each{|file| require "behaviors/#{file}"}
7
7
  %w{game system actor cursor text_box}.each{|file| require file}
8
- %w{transformation_system animation_system input_system stalker_system fps_system collision_system steering_system}.each{|file| require "systems/#{file}"}
8
+ %w{interpolation_system animation_system input_system stalker_system fps_system collision_system steering_system}.each{|file| require "systems/#{file}"}
data/lotu.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lotu}
8
- s.version = "0.1.13"
8
+ s.version = "0.1.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["lobo_tuerto"]
12
- s.date = %q{2010-03-31}
12
+ s.date = %q{2010-04-05}
13
13
  s.description = %q{lotu aims to bring an agile and simple game development framework to life. It provides useful abstractions so you can concentrate on developing your game.}
14
14
  s.email = %q{dev@lobotuerto.com}
15
15
  s.extra_rdoc_files = [
@@ -54,9 +54,9 @@ Gem::Specification.new do |s|
54
54
  "lib/lotu/systems/collision_system.rb",
55
55
  "lib/lotu/systems/fps_system.rb",
56
56
  "lib/lotu/systems/input_system.rb",
57
+ "lib/lotu/systems/interpolation_system.rb",
57
58
  "lib/lotu/systems/stalker_system.rb",
58
59
  "lib/lotu/systems/steering_system.rb",
59
- "lib/lotu/systems/transformation_system.rb",
60
60
  "lib/lotu/text_box.rb",
61
61
  "lotu.gemspec",
62
62
  "test/actor_test.rb"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 13
9
- version: 0.1.13
8
+ - 14
9
+ version: 0.1.14
10
10
  platform: ruby
11
11
  authors:
12
12
  - lobo_tuerto
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-31 00:00:00 -06:00
17
+ date: 2010-04-05 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -78,9 +78,9 @@ files:
78
78
  - lib/lotu/systems/collision_system.rb
79
79
  - lib/lotu/systems/fps_system.rb
80
80
  - lib/lotu/systems/input_system.rb
81
+ - lib/lotu/systems/interpolation_system.rb
81
82
  - lib/lotu/systems/stalker_system.rb
82
83
  - lib/lotu/systems/steering_system.rb
83
- - lib/lotu/systems/transformation_system.rb
84
84
  - lib/lotu/text_box.rb
85
85
  - lotu.gemspec
86
86
  - test/actor_test.rb