Commit a5f6e34c authored by tgw3ff's avatar tgw3ff
Browse files

Implement Interactible Chests

0 to 3 interactible chests will now spawn on each floor. Loot for chests still
needs to be implemented.
parent e829612e
61528
C:\Users\Username\Desktop\Godot_v3.2.3-stable_mono_win64\Godot_v3.2.3-stable_mono_win64.exe
......@@ -6,6 +6,7 @@ const TYPE_ARRAY = 19
# The pairings also equate to the corresponding tile group's index in the
# atlas tileset
enum {
CHEST = -3,
HOLE = -2,
EMPTY = -1,
WALL,
......
......@@ -3,6 +3,10 @@ const ROOM = preload("res://src/Room.gd")
# Percentage of cells in the map that should be enemy spawns
const ENEMY_FILL_PERCENT = 0.15
# Maximum number of chests in a level
const MAX_CHESTS = 3
# Minimum number of chests in a level
const MIN_CHESTS = 1
# Stores the empty coordinates on the map and which "room" they are each a part of
var rooms = []
var centers = []
......@@ -451,6 +455,23 @@ func spawn_enemies():
if coord_in_what_room(spawn).find_distance_individual(spawn, "PLAYER") < 4:
enemy_spawns.append(spawn)
# Spawn chests
func spawn_chests():
var chest_spawns = []
for i in range(MIN_CHESTS, MAX_CHESTS + 1):
var room
randomize()
room = rooms[randi() % rooms.size()]
chest_spawns.append(room.get_random_hole_spawn())
for spawn in chest_spawns:
if !coord_in_what_room(spawn).spawn_room:
print(spawn)
grid[spawn.y][spawn.x].content = CELL.CHEST
grid[spawn.y][spawn.x].elligible_hole = false
# Generates a new map
func generate_map(fill_percent, width, height):
rooms.clear()
......@@ -468,7 +489,10 @@ func generate_map(fill_percent, width, height):
minimum_tree = get_minimum_spanning_tree()
player_spawn = spawn_player()
print(player_spawn)
spawn_holes()
spawn_chests()
spawn_enemies()
......@@ -213,6 +213,9 @@ func update_tile(x, y):
CELL.HOLE:
index = CELL.ROCK_T
autotile = Vector2(1, 2)
CELL.CHEST:
index = CELL.ROCK_T
autotile = Vector2(0, 1)
set_cell(x, y, index, false, false, false, autotile)
......@@ -258,6 +261,9 @@ func break_obstacle(x, y):
autotile = Vector2(1, 0)
CELL.PLANT_T:
autotile = Vector2(1, 0)
CELL.CHEST:
index = CELL.ROCK_T
autotile = Vector2(1, 1)
if autotile != null:
set_cell(x, y, index, false, false, false, autotile)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment