feat: add 30x20 demo map and chest interaction
This commit is contained in:
+30
-15
@@ -51,8 +51,9 @@ func _capture_visual_check(capture_mode: String) -> void:
|
||||
get_tree().quit(0 if result == OK else 1)
|
||||
|
||||
func _prepare_exit_capture_state() -> void:
|
||||
game_state.map.set_cell(Vector2i(2, 1), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.player.cell = Vector2i(9, 7)
|
||||
game_state.map.set_cell(Vector2i(4, 10), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.player.cell = Vector2i(18, 4)
|
||||
_process_interact()
|
||||
_sync_camera_to_player()
|
||||
|
||||
@@ -139,21 +140,35 @@ func _show_damage_feedback(results: Array[TurnResult]) -> void:
|
||||
player_view.show_damage(result.damage)
|
||||
|
||||
func _create_initial_state() -> GameState:
|
||||
var map := GridMapStateType.new(Vector2i(12, 10), GridMapStateType.CellKind.FLOOR)
|
||||
for x in range(map.size.x):
|
||||
map.set_cell(Vector2i(x, 0), GridMapStateType.CellKind.WALL)
|
||||
map.set_cell(Vector2i(x, map.size.y - 1), GridMapStateType.CellKind.WALL)
|
||||
for y in range(map.size.y):
|
||||
map.set_cell(Vector2i(0, y), GridMapStateType.CellKind.WALL)
|
||||
map.set_cell(Vector2i(map.size.x - 1, y), GridMapStateType.CellKind.WALL)
|
||||
map.set_cell(Vector2i(1, 2), GridMapStateType.CellKind.WALL)
|
||||
map.set_cell(Vector2i(2, 1), GridMapStateType.CellKind.CLOSED_DOOR)
|
||||
map.set_cell(Vector2i(8, 3), GridMapStateType.CellKind.CHEST)
|
||||
map.set_cell(Vector2i(9, 7), GridMapStateType.CellKind.STAIRS)
|
||||
var player := ActorStateType.new(&"player", Vector2i(2, 2), 12, 3)
|
||||
var goblin := ActorStateType.new(&"goblin", Vector2i(4, 2), 6, 2)
|
||||
var map := GridMapStateType.new(Vector2i(30, 20), GridMapStateType.CellKind.WALL)
|
||||
_carve_room(map, Rect2i(2, 12, 6, 5))
|
||||
_carve_room(map, Rect2i(2, 4, 7, 7))
|
||||
_carve_room(map, Rect2i(10, 2, 10, 6))
|
||||
_carve_room(map, Rect2i(21, 5, 7, 8))
|
||||
_carve_vertical_corridor(map, 4, 10, 12)
|
||||
_carve_horizontal_corridor(map, 8, 10, 6)
|
||||
_carve_horizontal_corridor(map, 18, 21, 6)
|
||||
_carve_vertical_corridor(map, 18, 4, 6)
|
||||
map.set_cell(Vector2i(4, 11), GridMapStateType.CellKind.CLOSED_DOOR)
|
||||
map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.CHEST)
|
||||
map.set_cell(Vector2i(18, 4), GridMapStateType.CellKind.STAIRS)
|
||||
var player := ActorStateType.new(&"player", Vector2i(4, 12), 12, 3)
|
||||
var goblin := ActorStateType.new(&"goblin", Vector2i(24, 8), 6, 2)
|
||||
return GameStateType.new(map, player, {&"goblin": goblin})
|
||||
|
||||
func _carve_room(map: GridMapState, room: Rect2i) -> void:
|
||||
for y in range(room.position.y, room.end.y):
|
||||
for x in range(room.position.x, room.end.x):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _carve_horizontal_corridor(map: GridMapState, from_x: int, to_x: int, y: int) -> void:
|
||||
for x in range(from_x, to_x + 1):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _carve_vertical_corridor(map: GridMapState, x: int, from_y: int, to_y: int) -> void:
|
||||
for y in range(from_y, to_y + 1):
|
||||
map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)
|
||||
|
||||
func _configure_camera() -> void:
|
||||
var map_size := game_state.map.size * TILE_SIZE
|
||||
camera.limit_left = $World.position.x
|
||||
|
||||
Reference in New Issue
Block a user