feat: reorganized logic + camera
This commit is contained in:
1 parent
bee8cdeeef
commit
fa6e5d9582
12 files changed
+124
-100
No files matched your search
+23
-19
@@ -17,31 +17,35 @@ var cur_int: Dictionary = {
|
||||
TileSet.CELL_NEIGHBOR_RIGHT_SIDE: 0,
|
||||
TileSet.CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE: 1,
|
||||
TileSet.CELL_NEIGHBOR_BOTTOM_LEFT_SIDE: 2,
|
||||
TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE: 3,
|
||||
TileSet.CELL_NEIGHBOR_LEFT_SIDE: 4,
|
||||
TileSet.CELL_NEIGHBOR_LEFT_SIDE: 3,
|
||||
TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE: 4,
|
||||
TileSet.CELL_NEIGHBOR_TOP_RIGHT_SIDE: 5,
|
||||
}
|
||||
|
||||
func _ready() -> void:
|
||||
set_frame(1)
|
||||
set_z_index(1)
|
||||
tiles.set_tile(pos, (tiles.get_tile_colour(pos) + 1) % 2) # TODO: should probably use another dictionary
|
||||
self.set_z_index(1)
|
||||
self.set_frame(cur_int[dir])
|
||||
tiles.set_tile(pos, (tiles.get_tile_colour(pos))) # TODO: should probably use another dictionary
|
||||
move()
|
||||
|
||||
func update() -> void:
|
||||
var tile: int = tiles.get_tile_colour(pos)
|
||||
print("tile %s" % tile)
|
||||
var newFrame: int = cur_int[dir]
|
||||
|
||||
# TODO: turn into dict{tileCol, (nextDir, paintCol)} customizable
|
||||
match tile:
|
||||
0:
|
||||
newFrame = (newFrame + 1) % 6
|
||||
newFrame = (newFrame + 5) % tiles.numTiles
|
||||
1:
|
||||
newFrame = (newFrame + 1) % 6
|
||||
newFrame = (newFrame + 4) % tiles.numTiles
|
||||
2:
|
||||
newFrame = (newFrame + 1) % 6
|
||||
newFrame = (newFrame + 0) % tiles.numTiles
|
||||
3:
|
||||
newFrame = (newFrame + 5) % 6
|
||||
newFrame = (newFrame + 0) % tiles.numTiles
|
||||
4:
|
||||
newFrame = (newFrame + 5) % tiles.numTiles
|
||||
5:
|
||||
newFrame = (newFrame + 4) % tiles.numTiles
|
||||
_:
|
||||
pass
|
||||
dir = next_dir[newFrame]
|
||||
@@ -49,24 +53,24 @@ func update() -> void:
|
||||
move()
|
||||
pos = tiles.get_neighbor_cell(pos, dir)
|
||||
tile = tiles.get_tile_colour(pos)
|
||||
tiles.set_tile(pos, (tile + 1) % 4) # TODO: should probably use another dictionary
|
||||
set_frame(newFrame)
|
||||
tiles.set_tile(pos, (tile + 1) % tiles.numTiles) # TODO: should probably use another dictionary
|
||||
self.set_frame(newFrame)
|
||||
|
||||
func move() -> void:
|
||||
var delta: Vector2
|
||||
match dir:
|
||||
TileSet.CELL_NEIGHBOR_RIGHT_SIDE:
|
||||
delta = Vector2(32, 0)
|
||||
delta = Vector2(tiles.texSize.x, 0)
|
||||
TileSet.CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE:
|
||||
delta = Vector2(16, 24)
|
||||
delta = Vector2(tiles.texSize.x/2, tiles.texSize.y/4*3)
|
||||
TileSet.CELL_NEIGHBOR_BOTTOM_LEFT_SIDE:
|
||||
delta = Vector2(-16, 24)
|
||||
delta = Vector2(-tiles.texSize.x/2, tiles.texSize.y/4*3)
|
||||
TileSet.CELL_NEIGHBOR_LEFT_SIDE:
|
||||
delta = Vector2(-32, 0)
|
||||
delta = Vector2(-tiles.texSize.x, 0)
|
||||
TileSet.CELL_NEIGHBOR_TOP_LEFT_SIDE:
|
||||
delta = Vector2(-16, -24)
|
||||
delta = Vector2(-tiles.texSize.x/2, -tiles.texSize.y/4*3)
|
||||
TileSet.CELL_NEIGHBOR_TOP_RIGHT_SIDE:
|
||||
delta = Vector2(16, -24)
|
||||
delta = Vector2(tiles.texSize.x/2, -tiles.texSize.y/4*3)
|
||||
_:
|
||||
delta = Vector2(0,0)
|
||||
translate(delta)
|
||||
self.translate(delta)
|
||||