Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126410
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
23 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/BaseCreatureEntity.cpp b/src/BaseCreatureEntity.cpp
index fb380f3..cbc4465 100644
--- a/src/BaseCreatureEntity.cpp
+++ b/src/BaseCreatureEntity.cpp
@@ -1,149 +1,177 @@
#include "BaseCreatureEntity.h"
#include "sfml_game/ImageManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
BaseCreatureEntity::BaseCreatureEntity(sf::Texture* image, float x = 0.0f, float y = 0.0f, int spriteWidth = -1, int spriteHeight = -1)
: CollidingSpriteEntity (image, x, y, spriteWidth, spriteHeight )
{
hurting = false;
hurtingType = ShotTypeStandard;
shadowFrame = -1;
setMap(game().getCurrentMap(), TILE_WIDTH, TILE_HEIGHT, OFFSET_X, OFFSET_Y);
hpDisplay = 0;
+ movingStyle = movWalking;
for (int i = 0; i < NB_SPECIAL_STATES; i++)
{
specialState[i].type = (enumSpecialState)i;
specialState[i].resistance = ResistanceStandard;
specialState[i].active = false;
specialState[i].timer = 0.0f;
}
}
int BaseCreatureEntity::getHp()
{
return hp;
}
int BaseCreatureEntity::getHpMax()
{
return hpMax;
}
void BaseCreatureEntity::setHp(int hp)
{
this->hp = hp;
}
void BaseCreatureEntity::setHpMax(int hpMax)
{
this->hpMax = hpMax;
}
int BaseCreatureEntity::getHpDisplay()
{
return hpDisplay;
}
void BaseCreatureEntity::animate(float delay)
{
if (hpDisplay > hp) hpDisplay--;
else if (hpDisplay < hp) hpDisplay++;
for (int i = 0; i < NB_SPECIAL_STATES; i++)
{
if (specialState[i].active)
{
specialState[i].timer -= delay;
if (specialState[i].timer <= 0.0f) specialState[i].active = false;
}
}
if (specialState[SpecialStateIce].active) delay *= STATUS_FROZEN_MULT;
z = y + height/2;
sprite.setColor(sf::Color(255, 255, 255, 255 ));
if (hurting)
{
hurtingDelay -= delay;
if (hurtingDelay > 0.0f)
{
int fadeColor = (sf::Uint8)((HURTING_DELAY - hurtingDelay) * 255);
if (hurtingType == ShotTypeIce)
sprite.setColor(sf::Color(fadeColor, fadeColor, 255, 255 ));
else
sprite.setColor(sf::Color(255, fadeColor, fadeColor, 255 ));
}
else
{
hurting = false;
sprite.setColor(sf::Color(255, 255, 255, 255 ));
}
}
CollidingSpriteEntity::animate(delay);
if (specialState[SpecialStateIce].active) sprite.setColor(sf::Color(100, 100, 255, 255 ));
}
void BaseCreatureEntity::render(sf::RenderWindow* app)
{
if (!isDying && shadowFrame > -1)
{
// shadow
sprite.setTextureRect(sf::IntRect(shadowFrame * width, 0, width, height));
app->draw(sprite);
}
CollidingSpriteEntity::render(app);
#ifdef SHOW_BOUNDING_BOX
sf::Vertex line[] =
{
sf::Vertex(sf::Vector2f(boundingBox.left, boundingBox.top)),
sf::Vertex(sf::Vector2f(boundingBox.left + boundingBox.width, boundingBox.top)),
sf::Vertex(sf::Vector2f(boundingBox.left + boundingBox.width, boundingBox.top)),
sf::Vertex(sf::Vector2f(boundingBox.left + boundingBox.width, boundingBox.top + boundingBox.height)),
sf::Vertex(sf::Vector2f(boundingBox.left + boundingBox.width, boundingBox.top + boundingBox.height)),
sf::Vertex(sf::Vector2f(boundingBox.left, boundingBox.top + boundingBox.height)),
sf::Vertex(sf::Vector2f(boundingBox.left, boundingBox.top + boundingBox.height)),
sf::Vertex(sf::Vector2f(boundingBox.left, boundingBox.top))
};
app->draw(line, 8, sf::Lines);
#endif
}
void BaseCreatureEntity::calculateBB()
{
}
+bool BaseCreatureEntity::collideWithMap(int direction)
+{
+ calculateBB();
+
+ int xTile0 = (boundingBox.left - offsetX) / tileWidth;
+ int xTilef = (boundingBox.left + boundingBox.width - offsetX) / tileWidth;
+ int yTile0 = (boundingBox.top - offsetY) / tileHeight;
+ int yTilef = (boundingBox.top + boundingBox.height - offsetY) / tileHeight;
+
+ if (boundingBox.top < 0) yTile0 = -1;
+
+ for (int xTile = xTile0; xTile <= xTilef; xTile++)
+ for (int yTile = yTile0; yTile <= yTilef; yTile++)
+ {
+ if (movingStyle == movWalking)
+ {
+ if ( dynamic_cast<DungeonMap*>(map)->isWalkable(xTile, yTile) == false ) return true;
+ }
+ else if (movingStyle == movFlying)
+ {
+ if ( dynamic_cast<DungeonMap*>(map)->isFlyable(xTile, yTile) == false ) return true;
+ }
+ }
+
+ return false;
+}
+
bool BaseCreatureEntity::hurt(int damages, enumShotType hurtingType)
{
hurting = true;
hurtingDelay = HURTING_DELAY;
this->hurtingType = hurtingType;
if (hurtingType == ShotTypeIce && specialState[SpecialStateIce].resistance > ResistanceImmune)
{
specialState[SpecialStateIce].active = true;
specialState[SpecialStateIce].timer = STATUS_FROZEN_DELAY;
}
hp -= damages;
if (hp <= 0)
{
hp = 0;
prepareDying();
}
return true;
}
void BaseCreatureEntity::prepareDying()
{
dying();
}
void BaseCreatureEntity::dying()
{
isDying = true;
}
diff --git a/src/BaseCreatureEntity.h b/src/BaseCreatureEntity.h
index 69c8db1..e22f4a9 100644
--- a/src/BaseCreatureEntity.h
+++ b/src/BaseCreatureEntity.h
@@ -1,53 +1,56 @@
#ifndef BASECREATUREENTITY_H
#define BASECREATUREENTITY_H
#include "sfml_game/CollidingSpriteEntity.h"
#include "Constants.h"
const int NB_SPECIAL_STATES = 1;
class BaseCreatureEntity : public CollidingSpriteEntity
{
public:
BaseCreatureEntity(sf::Texture* image, float x, float y, int spriteWidth, int spriteHeight);
int getHp();
int getHpMax();
void setHp(int hp);
void setHpMax(int hpMax);
int getHpDisplay();
virtual void animate(float delay);
virtual void render(sf::RenderWindow* app);
virtual void calculateBB();
+ virtual bool collideWithMap(int direction);
virtual bool hurt(int damages, enumShotType hurtingType);
virtual void prepareDying();
virtual void dying();
+ enum enumMovingStyle { movWalking, movFlying};
enum enumBloodColor { bloodRed, bloodGreen};
enum enumSpecialState
{
SpecialStateIce // = 0
};
enum enumStateResistance { ResistanceImmune, ResistanceResistant, ResistanceStandard, ResistanceLow, ResistanceVeryLow};
struct itemStuct
{
enumSpecialState type;
enumStateResistance resistance;
bool active;
float timer;
};
itemStuct specialState[NB_SPECIAL_STATES];
protected:
int hp;
int hpMax;
int hpDisplay;
float creatureSpeed;
int shadowFrame;
bool hurting;
float hurtingDelay;
enumShotType hurtingType;
enumBloodColor bloodColor;
+ enumMovingStyle movingStyle;
private:
};
#endif // BASECREATUREENTITY_H
diff --git a/src/BatEntity.cpp b/src/BatEntity.cpp
index 47a9c16..daf29d9 100644
--- a/src/BatEntity.cpp
+++ b/src/BatEntity.cpp
@@ -1,124 +1,81 @@
#include "BatEntity.h"
#include "PlayerEntity.h"
#include "sfml_game/SpriteEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
BatEntity::BatEntity(float x, float y)
: EnnemyEntity (ImageManager::getImageManager()->getImage(IMAGE_BAT), x, y)
{
creatureSpeed = BAT_SPEED;
velocity = Vector2D(creatureSpeed);
hp = BAT_HP;
meleeDamages = BAT_DAMAGES;
type = ENTITY_ENNEMY;
bloodColor = bloodRed;
changingDelay = -0.5f;
shadowFrame = 3;
+ movingStyle = movFlying;
}
void BatEntity::animate(float delay)
{
changingDelay -= delay;
if (changingDelay < 0.0f)
{
velocity = Vector2D(creatureSpeed);
changingDelay = 0.5f + (float)(rand() % 2500) / 1000.0f;
}
if (age < 0.0f)
frame = 1;
else
frame = ((int)(age * 5.0f)) % 2;
testSpriteCollisions();
EnnemyEntity::animate(delay);
}
void BatEntity::calculateBB()
{
boundingBox.left = (int)x - width / 2 + BAT_BB_LEFT;
boundingBox.width = width - BAT_BB_WIDTH_DIFF;
boundingBox.top = (int)y - height / 2 + BAT_BB_TOP;
boundingBox.height = height - BAT_BB_HEIGHT_DIFF;
}
void BatEntity::collideMapRight()
{
- // if (x > OFFSET_X + MAP_WIDTH * TILE_WIDTH)
velocity.x = -velocity.x;
}
void BatEntity::collideMapLeft()
{
- // if (x < OFFSET_X + MAP_WIDTH )
velocity.x = -velocity.x;
}
void BatEntity::collideMapTop()
{
-// if (y > OFFSET_Y + MAP_HEIGHT * TILE_HEIGHT)
velocity.y = -velocity.y;
}
void BatEntity::collideMapBottom()
{
- // if (y < OFFSET_Y + MAP_HEIGHT )
velocity.y = -velocity.y;
}
-bool BatEntity::collideWithMap(int direction)
-{
- calculateBB();
-
- int xTile0 = (boundingBox.left - offsetX) / tileWidth;
- int xTilef = (boundingBox.left + boundingBox.width - offsetX) / tileWidth;
- int yTile0 = (boundingBox.top - offsetY) / tileHeight;
- int yTilef = (boundingBox.top + boundingBox.height - offsetY) / tileHeight;
-
- if (boundingBox.top < 0) yTile0 = -1;
-
- for (int xTile = xTile0; xTile <= xTilef; xTile++)
- for (int yTile = yTile0; yTile <= yTilef; yTile++)
- {
- if (xTile == 0 || xTile == MAP_WIDTH - 1 || yTile == 0 || yTile == MAP_HEIGHT - 1)
- {
- switch (direction)
- {
- case DIRECTION_LEFT:
- if (map->isLeftBlocking(xTile, yTile)) return true;
- break;
-
- case DIRECTION_RIGHT:
- if (map->isRightBlocking(xTile, yTile)) return true;
- break;
-
- case DIRECTION_TOP:
- if (map->isUpBlocking(xTile, yTile)) return true;
- break;
-
- case DIRECTION_BOTTOM:
- if (map->isDownBlocking(xTile, yTile)) return true;
- break;
- }
- }
- }
-
- return false;
-}
-
void BatEntity::dying()
{
isDying = true;
SpriteEntity* deadBat = new SpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_CORPSES), x, y, 64, 64);
deadBat->setZ(OFFSET_Y);
deadBat->setFrame(FRAME_CORPSE_BAT);
deadBat->setType(ENTITY_CORPSE);
for (int i = 0; i < 4; i++) game().generateBlood(x, y, bloodColor);
drop();
SoundManager::getSoundManager()->playSound(SOUND_ENNEMY_DYING);
}
diff --git a/src/BatEntity.h b/src/BatEntity.h
index 27208e6..6bf571b 100644
--- a/src/BatEntity.h
+++ b/src/BatEntity.h
@@ -1,25 +1,24 @@
#ifndef BATSPRITE_H
#define BATSPRITE_H
#include "EnnemyEntity.h"
class BatEntity : public EnnemyEntity
{
public:
BatEntity(float x, float y);
virtual void animate(float delay);
virtual void calculateBB();
protected:
- virtual bool collideWithMap(int direction);
virtual void collideMapRight();
virtual void collideMapLeft();
virtual void collideMapTop();
virtual void collideMapBottom();
virtual void dying();
private:
float changingDelay;
};
#endif // BATSPRITE_H
diff --git a/src/DungeonMap.cpp b/src/DungeonMap.cpp
index 2f2d35b..5fbf2d2 100644
--- a/src/DungeonMap.cpp
+++ b/src/DungeonMap.cpp
@@ -1,478 +1,494 @@
#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::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 13a6985..2492893 100644
--- a/src/DungeonMap.h
+++ b/src/DungeonMap.h
@@ -1,107 +1,109 @@
#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_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);
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
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 11:31 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68779
Default Alt Text
(23 KB)
Attached To
Mode
R78 witchblast
Attached
Detach File
Event Timeline