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 +1 -1
- data/examples/hello_world/moving_portraits.rb +3 -3
- data/examples/screen_cursor/mouse_and_keyboard_cursors.rb +5 -5
- data/lib/lotu/actor.rb +1 -1
- data/lib/lotu/systems/{transformation_system.rb → interpolation_system.rb} +34 -32
- data/lib/lotu.rb +1 -1
- data/lotu.gemspec +3 -3
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
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
|
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 =
|
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 =
|
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
|
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.
|
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.
|
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
@@ -1,15 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
module Lotu
|
2
|
-
class
|
3
|
+
class InterpolationSystem < System
|
3
4
|
|
4
5
|
def initialize(user, opts={})
|
5
6
|
super
|
6
7
|
user.extend(UserMethods)
|
7
|
-
@
|
8
|
+
@interpolations = []
|
8
9
|
@tagged_for_deletion = []
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
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
|
-
@
|
28
|
+
@interpolations << interpolation
|
28
29
|
end
|
29
30
|
|
31
|
+
# TODO: incluir código para :loop_for => n
|
30
32
|
def update
|
31
|
-
@
|
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
|
-
@
|
58
|
+
@interpolations.delete(to_delete)
|
57
59
|
end.clear
|
58
60
|
end
|
59
61
|
|
60
|
-
def tag_for_deletion(
|
61
|
-
@tagged_for_deletion <<
|
62
|
+
def tag_for_deletion(interpolation)
|
63
|
+
@tagged_for_deletion << interpolation
|
62
64
|
end
|
63
65
|
|
64
66
|
def to_s
|
65
|
-
["@
|
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
|
71
|
-
@systems[
|
72
|
+
def interpolate(object, property, opts)
|
73
|
+
@systems[InterpolationSystem].interpolate(object, property, opts)
|
72
74
|
end
|
73
75
|
|
74
76
|
# Image helpers
|
75
|
-
def
|
76
|
-
|
77
|
+
def interpolate_angle(opts)
|
78
|
+
interpolate(self, :angle, opts)
|
77
79
|
end
|
78
80
|
|
79
|
-
def
|
80
|
-
|
81
|
+
def interpolate_width(opts)
|
82
|
+
interpolate(self, :width, opts)
|
81
83
|
end
|
82
84
|
|
83
|
-
def
|
84
|
-
|
85
|
+
def interpolate_height(opts)
|
86
|
+
interpolate(self, :height, opts)
|
85
87
|
end
|
86
88
|
|
87
89
|
# Color helpers
|
88
|
-
def
|
89
|
-
|
90
|
+
def interpolate_alpha(opts)
|
91
|
+
interpolate(@color, :alpha, opts.merge!(:on_result => :to_i))
|
90
92
|
end
|
91
93
|
|
92
|
-
def
|
93
|
-
|
94
|
+
def interpolate_red(opts)
|
95
|
+
interpolate(@color, :red, opts.merge!(:on_result => :to_i))
|
94
96
|
end
|
95
97
|
|
96
|
-
def
|
97
|
-
|
98
|
+
def interpolate_green(opts)
|
99
|
+
interpolate(@color, :green, opts.merge!(:on_result => :to_i))
|
98
100
|
end
|
99
101
|
|
100
|
-
def
|
101
|
-
|
102
|
+
def interpolate_blue(opts)
|
103
|
+
interpolate(@color, :blue, opts.merge!(:on_result => :to_i))
|
102
104
|
end
|
103
105
|
|
104
|
-
def
|
105
|
-
|
106
|
+
def interpolate_hue(opts)
|
107
|
+
interpolate(@color, :hue, opts)
|
106
108
|
end
|
107
109
|
|
108
|
-
def
|
109
|
-
|
110
|
+
def interpolate_saturation(opts)
|
111
|
+
interpolate(@color, :saturation, opts)
|
110
112
|
end
|
111
113
|
|
112
|
-
def
|
113
|
-
|
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{
|
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.
|
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-
|
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
|
-
-
|
9
|
-
version: 0.1.
|
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-
|
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
|