dedalus 0.2.10 → 0.2.11
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/lib/dedalus/elements.rb +1 -1
- data/lib/dedalus/elements/image_grid.rb +1 -1
- data/lib/dedalus/elements/sprite_field.rb +7 -4
- data/lib/dedalus/version.rb +1 -1
- data/lib/dedalus/view_traversal.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69c2e241081316b40a5202ef1e04a8ffb891eec1
|
4
|
+
data.tar.gz: 10d5a9974a8ba9ea0d8be625b4e963f4892272a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5e4ba3c3d4b5489228cdff7b7e1a1a09fa9a734b012361a5503e1b75a5c7f484f2b4c4599fd9748fe4086eacf28c6df5f659d45c670435295ba1990e6f75ad0
|
7
|
+
data.tar.gz: 1990bd8db8a9d23feb6fdaf0d28bbd8ccdb32409b5ab5f28a309488069ee3518d9634316d3885fb6100284fbe4090dee5bda9f053abe228315015dc3ea6ea8c8
|
data/lib/dedalus/elements.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Dedalus
|
2
2
|
module Elements
|
3
|
+
# TODO image grid should learn to use window#record http://www.rubydoc.info/github/jlnr/gosu/Gosu%2FWindow%3Arecord
|
3
4
|
class ImageGrid < Dedalus::Molecule
|
4
5
|
attr_accessor :grid, :tiles_path, :tile_width, :tile_height
|
5
6
|
|
@@ -53,6 +54,5 @@ module Dedalus
|
|
53
54
|
}
|
54
55
|
end
|
55
56
|
end
|
56
|
-
|
57
57
|
end
|
58
58
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Dedalus
|
2
2
|
module Elements
|
3
3
|
class SpriteField < Dedalus::Organism
|
4
|
-
attr_accessor :grid, :sprite_map, :scale
|
4
|
+
attr_accessor :grid, :sprite_map, :scale, :camera_location
|
5
5
|
|
6
6
|
def show
|
7
7
|
layers
|
@@ -31,17 +31,20 @@ module Dedalus
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def image_grid
|
34
|
+
cx,cy = *camera_location
|
34
35
|
ImageGrid.new(
|
35
36
|
tiles_path: 'media/images/tiles.png',
|
36
37
|
grid: grid,
|
37
38
|
tile_width: 64,
|
38
|
-
tile_height: 64
|
39
|
+
tile_height: 64,
|
40
|
+
offset: [-cx*64, -cy*64]
|
39
41
|
)
|
40
42
|
end
|
41
43
|
|
42
44
|
def to_screen_coordinates(location:)
|
43
45
|
x,y = *location
|
44
|
-
|
46
|
+
cx,cy = *camera_location
|
47
|
+
[(x * image_grid.tile_width - cx*64), (y * image_grid.tile_height - cy*64)]
|
45
48
|
end
|
46
49
|
|
47
50
|
def background_image
|
@@ -59,7 +62,7 @@ module Dedalus
|
|
59
62
|
[1,1,1,1,1],
|
60
63
|
[1,1,1,1,1]],
|
61
64
|
scale: 0.3,
|
62
|
-
|
65
|
+
camera_location: [1.2,2.4],
|
63
66
|
sprite_map: { [1.2,2.4] => [ Sprite.new(Sprite.example_data) ] }
|
64
67
|
}
|
65
68
|
end
|
data/lib/dedalus/version.rb
CHANGED
@@ -28,9 +28,13 @@ module Dedalus
|
|
28
28
|
if structure.is_a?(Dedalus::Atom)
|
29
29
|
@atom_callback.call(structure, origin: origin, dimensions: dimensions, freeform: freeform) if @atom_callback
|
30
30
|
elsif structure.is_a?(Dedalus::Element)
|
31
|
+
offset = structure.offset || [0,0]
|
32
|
+
ox,oy = *offset
|
33
|
+
|
31
34
|
# an element *other than* an atom, we need to call #show on it
|
32
35
|
margin = structure.margin || 0.0
|
33
|
-
x,y = x0 + margin, y0 + margin
|
36
|
+
x,y = x0 + ox + margin, y0 + oy + margin
|
37
|
+
|
34
38
|
margin_origin = [ x, y ]
|
35
39
|
margin_dims = [ width - margin*2, height - margin*2 ]
|
36
40
|
|