dedalus 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dedalus/elements/sprite_field.rb +14 -4
- data/lib/dedalus/version.rb +1 -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: ccd682d80ad90e1cf10020d057c1d58ec41e7b63
|
4
|
+
data.tar.gz: 8795a8e23edaee430a5299675a49719c56bc8749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6af7458172873ddc245a291d2bcbee55dda5a157113915f8c0af9009ab0000d63f3ad4dd1de2cc9f6a30dcc9c2b6b6cfddf1a319058dcaca7a80a8ad6b674ee7
|
7
|
+
data.tar.gz: 05d2f7bac3b56a1912e035d76eebd13b4dbcb6c671bd035abb4bd116541da79371d7d6b2247c6d7d4927bf16f7e8f253a377001ec2db952d6cda8fa8f0e72d86
|
@@ -2,11 +2,21 @@ module Dedalus
|
|
2
2
|
module Elements
|
3
3
|
class SpriteField < Dedalus::Organism
|
4
4
|
attr_accessor :grid, :sprite_map, :scale, :camera_location
|
5
|
+
# TODO tiles path and width/height as attrs
|
5
6
|
|
6
7
|
def show
|
7
8
|
layers
|
8
9
|
end
|
9
10
|
|
11
|
+
def camera_offset
|
12
|
+
if camera_location
|
13
|
+
cx,cy = *camera_location
|
14
|
+
[-cx * 64, -cy * 64]
|
15
|
+
else
|
16
|
+
[0,0]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
10
20
|
def layers
|
11
21
|
layer_stack = Dedalus::LayerStack.new
|
12
22
|
layer_stack.push(Dedalus::Layer.new(background_image))
|
@@ -31,20 +41,20 @@ module Dedalus
|
|
31
41
|
end
|
32
42
|
|
33
43
|
def image_grid
|
34
|
-
cx,cy = *
|
44
|
+
# cx,cy = *camera_offset
|
35
45
|
ImageGrid.new(
|
36
46
|
tiles_path: 'media/images/tiles.png',
|
37
47
|
grid: grid,
|
38
48
|
tile_width: 64,
|
39
49
|
tile_height: 64,
|
40
|
-
offset: [-cx*64, -cy*64]
|
50
|
+
offset: camera_offset #[-cx*64, -cy*64]
|
41
51
|
)
|
42
52
|
end
|
43
53
|
|
44
54
|
def to_screen_coordinates(location:)
|
45
55
|
x,y = *location
|
46
|
-
cx,cy = *
|
47
|
-
[(x * image_grid.tile_width
|
56
|
+
cx,cy = *camera_offset
|
57
|
+
[(x * image_grid.tile_width + cx), (y * image_grid.tile_height + cy)]
|
48
58
|
end
|
49
59
|
|
50
60
|
def background_image
|
data/lib/dedalus/version.rb
CHANGED