lotu 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/Rakefile +1 -1
- data/VERSION +1 -1
- data/examples/mouse_pointer/mouse.rb +8 -8
- data/lib/lotu/actor.rb +6 -0
- data/lib/lotu/behaviors/drawable.rb +6 -1
- data/lib/lotu/behaviors/resourceful.rb +1 -1
- data/lib/lotu/cursor.rb +26 -18
- data/lib/lotu.rb +2 -12
- data/lotu.gemspec +3 -3
- metadata +4 -4
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ begin
|
|
10
10
|
gem.email = "dev@lobotuerto.com"
|
11
11
|
gem.homepage = "http://github.com/lobo-tuerto/lotu"
|
12
12
|
gem.authors = ["lobo_tuerto"]
|
13
|
-
gem.
|
13
|
+
gem.add_dependency "gosu", ">= 0.7.18"
|
14
14
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
15
|
end
|
16
16
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -10,12 +10,12 @@ class Cursor < Lotu::Cursor
|
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
super
|
13
|
-
set_keys(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
set_keys(MsLeft => [:click, false],
|
14
|
+
KbSpace => [:click, false],
|
15
|
+
KbUp => :up,
|
16
|
+
KbDown => :down,
|
17
|
+
KbLeft => :left,
|
18
|
+
KbRight => :right)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -78,8 +78,8 @@ class Example < Lotu::Window
|
|
78
78
|
|
79
79
|
def draw
|
80
80
|
super
|
81
|
-
@
|
82
|
-
@font.draw("
|
81
|
+
@fps_counter.draw
|
82
|
+
@font.draw("Clicked on? #{@cursor.clicked_x}, #{@cursor.clicked_y}", 10, 30, 0, 1.0, 1.0, 0xfffff000)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
data/lib/lotu/actor.rb
CHANGED
@@ -15,10 +15,16 @@ module Lotu
|
|
15
15
|
init_behavior
|
16
16
|
end
|
17
17
|
|
18
|
+
# Easy access to delta-time
|
18
19
|
def dt
|
19
20
|
$window.dt
|
20
21
|
end
|
21
22
|
|
23
|
+
# Remove ourselves from the update queue
|
24
|
+
def die
|
25
|
+
@parent.update_queue.delete(self)
|
26
|
+
end
|
27
|
+
|
22
28
|
# Meant to be overriden by behaviors
|
23
29
|
def init_behavior;end
|
24
30
|
def update;end
|
@@ -12,12 +12,17 @@ module Lotu
|
|
12
12
|
|
13
13
|
def set_image(image)
|
14
14
|
@_image = $window.image(image)
|
15
|
-
|
15
|
+
@parent.draw_queue << self unless @parent.draw_queue.include?(self)
|
16
16
|
end
|
17
17
|
|
18
18
|
def draw
|
19
19
|
@_image.draw(@x,@y,0)
|
20
20
|
end
|
21
|
+
|
22
|
+
def die
|
23
|
+
super
|
24
|
+
@parent.draw_queue.delete(self)
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
data/lib/lotu/cursor.rb
CHANGED
@@ -1,48 +1,56 @@
|
|
1
1
|
# Provides a mouse pointer usable through mouse or keyboard
|
2
2
|
module Lotu
|
3
3
|
class Cursor < Actor
|
4
|
-
attr_reader :
|
5
|
-
attr_accessor :
|
4
|
+
attr_reader :clicked_x, :clicked_y
|
5
|
+
attr_accessor :speed, :use_mouse
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
super
|
9
|
-
@
|
10
|
-
@
|
9
|
+
@clicked_x = @clicked_y = 0
|
10
|
+
@speed = 100
|
11
|
+
@use_mouse = true
|
11
12
|
end
|
12
13
|
|
13
14
|
def update
|
14
|
-
@
|
15
|
-
|
15
|
+
if @use_mouse
|
16
|
+
@x = $window.mouse_x
|
17
|
+
@y = $window.mouse_y
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
21
|
# This is the method you want to call when a user press the
|
19
22
|
# "click" key of your preference with something like:
|
20
23
|
# set_keys Gosu::Button::MsLeft => :click
|
21
|
-
# It'll yield the x, y coordinates of the
|
24
|
+
# It'll yield the x, y coordinates of the clicked point
|
22
25
|
def click
|
23
|
-
@
|
24
|
-
@
|
25
|
-
fire(:click, @
|
26
|
+
@clicked_x = @x
|
27
|
+
@clicked_y = @y
|
28
|
+
fire(:click, @clicked_x, @clicked_y)
|
29
|
+
end
|
30
|
+
|
31
|
+
def adjust_mouse
|
32
|
+
$window.mouse_y = @y
|
33
|
+
$window.mouse_x = @x
|
26
34
|
end
|
27
35
|
|
28
36
|
def up
|
29
|
-
|
37
|
+
@y -= @speed * dt
|
38
|
+
adjust_mouse if use_mouse
|
30
39
|
end
|
31
40
|
|
32
41
|
def down
|
33
|
-
|
42
|
+
@y += @speed * dt
|
43
|
+
adjust_mouse if use_mouse
|
34
44
|
end
|
35
45
|
|
36
46
|
def left
|
37
|
-
|
47
|
+
@x -= @speed * dt
|
48
|
+
adjust_mouse if use_mouse
|
38
49
|
end
|
39
50
|
|
40
51
|
def right
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def last_click
|
45
|
-
"#{@click_x}, #{@click_y}"
|
52
|
+
@x += @speed * dt
|
53
|
+
adjust_mouse if use_mouse
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
data/lib/lotu.rb
CHANGED
@@ -2,15 +2,5 @@ LOTU_ROOT = File.expand_path(File.join(File.dirname(__FILE__), 'lotu'))
|
|
2
2
|
$LOAD_PATH.unshift(LOTU_ROOT)
|
3
3
|
|
4
4
|
require 'gosu'
|
5
|
-
|
6
|
-
require
|
7
|
-
require 'behaviors/resourceful'
|
8
|
-
require 'behaviors/drawable'
|
9
|
-
require 'behaviors/input_controller'
|
10
|
-
require 'behaviors/eventful'
|
11
|
-
require 'behaviors/has_behavior'
|
12
|
-
|
13
|
-
require 'fps'
|
14
|
-
require 'actor'
|
15
|
-
require 'cursor'
|
16
|
-
require 'window'
|
5
|
+
%w{controllable resourceful drawable input_controller eventful has_behavior}.each{|file| require "behaviors/#{file}"}
|
6
|
+
%w{fps actor cursor window}.each{|file| require 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.1"
|
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-
|
12
|
+
s.date = %q{2010-03-17}
|
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 = [
|
@@ -71,7 +71,7 @@ Gem::Specification.new do |s|
|
|
71
71
|
s.specification_version = 3
|
72
72
|
|
73
73
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
74
|
-
s.
|
74
|
+
s.add_runtime_dependency(%q<gosu>, [">= 0.7.18"])
|
75
75
|
else
|
76
76
|
s.add_dependency(%q<gosu>, [">= 0.7.18"])
|
77
77
|
end
|
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
|
+
- 1
|
9
|
+
version: 0.1.1
|
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-
|
17
|
+
date: 2010-03-17 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
- 7
|
30
30
|
- 18
|
31
31
|
version: 0.7.18
|
32
|
-
type: :
|
32
|
+
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
description: 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.
|
35
35
|
email: dev@lobotuerto.com
|