dedalus 0.2.10 → 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff3dc108b650336c0bd4cb2c0e39c18b9d55135d
4
- data.tar.gz: ae4f6064a350a89baf66eb46c11290b348d0951c
3
+ metadata.gz: 69c2e241081316b40a5202ef1e04a8ffb891eec1
4
+ data.tar.gz: 10d5a9974a8ba9ea0d8be625b4e963f4892272a2
5
5
  SHA512:
6
- metadata.gz: 73eda2ecb108ba02c198a9af302914f9a1811d2d1399251ad0080642ad5f7f7669bd217c0adaec17ec242e8be2675eade51ce342257126352a8b768acfa0e3b8
7
- data.tar.gz: 88e7eb6fef2f272dd7d4049098b73cc4a34f3da2e6309ea6dd260e707d4827d24bd22ca13e6987a57b9560a6aeb5524035c38200081bc6f8c589309e495d94b4
6
+ metadata.gz: d5e4ba3c3d4b5489228cdff7b7e1a1a09fa9a734b012361a5503e1b75a5c7f484f2b4c4599fd9748fe4086eacf28c6df5f659d45c670435295ba1990e6f75ad0
7
+ data.tar.gz: 1990bd8db8a9d23feb6fdaf0d28bbd8ccdb32409b5ab5f28a309488069ee3518d9634316d3885fb6100284fbe4090dee5bda9f053abe228315015dc3ea6ea8c8
@@ -17,7 +17,7 @@ module Dedalus
17
17
  end
18
18
 
19
19
  class Element
20
- attr_accessor :position
20
+ attr_accessor :position, :offset
21
21
 
22
22
  # in % as 0.0-1.0 (hint to compositing engine for elements in columns/rows respectively)
23
23
  attr_accessor :width_percent, :height_percent
@@ -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
- [(x * image_grid.tile_width), (y * image_grid.tile_height)]
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
- player_location: [2,2],
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
@@ -1,4 +1,4 @@
1
1
  module Dedalus
2
2
  # dedalus version
3
- VERSION = "0.2.10"
3
+ VERSION = "0.2.11"
4
4
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dedalus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Weissman