Now have doors that you can walk though. No open/close animation yet.
This commit is contained in:
parent
02d23bb77d
commit
0add3b29ae
10 changed files with 41 additions and 5 deletions
|
|
@ -231,6 +231,11 @@
|
||||||
"frame_width": 256,
|
"frame_width": 256,
|
||||||
"frame_height": 256
|
"frame_height": 256
|
||||||
},
|
},
|
||||||
|
"door_plain":
|
||||||
|
{"path": "assets/sprites/door_plain.png",
|
||||||
|
"frame_width": 256,
|
||||||
|
"frame_height": 256
|
||||||
|
},
|
||||||
"dead_body_lootable":
|
"dead_body_lootable":
|
||||||
{"path": "assets/sprites/dead_body_lootable.png",
|
{"path": "assets/sprites/dead_body_lootable.png",
|
||||||
"frame_width": 256,
|
"frame_width": 256,
|
||||||
|
|
|
||||||
|
|
@ -136,5 +136,11 @@
|
||||||
"display": 1218,
|
"display": 1218,
|
||||||
"x": 128,
|
"x": 128,
|
||||||
"y": 128
|
"y": 128
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"centered": true,
|
||||||
|
"display": 1087,
|
||||||
|
"x": 128,
|
||||||
|
"y": 128
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
BIN
assets/textures/door_plain.png
Normal file
BIN
assets/textures/door_plain.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
|
|
@ -65,5 +65,13 @@
|
||||||
"foreground": "color:BAD",
|
"foreground": "color:BAD",
|
||||||
"background": "color:BAD",
|
"background": "color:BAD",
|
||||||
"id": 8
|
"id": 8
|
||||||
|
},
|
||||||
|
"door_plain": {
|
||||||
|
"texture": "assets/textures/door_plain.png",
|
||||||
|
"display": 1087,
|
||||||
|
"light": 0,
|
||||||
|
"foreground": "tiles/fg:wall_plain",
|
||||||
|
"background": "tiles/bg:wall_plain",
|
||||||
|
"id": 9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,16 @@ namespace maze {
|
||||||
size_t $height = 0;
|
size_t $height = 0;
|
||||||
Matrix& $walls;
|
Matrix& $walls;
|
||||||
std::vector<Room>& $rooms;
|
std::vector<Room>& $rooms;
|
||||||
|
std::unordered_map<Point, bool>& $doors;
|
||||||
std::vector<Point>& $dead_ends;
|
std::vector<Point>& $dead_ends;
|
||||||
std::unordered_map<Point, bool> $ends_map;
|
std::unordered_map<Point, bool> $ends_map;
|
||||||
Room $no_rooms_region{0,0,0,0};
|
Room $no_rooms_region{0,0,0,0};
|
||||||
// BUG: instead of bool map it to the room?
|
// BUG: instead of bool map it to the room?
|
||||||
std::unordered_map<Point, bool> $doors;
|
|
||||||
Pathing $pathing;
|
Pathing $pathing;
|
||||||
|
|
||||||
Builder(Map& map) :
|
Builder(Map& map) :
|
||||||
$width(map.$width), $height(map.$height), $walls(map.$walls),
|
$width(map.$width), $height(map.$height), $walls(map.$walls),
|
||||||
$rooms(map.$rooms), $dead_ends(map.$dead_ends), $pathing{$width, $height}
|
$rooms(map.$rooms), $doors(map.$doors), $dead_ends(map.$dead_ends), $pathing{$width, $height}
|
||||||
{
|
{
|
||||||
dbc::check($width % 2 == 1, "map width not an ODD number (perimter dead ends bug)");
|
dbc::check($width % 2 == 1, "map width not an ODD number (perimter dead ends bug)");
|
||||||
dbc::check($height % 2 == 1, "map height not an ODD number (perimter dead ends bug)");
|
dbc::check($height % 2 == 1, "map height not an ODD number (perimter dead ends bug)");
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ bool Map::place_entity(size_t room_index, Point &out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Map::iswall(size_t x, size_t y) {
|
bool Map::iswall(size_t x, size_t y) {
|
||||||
return $walls[y][x] == WALL_VALUE;
|
return !$doors.contains({x, y}) && $walls[y][x] == WALL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map::dump(int show_x, int show_y) {
|
void Map::dump(int show_x, int show_y) {
|
||||||
|
|
@ -71,8 +71,7 @@ void Map::dump(int show_x, int show_y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Map::can_move(Point move_to) {
|
bool Map::can_move(Point move_to) {
|
||||||
return inmap(move_to.x, move_to.y) &&
|
return inmap(move_to.x, move_to.y) && !iswall(move_to.x, move_to.y);
|
||||||
!iswall(move_to.x, move_to.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Point Map::map_to_camera(const Point &loc, const Point &cam_orig) {
|
Point Map::map_to_camera(const Point &loc, const Point &cam_orig) {
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ public:
|
||||||
Pathing $paths;
|
Pathing $paths;
|
||||||
std::vector<Room> $rooms;
|
std::vector<Room> $rooms;
|
||||||
std::vector<Point> $dead_ends;
|
std::vector<Point> $dead_ends;
|
||||||
|
std::unordered_map<Point, bool> $doors;
|
||||||
|
|
||||||
Map(size_t width, size_t height);
|
Map(size_t width, size_t height);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,11 +163,25 @@ void WorldBuilder::randomize_entities(DinkyECS::World &world, GameConfig &config
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& at : $map.$dead_ends) {
|
for(auto& at : $map.$dead_ends) {
|
||||||
|
if($map.$doors.contains(at)) continue;
|
||||||
auto& entity_data = random_entity_data(config, gen_config);
|
auto& entity_data = random_entity_data(config, gen_config);
|
||||||
configure_entity_in_map(world, entity_data, at);
|
configure_entity_in_map(world, entity_data, at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldBuilder::place_doors(DinkyECS::World& world, GameConfig& config) {
|
||||||
|
auto& device_config = config.devices.json();
|
||||||
|
auto entity_data = device_config["DOOR_PLAIN"];
|
||||||
|
auto& tiles = $map.tiles();
|
||||||
|
|
||||||
|
size_t door_id = textures::get_id("door_plain");
|
||||||
|
|
||||||
|
for(auto [door_at, _] : $map.$doors) {
|
||||||
|
$map.$walls[door_at.y][door_at.x] = WALL_VALUE;
|
||||||
|
tiles[door_at.y][door_at.x] = door_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WorldBuilder::place_stairs(DinkyECS::World& world, GameConfig& config) {
|
void WorldBuilder::place_stairs(DinkyECS::World& world, GameConfig& config) {
|
||||||
auto& device_config = config.devices.json();
|
auto& device_config = config.devices.json();
|
||||||
auto entity_data = device_config["STAIRS_DOWN"];
|
auto entity_data = device_config["STAIRS_DOWN"];
|
||||||
|
|
@ -233,6 +247,7 @@ void WorldBuilder::place_entities(DinkyECS::World &world) {
|
||||||
dbc::check(player_pos.location.x != 0 && player_pos.location.y != 0,
|
dbc::check(player_pos.location.x != 0 && player_pos.location.y != 0,
|
||||||
"failed to place the player correctly");
|
"failed to place the player correctly");
|
||||||
|
|
||||||
|
place_doors(world, config);
|
||||||
randomize_entities(world, config);
|
randomize_entities(world, config);
|
||||||
place_stairs(world, config);
|
place_stairs(world, config);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class WorldBuilder {
|
||||||
void generate(DinkyECS::World &world);
|
void generate(DinkyECS::World &world);
|
||||||
void randomize_entities(DinkyECS::World &world, components::GameConfig &config);
|
void randomize_entities(DinkyECS::World &world, components::GameConfig &config);
|
||||||
void place_stairs(DinkyECS::World& world, components::GameConfig& config);
|
void place_stairs(DinkyECS::World& world, components::GameConfig& config);
|
||||||
|
void place_doors(DinkyECS::World& world, components::GameConfig& config);
|
||||||
void configure_starting_items(DinkyECS::World &world);
|
void configure_starting_items(DinkyECS::World &world);
|
||||||
void stylize_rooms();
|
void stylize_rooms();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,7 @@ void Raycaster::cast_rays() {
|
||||||
int draw_end = line_height / 2 + $height / 2 + $pitch;
|
int draw_end = line_height / 2 + $height / 2 + $pitch;
|
||||||
if(draw_end >= $height) draw_end = $height - 1;
|
if(draw_end >= $height) draw_end = $height - 1;
|
||||||
|
|
||||||
|
// BUG: I thought I got rid of this
|
||||||
auto texture = textures::get_surface($tiles[map_y][map_x]);
|
auto texture = textures::get_surface($tiles[map_y][map_x]);
|
||||||
|
|
||||||
// calculate value of wall_x
|
// calculate value of wall_x
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue