minigl 1.2.2 → 1.2.3
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.
- checksums.yaml +4 -4
- data/data/img/btn.png +0 -0
- data/data/img/text.png +0 -0
- data/lib/minigl/forms.rb +22 -16
- data/lib/minigl/game_object.rb +22 -7
- data/test/game.rb +19 -10
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a86c42ce7c6ca9f79f56802e343f9cc86444088a
|
4
|
+
data.tar.gz: ac13807120b6a030599ee04df958d1bdfde33a0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2222057067a8f1db28f43be8d116605ed574beb73574eb050c1f5bde0fb23558507e1750253128c01157e6685022647eeba2dc164094a3bfdb9eff7d64effce5
|
7
|
+
data.tar.gz: be9b5881dd8d36b826a2706933a22bfcae2fd2d1df41e471b36f77bfa46ed22da4ea9c71c7c69bb5a4fda0cb18a298714cdacb75fd25fd96b9bea167540f5e39
|
data/data/img/btn.png
ADDED
Binary file
|
data/data/img/text.png
ADDED
Binary file
|
data/lib/minigl/forms.rb
CHANGED
@@ -61,13 +61,15 @@ module AGL
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
65
|
-
def draw
|
66
|
-
|
64
|
+
|
65
|
+
def draw text_color = 0, alpha = 0xff
|
66
|
+
color = (alpha << 24) | 0xffffff
|
67
|
+
text_color = (alpha << 24) | text_color
|
68
|
+
@img[@img_index].draw @x, @y, 0, 1, 1, color
|
67
69
|
if @center
|
68
|
-
@font.draw_rel @text, @text_x, @text_y, 0, 0.5, 0.5, 1, 1,
|
70
|
+
@font.draw_rel @text, @text_x, @text_y, 0, 0.5, 0.5, 1, 1, text_color
|
69
71
|
else
|
70
|
-
@font.draw @text, @text_x, @text_y, 0, 1, 1,
|
72
|
+
@font.draw @text, @text_x, @text_y, 0, 1, 1, text_color
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
@@ -341,24 +343,28 @@ module AGL
|
|
341
343
|
set_cursor_visible
|
342
344
|
end
|
343
345
|
|
344
|
-
def draw
|
345
|
-
|
346
|
-
|
346
|
+
def draw text_color = 0, selection_color = 0, alpha = 0xff
|
347
|
+
color = (alpha << 24) | 0xffffff
|
348
|
+
text_color = (alpha << 24) | text_color
|
349
|
+
@img.draw @x, @y, 0, 1, 1, color
|
350
|
+
@font.draw @text, @text_x, @text_y, 0, 1, 1, text_color
|
347
351
|
|
348
352
|
if @anchor1 and @anchor2
|
349
|
-
|
350
|
-
|
351
|
-
@nodes[@anchor2] + 1, @text_y
|
352
|
-
@nodes[@
|
353
|
+
selection_color = ((alpha / 2) << 24) | selection_color
|
354
|
+
Game.window.draw_quad @nodes[@anchor1], @text_y, selection_color,
|
355
|
+
@nodes[@anchor2] + 1, @text_y, selection_color,
|
356
|
+
@nodes[@anchor2] + 1, @text_y + @font.height, selection_color,
|
357
|
+
@nodes[@anchor1], @text_y + @font.height, selection_color, 0
|
353
358
|
end
|
354
359
|
|
355
360
|
if @cursor_visible
|
356
361
|
if @cursor_img; @cursor_img.draw @nodes[@cur_node] - @cursor_img.width / 2, @text_y, 0
|
357
362
|
else
|
358
|
-
|
359
|
-
|
360
|
-
@nodes[@cur_node] + 1, @text_y
|
361
|
-
@nodes[@cur_node], @text_y + @font.height,
|
363
|
+
cursor_color = (alpha << 24) | 0
|
364
|
+
Game.window.draw_quad @nodes[@cur_node], @text_y, cursor_color,
|
365
|
+
@nodes[@cur_node] + 1, @text_y, cursor_color,
|
366
|
+
@nodes[@cur_node] + 1, @text_y + @font.height, cursor_color,
|
367
|
+
@nodes[@cur_node], @text_y + @font.height, cursor_color, 0
|
362
368
|
end
|
363
369
|
end
|
364
370
|
end
|
data/lib/minigl/game_object.rb
CHANGED
@@ -28,11 +28,18 @@ module AGL
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def draw map = nil
|
31
|
+
def draw map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil
|
32
|
+
color = (alpha << 24) | color
|
32
33
|
if map
|
33
|
-
|
34
|
+
if angle
|
35
|
+
@img[@img_index].draw_rot @x.round - map.cam.x, @y.round - map.cam.y, 0, angle, 0.5, 0.5, scale_x, scale_y, color
|
36
|
+
else
|
37
|
+
@img[@img_index].draw @x.round - map.cam.x, @y.round - map.cam.y, 0, scale_x, scale_y, color
|
38
|
+
end
|
39
|
+
elsif angle
|
40
|
+
@img[@img_index].draw_rot @x.round, @y.round, 0, angle, 0.5, 0.5, scale_x, scale_y, color
|
34
41
|
else
|
35
|
-
@img[@img_index].draw @x.round, @y.round, 0
|
42
|
+
@img[@img_index].draw @x.round, @y.round, 0, scale_x, scale_y, color
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
@@ -66,12 +73,20 @@ module AGL
|
|
66
73
|
false
|
67
74
|
end
|
68
75
|
|
69
|
-
def draw map = nil
|
76
|
+
def draw map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil
|
77
|
+
color = (alpha << 24) | color
|
70
78
|
if map
|
71
|
-
|
72
|
-
|
79
|
+
if angle
|
80
|
+
@img[@img_index].draw_rot @x.round + @img_gap.x - map.cam.x,
|
81
|
+
@y.round + @img_gap.y - map.cam.y,
|
82
|
+
0, angle, 0.5, 0.5, scale_x, scale_y, color
|
83
|
+
else
|
84
|
+
@img[@img_index].draw @x.round + @img_gap.x - map.cam.x, @y.round + @img_gap.y - map.cam.y, 0, scale_x, scale_y, color
|
85
|
+
end
|
86
|
+
elsif angle
|
87
|
+
@img[@img_index].draw_rot @x.round + @img_gap.x, @y.round + @img_gap.y, 0, angle, 0.5, 0.5, scale_x, scale_y, color
|
73
88
|
else
|
74
|
-
@img[@img_index].draw @x.round + @img_gap.x, @y.round + @img_gap.y, 0
|
89
|
+
@img[@img_index].draw @x.round + @img_gap.x, @y.round + @img_gap.y, 0, scale_x, scale_y, color
|
75
90
|
end
|
76
91
|
end
|
77
92
|
end
|
data/test/game.rb
CHANGED
@@ -6,11 +6,13 @@ class MyGame < Gosu::Window
|
|
6
6
|
super 800, 600, false # creating a 800 x 600 window, not full screen
|
7
7
|
Game.initialize self, Vector.new(0, 1), 10, 2, 20
|
8
8
|
|
9
|
-
@
|
9
|
+
@obj1 = GameObject.new 10, 10, 80, 80, :img1, Vector.new(-10, -10)
|
10
|
+
@obj2 = Sprite.new 400, 0, :img1
|
11
|
+
|
10
12
|
@font = Res.font :font1, 20
|
11
13
|
@writer = TextHelper.new @font, 5
|
12
|
-
@
|
13
|
-
@
|
14
|
+
@btn = Button.new(10, 560, @font, "Test", :btn, false, 15, 5) {}
|
15
|
+
@txt = TextField.new 10, 520, @font, :text, nil, "", 15, 5, 16
|
14
16
|
end
|
15
17
|
|
16
18
|
def needs_cursor?
|
@@ -19,24 +21,31 @@ class MyGame < Gosu::Window
|
|
19
21
|
|
20
22
|
def update
|
21
23
|
KB.update
|
22
|
-
@y -= 1 if KB.key_held? Gosu::KbUp
|
23
|
-
@x += 1 if KB.key_down? Gosu::KbRight
|
24
|
-
@y += 1 if KB.key_held? Gosu::KbDown
|
25
|
-
@x -= 1 if KB.key_down? Gosu::KbLeft
|
24
|
+
@obj1.y -= 1 if KB.key_held? Gosu::KbUp
|
25
|
+
@obj1.x += 1 if KB.key_down? Gosu::KbRight
|
26
|
+
@obj1.y += 1 if KB.key_held? Gosu::KbDown
|
27
|
+
@obj1.x -= 1 if KB.key_down? Gosu::KbLeft
|
26
28
|
|
27
29
|
Mouse.update
|
28
30
|
if Mouse.double_click? :left
|
29
|
-
@x = Mouse.x
|
30
|
-
@y = Mouse.y
|
31
|
+
@obj1.x = Mouse.x + 10
|
32
|
+
@obj1.y = Mouse.y + 10
|
31
33
|
end
|
34
|
+
|
35
|
+
@btn.update
|
36
|
+
@txt.update
|
32
37
|
end
|
33
38
|
|
34
39
|
def draw
|
35
|
-
@
|
40
|
+
@obj1.draw nil, 1, 1, 0x80, 0x33ff33, 30
|
41
|
+
@obj2.draw nil, 0.6, 1.4, 0x99
|
36
42
|
@writer.write_breaking "Testing multiple line text.\nThis should draw text "\
|
37
43
|
"across multiple lines, respecting a limit width. "\
|
38
44
|
"Furthermore, the text must be right-aligned.",
|
39
45
|
780, 300, 300, :right
|
46
|
+
|
47
|
+
@btn.draw 0x008000, 0xcc
|
48
|
+
@txt.draw 0, 0x0000ff
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minigl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor David Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -40,8 +40,10 @@ files:
|
|
40
40
|
- README.md
|
41
41
|
- Rakefile
|
42
42
|
- data/font/font1.ttf
|
43
|
+
- data/img/btn.png
|
43
44
|
- data/img/image.png
|
44
45
|
- data/img/img1.png
|
46
|
+
- data/img/text.png
|
45
47
|
- data/tileset/tileset1.png
|
46
48
|
- lib/minigl.rb
|
47
49
|
- lib/minigl/forms.rb
|