Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
23 KB
Referenced Files
None
Subscribers
None
diff --git a/media/tiles.png b/media/tiles.png
index d3277e6..1acbf84 100644
Binary files a/media/tiles.png and b/media/tiles.png differ
diff --git a/src/DoorEntity.cpp b/src/DoorEntity.cpp
index 551f013..81c0c3f 100644
--- a/src/DoorEntity.cpp
+++ b/src/DoorEntity.cpp
@@ -1,286 +1,281 @@
#include "DoorEntity.h"
#include "Constants.h"
#include "sfml_game/ImageManager.h"
DoorEntity::DoorEntity(int direction) : SpriteEntity (ImageManager::getImageManager()->getImage(IMAGE_DOOR))
{
this->direction = direction;
isOpen = true;
removeCenter();
width = TILE_WIDTH;
height = TILE_HEIGHT;
z = -0.5f;
type = ENTITY_DOOR;
doorType = 0;
-
- //isOpen = false;
- //timer = DOOR_CLOSE_TIME;
}
void DoorEntity::animate(float delay)
{
age += delay;
-
if (timer > 0.0f) timer -= delay;
- //SpriteEntity::animate(delay);
}
void DoorEntity::setOpen(bool open)
{
isOpen = open;
timer = 0.0f;
}
void DoorEntity::setDoorType(int doorType)
{
this->doorType = doorType;
}
void DoorEntity::closeDoor()
{
isOpen = false;
timer = DOOR_CLOSE_TIME;
}
void DoorEntity::openDoor()
{
isOpen = true;
timer = DOOR_OPEN_TIME;
}
void DoorEntity::render(sf::RenderWindow* app)
{
if (!isVisible) return;
float xl, yl, xr, yr;
if (direction == 8)
{
yl = OFFSET_Y;
yr = OFFSET_Y;
if (isOpen)
{
if (timer > 0.0f)
{
xl = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH - TILE_WIDTH / 2
- 1.2f * ((1.0f - (timer / DOOR_OPEN_TIME)) * TILE_WIDTH / 2);
xr = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH + TILE_WIDTH / 2
+ 1.2f * ((1.0f - (timer / DOOR_OPEN_TIME)) * TILE_WIDTH / 2);
}
else
{
xl = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH - TILE_WIDTH * 1.2f;
xr = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH + TILE_WIDTH * 1.2f;
}
}
else
{
if (timer > 0.0f)
{
xl = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH - TILE_WIDTH / 2
- 1.2f * ((timer / DOOR_OPEN_TIME) * TILE_WIDTH / 2);
xr = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH + TILE_WIDTH / 2
+ 1.2f * ((timer / DOOR_OPEN_TIME) * TILE_WIDTH / 2);
}
else
{
xl = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH - TILE_WIDTH /2;;
xr = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH + TILE_WIDTH /2;
}
}
// back
sprite.setTextureRect(sf::IntRect(3 * width, doorType * height, width * 3, height));
sprite.setPosition(OFFSET_X + (MAP_WIDTH / 2 - 1) * TILE_WIDTH, OFFSET_Y);
app->draw(sprite);
// door
sprite.setTextureRect(sf::IntRect(0.5f * width, doorType * height, width, height));
sprite.setPosition(xl, yl);
app->draw(sprite);
sprite.setTextureRect(sf::IntRect(1.5f * width, doorType * height, width, height));
sprite.setPosition(xr, yr);
app->draw(sprite);
// front
sprite.setTextureRect(sf::IntRect(6 * width, doorType * height, width * 3, height));
sprite.setPosition(OFFSET_X + (MAP_WIDTH / 2 - 1) * TILE_WIDTH, OFFSET_Y);
app->draw(sprite);
}
if (direction == 4)
{
xl = OFFSET_X;
xr = OFFSET_X;
if (isOpen)
{
if (timer > 0.0f)
{
yl = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT - TILE_HEIGHT / 2
- 1.2f * ((1.0f - (timer / DOOR_OPEN_TIME)) * TILE_HEIGHT / 2);
yr = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT + TILE_HEIGHT / 2
+ 1.2f * ((1.0f - (timer / DOOR_OPEN_TIME)) * TILE_HEIGHT / 2);
}
else
{
yl = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT - TILE_HEIGHT * 1.2f;
yr = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT + TILE_HEIGHT * 1.2f;
}
}
else
{
if (timer > 0.0f)
{
yl = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT - TILE_HEIGHT / 2
- 1.2f * ((timer / DOOR_OPEN_TIME) * TILE_HEIGHT / 2);
yr = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT + TILE_HEIGHT / 2
+ 1.2f * ((timer / DOOR_OPEN_TIME) * TILE_HEIGHT / 2);
}
else
{
yl = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT - TILE_HEIGHT /2;
yr = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT + TILE_HEIGHT /2;
}
}
// back
sprite.setTextureRect(sf::IntRect(width + (3 * width * doorType), 2 * height, width , height* 3));
sprite.setPosition(OFFSET_X + (MAP_WIDTH / 2 - 1) * TILE_WIDTH, OFFSET_Y);
sprite.setPosition(OFFSET_X, + (MAP_HEIGHT / 2 - 1) * TILE_HEIGHT + OFFSET_Y);
app->draw(sprite);
// door
sprite.setTextureRect(sf::IntRect( 3 * width * doorType, 2.5 * height, width, height));
sprite.setPosition(xl, yl);
app->draw(sprite);
sprite.setTextureRect(sf::IntRect( 3 * width * doorType, 3.5 * height, width, height));
sprite.setPosition(xr, yr);
app->draw(sprite);
// front
sprite.setTextureRect(sf::IntRect(2 * width + (3 * width * doorType), 2 * height, width , height* 3));
sprite.setPosition(OFFSET_X + (MAP_WIDTH / 2 - 1) * TILE_WIDTH, OFFSET_Y);
sprite.setPosition(OFFSET_X, + (MAP_HEIGHT / 2 - 1) * TILE_HEIGHT + OFFSET_Y);
app->draw(sprite);
}
if (direction == 2)
{
sprite.setRotation(0.0f);
yl = OFFSET_Y + TILE_HEIGHT * (MAP_HEIGHT - 1);
yr = OFFSET_Y + TILE_HEIGHT * (MAP_HEIGHT - 1);
if (isOpen)
{
if (timer > 0.0f)
{
xl = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH - TILE_WIDTH / 2
- 1.2f * ((1.0f - (timer / DOOR_OPEN_TIME)) * TILE_WIDTH / 2);
xr = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH + TILE_WIDTH / 2
+ 1.2f * ((1.0f - (timer / DOOR_OPEN_TIME)) * TILE_WIDTH / 2);
}
else
{
xl = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH - TILE_WIDTH * 1.2f;
xr = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH + TILE_WIDTH * 1.2f;
}
}
else
{
if (timer > 0.0f)
{
xl = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH - TILE_WIDTH / 2
- 1.2f * ((timer / DOOR_OPEN_TIME) * TILE_WIDTH / 2);
xr = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH + TILE_WIDTH / 2
+ 1.2f * ((timer / DOOR_OPEN_TIME) * TILE_WIDTH / 2);
}
else
{
xl = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH - TILE_WIDTH /2;;
xr = OFFSET_X + (MAP_WIDTH / 2 ) * TILE_WIDTH + TILE_WIDTH /2;
}
}
// back
sprite.setTextureRect(sf::IntRect(3 * width, (1 + doorType) * height, width * 3, -height));
sprite.setPosition(OFFSET_X + (MAP_WIDTH / 2 - 1) * TILE_WIDTH, yl);
app->draw(sprite);
// door
sprite.setTextureRect(sf::IntRect(0.5f * width, (1 + doorType) * height, width, -height));
sprite.setPosition(xl, yl);
app->draw(sprite);
sprite.setTextureRect(sf::IntRect(1.5f * width, (1 + doorType) * height, width, -height));
sprite.setPosition(xr, yr);
app->draw(sprite);
// front
sprite.setTextureRect(sf::IntRect(6 * width, (1 + doorType) * height, width * 3, -height));
sprite.setPosition(OFFSET_X + (MAP_WIDTH / 2 - 1) * TILE_WIDTH, yl);
//sprite.setRotation(angle);
app->draw(sprite);
}
if (direction == 6)
{
xl = OFFSET_X + TILE_WIDTH * (MAP_WIDTH - 1);
xr = OFFSET_X + TILE_WIDTH * (MAP_WIDTH - 1);
if (isOpen)
{
if (timer > 0.0f)
{
yl = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT - TILE_HEIGHT / 2
- 1.2f * ((1.0f - (timer / DOOR_OPEN_TIME)) * TILE_HEIGHT / 2);
yr = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT + TILE_HEIGHT / 2
+ 1.2f * ((1.0f - (timer / DOOR_OPEN_TIME)) * TILE_HEIGHT / 2);
}
else
{
yl = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT - TILE_HEIGHT * 1.2f;
yr = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT + TILE_HEIGHT * 1.2f;
}
}
else
{
if (timer > 0.0f)
{
yl = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT - TILE_HEIGHT / 2
- 1.2f * ((timer / DOOR_OPEN_TIME) * TILE_HEIGHT / 2);
yr = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT + TILE_HEIGHT / 2
+ 1.2f * ((timer / DOOR_OPEN_TIME) * TILE_HEIGHT / 2);
}
else
{
yl = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT - TILE_HEIGHT /2;
yr = OFFSET_Y + (MAP_HEIGHT / 2 ) * TILE_HEIGHT + TILE_HEIGHT /2;
}
}
// back
sprite.setTextureRect(sf::IntRect(width * 2 + (3 * width * doorType), 2 * height, -width , height* 3));
sprite.setPosition(xl + (MAP_WIDTH / 2 - 1) * TILE_WIDTH, OFFSET_Y);
sprite.setPosition(xl, + (MAP_HEIGHT / 2 - 1) * TILE_HEIGHT + OFFSET_Y);
app->draw(sprite);
// door
sprite.setTextureRect(sf::IntRect(1 * width + (3 * width * doorType), 2.5 * height, -width, height));
sprite.setPosition(xl, yl);
app->draw(sprite);
sprite.setTextureRect(sf::IntRect(1* width + (3 * width * doorType), 3.5 * height, -width, height));
sprite.setPosition(xr, yr);
app->draw(sprite);
// front
sprite.setTextureRect(sf::IntRect(3 * width + (3 * width * doorType), 2 * height, -width , height* 3));
sprite.setPosition(xl + (MAP_WIDTH / 2 - 1) * TILE_WIDTH, OFFSET_Y);
sprite.setPosition(xl, + (MAP_HEIGHT / 2 - 1) * TILE_HEIGHT + OFFSET_Y);
app->draw(sprite);
}
}
diff --git a/src/DungeonMap.cpp b/src/DungeonMap.cpp
index 5fbf2d2..53d624c 100644
--- a/src/DungeonMap.cpp
+++ b/src/DungeonMap.cpp
@@ -1,494 +1,503 @@
#include "DungeonMap.h"
#include "GameFloor.h"
#include "ItemEntity.h"
#include "ChestEntity.h"
#include "sfml_game/ImageManager.h"
#include <cstdlib>
#include <stdio.h>
#include <iostream>
DungeonMap::DungeonMap(int width, int height) : GameMap(width, height)
{
}
DungeonMap::DungeonMap(GameFloor* gameFloor, int x, int y) : GameMap(MAP_WIDTH, MAP_HEIGHT)
{
this->gameFloor = gameFloor;
this->x = x;
this->y = y;
cleared = false;
visited = false;
known = false;
}
DungeonMap::~DungeonMap()
{
//dtor
}
bool DungeonMap::isVisited()
{
return visited;
}
void DungeonMap::setVisited(bool b)
{
visited = b;
}
bool DungeonMap::isKnown()
{
return known;
}
void DungeonMap::setKnown(bool b)
{
known = b;
}
bool DungeonMap::isCleared()
{
return cleared;
}
void DungeonMap::setCleared(bool b)
{
cleared = b;
}
roomTypeEnum DungeonMap::getRoomType()
{
return roomType;
}
void DungeonMap::setRoomType(roomTypeEnum roomType)
{
this->roomType = roomType;
}
std::list<DungeonMap::itemListElement> DungeonMap::getItemList()
{
return (itemList);
}
std::list<DungeonMap::chestListElement> DungeonMap::getChestList()
{
return (chestList);
}
std::list<DungeonMap::spriteListElement> DungeonMap::getSpriteList()
{
return (spriteList);
}
void DungeonMap::displayToConsole()
{
for (int j=0; j < MAP_HEIGHT; j++)
{
for (int i=0; i < MAP_WIDTH; i++)
{
printf("%d", map[i][j]);
}
printf("\n");
}
printf("\n");
}
bool DungeonMap::isDownBlocking(int x, int y)
{
if (!inMap(x, y)) return false;
if (map[x][y] >= MAP_WALL) return true;
return false;
}
bool DungeonMap::isUpBlocking(int x, int y)
{
if (!inMap(x, y)) return false;
if (map[x][y] >= MAP_WALL) return true;
return false;
}
bool DungeonMap::isLeftBlocking(int x, int y)
{
if (!inMap(x, y)) return false;
if (map[x][y] >= MAP_WALL) return true;
return false;
}
bool DungeonMap::isRightBlocking(int x, int y)
{
if (!inMap(x, y)) return false;
if (map[x][y] >= MAP_WALL) return true;
return false;
}
bool DungeonMap::isWalkable(int x, int y)
{
if (!inMap(x, y)) return true;
return (map[x][y] < MAP_WALL);
}
bool DungeonMap::isFlyable(int x, int y)
{
if (x <= 0) return false;
if (x >= MAP_WIDTH - 1) return false;
if (y <= 0) return false;
if (y >= MAP_HEIGHT - 1) return false;
return true;
}
bool DungeonMap::isShootable(int x, int y)
{
if (!inMap(x, y)) return true;
return (map[x][y] < MAP_WALL);
}
void DungeonMap::randomize(int n)
{
int i, j;
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
initRoom();
// bonus
if (n == 5)
{
roomType = roomTypeBonus;
}
// others
else if (n > 0)
{
int r = rand() % 4;
if (r == 0) // corner blocks
{
map[1][1] = 4;
map[1][MAP_HEIGHT -2] = 4;
map[MAP_WIDTH - 2][1] = 4;
map[MAP_WIDTH - 2][MAP_HEIGHT -2] = 4;
}
else if (r == 1) // bloc in the middle
{
for (i = x0-1; i <= x0+1; i++)
for (j = y0-1; j <= y0+1; j++)
map[i][j] = 4;
}
else if (r == 2) // checker
{
for (i = 2; i < MAP_WIDTH - 2; i = i + 2)
for (j = 2; j < MAP_HEIGHT - 2; j = j + 2)
map[i][j] = 4;
}
cleared = false;
roomType = (roomTypeEnum)(rand() % 3);
}
else
{
cleared = true;
}
}
int DungeonMap::hasNeighbourLeft()
{
if (x > 0 && gameFloor->getRoom(x-1, y) > 0)
{
if (gameFloor->getRoom(x-1, y) == roomTypeBoss) return 2;
else return 1;
}
return 0;
}
int DungeonMap::hasNeighbourRight()
{
if (x < MAP_WIDTH -1 && gameFloor->getRoom(x+1, y) > 0)
{
if (gameFloor->getRoom(x+1, y) == roomTypeBoss) return 2;
else return 1;
}
return 0;
}
int DungeonMap::hasNeighbourUp()
{
if (y > 0 && gameFloor->getRoom(x, y-1) > 0)
{
if (gameFloor->getRoom(x, y-1) == roomTypeBoss) return 2;
else return 1;
}
return 0;
}
int DungeonMap::hasNeighbourDown()
{
if (y < MAP_HEIGHT -1 && gameFloor->getRoom(x, y+1) > 0)
{
if (gameFloor->getRoom(x, y+1) == roomTypeBoss) return 2;
else return 1;
}
return 0;
}
void DungeonMap::initRoom()
{
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
int i, j;
map[0][0] = MAP_WALL_7;
for ( i = 1 ; i < width -1 ; i++)
{
map[i][0] = MAP_WALL_8;
map[i][height - 1] = MAP_WALL_2;
}
map[width - 1][0] = MAP_WALL_9;
for ( int i = 1 ; i < height -1 ; i++)
{
map[0][i] = MAP_WALL_4;
map[width - 1][i] = MAP_WALL_6;
}
map[0][height - 1] = MAP_WALL_1;
map[width - 1][height - 1] = MAP_WALL_3;
for ( i = 1 ; i < width - 1 ; i++)
for ( j = 1 ; j < height - 1 ; j++)
{
map[i][j] = 0;
if (rand()%8 == 0) map[i][j] = rand()%(MAP_NORMAL_FLOOR + 1);
}
if (gameFloor != NULL)
{
if (x > 0 && gameFloor->getRoom(x-1, y) > 0)
{
//map[0][y0-1] = 0;
map[0][y0] = 0;
//map[0][y0+1] = 0;
}
if (x < MAP_WIDTH -1 && gameFloor->getRoom(x+1, y) > 0)
{
//map[MAP_WIDTH -1][y0-1] = 0;
map[MAP_WIDTH -1][y0] = 0;
//map[MAP_WIDTH -1][y0+1] = 0;
}
if (y > 0 && gameFloor->getRoom(x, y-1) > 0)
{
//map[x0-1][0] = 0;
map[x0][0] = 0;
//map[x0+1][0] = 0;
}
if (y < MAP_HEIGHT -1 && gameFloor->getRoom(x, y+1) > 0)
{
//map[x0-1][MAP_HEIGHT -1] = 0;
map[x0][MAP_HEIGHT -1] = 0;
//map[x0+1][MAP_HEIGHT -1] = 0;
}
}
}
Vector2D DungeonMap::generateBonusRoom()
{
initRoom();
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
map[x0 - 1][y0 - 1] = MAP_WALL;
map[x0 - 1][y0 + 1] = MAP_WALL;
map[x0 + 1][y0 - 1] = MAP_WALL;
map[x0 + 1][y0 + 1] = MAP_WALL;
return (Vector2D(OFFSET_X + x0 * TILE_WIDTH + TILE_WIDTH / 2, OFFSET_Y + y0 * TILE_HEIGHT + TILE_HEIGHT / 2));
}
void DungeonMap::generateCarpet(int x0, int y0, int w, int h, int n)
{
int xf = x0 + w - 1;
int yf = y0 + h - 1;
map[x0][y0] = n;
map[x0][yf] = n + 6;
map[xf][y0] = n + 2;
map[xf][yf] = n + 8;
int i, j;
for (i = x0 + 1; i <= xf - 1; i++)
{
map[i][y0] = n + 1;
map[i][yf] = n + 7;
for (j = y0 + 1; j <= yf - 1; j++)
map[i][j] = n + 4;
}
for (j = y0 + 1; j <= yf - 1; j++)
{
map[x0][j] = n + 3;
map[xf][j] = n + 5;
}
}
Vector2D DungeonMap::generateMerchantRoom()
{
initRoom();
int x0 = 3;
int y0 = 3;
generateCarpet(3, 3, 9, 3, 20);
return (Vector2D(OFFSET_X + x0 * TILE_WIDTH + TILE_WIDTH / 2, OFFSET_Y + y0 * TILE_HEIGHT + TILE_HEIGHT / 2));
}
Vector2D DungeonMap::generateKeyRoom()
{
initRoom();
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
for (int i = x0 - 1; i <= x0 + 1; i++)
for (int j = y0 - 1; j <= y0 + 1; j++)
map[i][j] = MAP_WALL;
map[x0][y0] = 0;
map[x0][y0+1] = MAP_DOOR;
return (Vector2D(OFFSET_X + x0 * TILE_WIDTH + TILE_WIDTH / 2, OFFSET_Y + y0 * TILE_HEIGHT + TILE_HEIGHT / 2));
}
+void DungeonMap::generateExitRoom()
+{
+ initRoom();
+ int x0 = MAP_WIDTH / 2;
+ map[x0][0] = MAP_STAIRS_UP;
+ map[x0 - 1][0] = 40;
+ map[x0 + 1][0] = 41;
+}
+
void DungeonMap::generateRoom(int type)
{
initRoom();
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
int i, j, r;
if (type == 0)
{
if (roomType == roomTypeStarting)
generateCarpet(5, 3, 5, 3, 30);
}
if (type == 1)
{
// corner block
map[1][1] = MAP_WALL;
map[1][MAP_HEIGHT -2] = MAP_WALL;
map[MAP_WIDTH - 2][1] = MAP_WALL;
map[MAP_WIDTH - 2][MAP_HEIGHT -2] = MAP_WALL;
}
if (type == 2)
{
r = 1 + rand() % 3;
for (i = x0 - r; i <= x0 + r; i++)
for (j = y0 - 1; j <= y0 + 1; j++)
map[i][j] = MAP_WALL;
}
}
void DungeonMap::addItem(int itemType, float x, float y, bool merch)
{
itemListElement ilm;
ilm.type = itemType;
ilm.x = x;
ilm.y = y;
ilm.merch = merch;
itemList.push_back(ilm);
}
void DungeonMap::addSprite(int spriteType, int frame, float x, float y, float scale)
{
spriteListElement slm;
slm.type = spriteType;
slm.frame = frame;
slm.x = x;
slm.y = y;
slm.scale = scale;
spriteList.push_back(slm);
}
void DungeonMap::addChest(int chestType, bool state, float x, float y)
{
chestListElement clm;
clm.type = chestType;
clm.state = state;
clm.x = x;
clm.y = y;
chestList.push_back(clm);
}
void DungeonMap::restoreItems()
{
ItemList::iterator it;
for (it = itemList.begin (); it != itemList.end ();)
{
itemListElement ilm = *it;
it++;
ItemEntity* itemEntity = new ItemEntity((enumItemType)(ilm.type), ilm.x, ilm.y);
itemEntity->setMerchandise(ilm.merch);
}
itemList.clear();
}
void DungeonMap::restoreSprites()
{
SpriteList::iterator it;
for (it = spriteList.begin (); it != spriteList.end ();)
{
spriteListElement ilm = *it;
it++;
if (ilm.type == ENTITY_BLOOD)
{
SpriteEntity* blood = new SpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_BLOOD), ilm.x, ilm.y, 16, 16, 6);
blood->setZ(OFFSET_Y - 1);
blood->setFrame(ilm.frame);
blood->setType(ENTITY_BLOOD);
blood->setScale(ilm.scale, ilm.scale);
}
else if (ilm.type == ENTITY_CORPSE)
{
SpriteEntity* corpse;
if (ilm.frame >= FRAME_CORPSE_KING_RAT)
{
corpse = new SpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_CORPSES_BIG), ilm.x, ilm.y, 128, 128);
corpse->setFrame(ilm.frame - FRAME_CORPSE_KING_RAT);
}
else
{
corpse = new SpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_CORPSES), ilm.x, ilm.y, 64, 64);
corpse->setFrame(ilm.frame);
}
corpse->setZ(OFFSET_Y);
corpse->setType(ENTITY_CORPSE);
}
}
spriteList.clear();
}
void DungeonMap::restoreChests()
{
ChestList::iterator it;
for (it = chestList.begin (); it != chestList.end ();)
{
chestListElement clm = *it;
it++;
new ChestEntity(clm.x, clm.y, clm.type, clm.state);
}
chestList.clear();
}
void DungeonMap::restoreMapObjects()
{
restoreItems();
restoreSprites();
restoreChests();
}
diff --git a/src/DungeonMap.h b/src/DungeonMap.h
index 2492893..7b833f5 100644
--- a/src/DungeonMap.h
+++ b/src/DungeonMap.h
@@ -1,109 +1,111 @@
#ifndef MAGICMAP_H
#define MAGICMAP_H
#include "sfml_game/GameMap.h"
#include "sfml_game/MyTools.h"
#include <list>
const int MAP_NORMAL_FLOOR = 3;
+const int MAP_STAIRS_UP = 39;
const int MAP_WALL = 50;
const int MAP_DOOR = 51;
const int MAP_WALL_7 = 52;
const int MAP_WALL_8 = 53;
const int MAP_WALL_9 = 54;
const int MAP_WALL_4 = 55;
const int MAP_WALL_6 = 56;
const int MAP_WALL_1 = 57;
const int MAP_WALL_2 = 58;
const int MAP_WALL_3 = 59;
class GameFloor;
enum roomTypeEnum
{
roomTypeNULL,
roomTypeStandard,
roomTypeBoss,
roomTypeMerchant,
roomTypeKey,
roomTypeBonus,
roomTypeExit,
roomTypeStarting
};
class DungeonMap : public GameMap
{
public:
DungeonMap(int width, int height);
DungeonMap(GameFloor* gameFloor, int x, int y);
virtual ~DungeonMap();
void displayToConsole();
bool isVisited();
void setVisited(bool b);
bool isKnown();
void setKnown(bool b);
bool isCleared();
void setCleared(bool b);
bool isWalkable(int x, int y);
bool isFlyable(int x, int y);
bool isShootable(int x, int y);
// 0 == no, 1 == yes, 2 == boss
int hasNeighbourLeft();
int hasNeighbourRight();
int hasNeighbourUp();
int hasNeighbourDown();
virtual bool isDownBlocking(int x, int y);
virtual bool isUpBlocking(int x, int y);
virtual bool isLeftBlocking(int x, int y);
virtual bool isRightBlocking(int x, int y);
virtual void randomize(int n);
void initRoom();
void generateCarpet(int x0, int y0, int w, int h, int n);
void generateRoom(int type);
+ void generateExitRoom();
Vector2D generateBonusRoom();
Vector2D generateMerchantRoom();
Vector2D generateKeyRoom();
void addItem(int itemType, float x, float y, bool merch);
void addSprite(int spriteType, int frame, float x, float y, float scale);
void addChest(int chestType, bool state, float x, float y);
void restoreItems();
void restoreSprites();
void restoreChests();
void restoreMapObjects();
roomTypeEnum getRoomType();
void setRoomType(roomTypeEnum roomType);
struct itemListElement { int type; float x; float y; bool merch; };
typedef std::list<itemListElement> ItemList;
struct spriteListElement { int type; int frame; float x; float y; float scale;};
typedef std::list<spriteListElement> SpriteList;
struct chestListElement { int type; bool state; float x; float y;};
typedef std::list<chestListElement> ChestList;
std::list<itemListElement> getItemList();
std::list<chestListElement> getChestList();
std::list<spriteListElement> getSpriteList();
protected:
private:
GameFloor* gameFloor;
int x, y;
bool visited;
bool known;
bool cleared;
roomTypeEnum roomType;
ItemList itemList;
SpriteList spriteList;
ChestList chestList;
};
#endif // MAGICMAP_H

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 11:29 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68764
Default Alt Text
(23 KB)

Event Timeline