Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F133956
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
16 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/DungeonMap.h b/src/DungeonMap.h
index 66ea408..35fdcc7 100644
--- a/src/DungeonMap.h
+++ b/src/DungeonMap.h
@@ -1,280 +1,281 @@
#ifndef MAGICMAP_H
#define MAGICMAP_H
#include "sfml_game/GameMap.h"
#include "sfml_game/MyTools.h"
#include "Constants.h"
#include "DoorEntity.h"
#include <list>
const int MAPOBJ_NONE = 0;
const int MAPOBJ_DOOR_OPEN = 1;
const int MAPOBJ_DOOR_CLOSED = 2;
const int MAPOBJ_OBSTACLE = 10;
const int MAPOBJ_BIG_OBSTACLE = 40;
const int MAPOBJ_TOMB = 49;
const int MAPOBJ_WALL_SPECIAL = 14;
const int MAPOBJ_GRID = 19;
const int MAPOBJ_BANK_TOP = 18;
const int MAPOBJ_BANK = 28;
const int MAPOBJ_BANK_BOTTOM = 38;
const int MAPOBJ_CHURCH_FURN_R = 29;
const int MAPOBJ_CHURCH_FURN_L = 39;
const int MAPOBJ_LONG_LEFT = 50;
const int MAPOBJ_LONG = 51;
const int MAPOBJ_LONG_RIGHT = 52;
const int MAPOBJ_PNW = 60;
const int MAPOBJ_HOLE = 3;
const int MAPOBJ_HOLE_TOP = MAPOBJ_HOLE;
const int MAPOBJ_HOLE_BOTTOM = MAPOBJ_HOLE + 1;
const int MAPOBJ_HOLE_LEFT = MAPOBJ_HOLE + 2;
const int MAPOBJ_HOLE_RIGHT = MAPOBJ_HOLE + 3;
const int MAPOBJ_TEMPLE_WALL = 20;
const int MAPOBJ_SHOP_BEGIN = 11;
const int MAPOBJ_SHOP_LEFT = 0 + MAPOBJ_SHOP_BEGIN;
const int MAPOBJ_SHOP = 1 + MAPOBJ_SHOP_BEGIN;
const int MAPOBJ_SHOP_RIGHT = 2 + MAPOBJ_SHOP_BEGIN;
-const int MAPOBJ_BARREL = 1000;
-const int MAPOBJ_BARREL_EXPL = 1003;
+const int MAPOBJ_BARREL = 1000;
+const int MAPOBJ_BARREL_NO_DROP = 1010;
+const int MAPOBJ_BARREL_EXPL = 1020;
const int MAP_NORMAL_FLOOR = 8;
const int MAP_NB_FLOORS = 10;
const int MAP_TEMPLE = MAP_NB_FLOORS * 24;
const int MAP_CARPET = MAP_TEMPLE + 8;
const int MAP_WALL_BEGIN = (MAP_NB_FLOORS + 3) * 24;
// walls
const int MAP_WALL_X = MAP_WALL_BEGIN - 1;
const int MAP_WALL_8 = 0 + MAP_WALL_BEGIN;
const int MAP_WALL_7 = 2 + MAP_WALL_BEGIN;
const int MAP_WALL_77 = 4 + MAP_WALL_BEGIN;
const int MAP_WALL_87 = 5 + MAP_WALL_BEGIN;
const int DOOR_WALL_SPRITE_X = 1344;
const int DOOR_WALL_SPRITE_Y = (MAP_NB_FLOORS + 3) * 64;
const int DOOR_GRID_SPRITE_X = 1280;
const int DOOR_GRID_SPRITE_Y = (MAP_NB_FLOORS + 2) * 64;
const int DOOR_STAIRS_SPRITE_X = 1088;
const int DOOR_STAIRS_SPRITE_Y = DOOR_GRID_SPRITE_Y;
const int DOOR_SHADOW_SPRITE_X = 896;
const int DOOR_SHADOW_SPRITE_Y = DOOR_GRID_SPRITE_Y;
const int ROOM_TYPE_CHECKER = 5;
const int ROOM_TYPE_ALL = 6;
enum logicalMapStateEnum
{
LogicalFloor,
LogicalWall,
LogicalObstacle,
LogicalHole,
LogicalDestroyable,
};
class GameFloor;
enum roomTypeEnum
{
roomTypeNULL,
roomTypeStandard,
roomTypeBoss,
roomTypeMerchant,
roomTypeKey,
roomTypeBonus,
roomTypeExit,
roomTypeStarting,
roomTypeChallenge,
roomTypeTemple
};
enum positionDirection
{
North, West, South, East,
};
struct randomDungeonTileStruct
{
int width;
int height;
int xOffset;
int yOffset;
bool canRotate;
bool canBeOnWall;
bool randomPlace;
int rarity;
};
const int NB_RANDOM_TILES = 21;
const int NB_RANDOM_TILE_TRY = 40;
const int NB_RANDOM_TILES_IN_ROOM = 4;
/** Array with all the items and data */
const randomDungeonTileStruct randomDungeonTiles[NB_RANDOM_TILES] =
{
{ 192, 192, 0, 0, true, true, true, 1},
{ 192, 192, 192, 0, true, true, true, 1},
{ 192, 192, 384, 0, true, true, true, 1},
{ 192, 192, 576, 0, true, true, true, 1},
{ 256, 256, 0, 192, true, true, true, 1},
{ 512, 256, 256, 192, true, true, true, 1},
{ 128, 128, 0, 448, true, false, true, 6},
{ 128, 128, 128, 448, true, false, true, 3},
{ 128, 128, 256, 448, true, false, true, 3},
{ 128, 128, 384, 448, false, false, false, 1},
{ 128, 128, 512, 448, false, false, false, 6},
{ 128, 128, 640, 448, false, false, false, 6},
{ 192, 192, 0, 576, true, true, true, 1},
{ 192, 192, 192, 576, true, true, true, 1},
{ 192, 192, 384, 576, true, true, true , 1},
{ 192, 192, 576, 576, true, true, true, 1},
{ 256, 256, 0, 768, true, true, true, 1},
{ 256, 256, 256, 768, true, true, true, 1},
{ 256, 192, 768, 0, true, true, true, 1},
{ 256, 192, 768, 192, true, true, true, 1},
{ 256, 192, 768, 384, true, true, true, 1},
};
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);
int getObjectTile(int x, int y);
logicalMapStateEnum getLogicalTile(int x, int y);
void setObjectTile(int x, int y, int n);
void setLogicalTile(int x, int y, logicalMapStateEnum state);
int getDivinity(int x, int y);
bool containsHealth();
roomTypeEnum getNeighbourLeft();
roomTypeEnum getNeighbourRight();
roomTypeEnum getNeighbourUp();
roomTypeEnum getNeighbourDown();
// 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);
doorEnum getDoorType(int direction);
void setDoorType(int direction, doorEnum type);
virtual void randomize(int n);
void initRoom(int floorN = -1, int wallN = -1);
enum patternEnum { PatternSmallChecker, PatternBigChecker, PatternBorder, PatternBigCircle, PatternSmallCircle, PatternSmallStar, PatternSmallDisc};
void initPattern(patternEnum n);
void generateCarpet(int x0, int y0, int w, int h, int n);
void generateTable(int x0, int y0, int w, int h, int n);
void generateLongObject(int x0, int y0, int w, int n);
void generateRoomRandom(int type);
void generateRoomWithoutHoles(int type);
void generateRoomWithHoles(int type);
void generateExitRoom();
Vector2D generateBonusRoom();
Vector2D generateChestRoom();
Vector2D generateMerchantRoom();
Vector2D generateKeyRoom();
void generateTemple(int x, int y, enumDivinityType type);
void generateTempleRoom();
void generateInselRoom();
void addRandomGrids(int n);
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 restoreMapObjects();
void cleanMapObjects();
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();
struct RandomTileElement { int type; float x; float y; float rotation;};
RandomTileElement getRandomTileElement(int n);
void setRandomTileElement (int n, RandomTileElement rt);
void openDoor(int x, int y);
void closeDoor(int x, int y);
bool isDoor(int x, int y);
int getFloorOffset();
int getWallType();
void setFloorOffset(int n);
void setWallType(int n);
protected:
private:
GameFloor* gameFloor;
int x, y;
bool visited;
bool known;
bool cleared;
int objectsMap[MAP_WIDTH][MAP_HEIGHT];
logicalMapStateEnum logicalMap[MAP_WIDTH][MAP_HEIGHT];
roomTypeEnum roomType;
ItemList itemList;
SpriteList spriteList;
ChestList chestList;
RandomTileElement randomTileElements[NB_RANDOM_TILES_IN_ROOM];
void generateCorridors();
void generateRandomTile(int index);
void generateRandomTiles();
void restoreItems();
void restoreSprites();
void restoreChests();
void makePatternTile(int x, int y);
void addHole(int x, int y);
int floorOffset;
int wallType;
doorEnum doorType[4];
};
#endif // MAGICMAP_H
diff --git a/src/ObstacleEntity.cpp b/src/ObstacleEntity.cpp
index d2c9746..f415359 100644
--- a/src/ObstacleEntity.cpp
+++ b/src/ObstacleEntity.cpp
@@ -1,198 +1,193 @@
#include "BoltEntity.h"
#include "EnemyBoltEntity.h"
#include "ExplosionEntity.h"
#include "sfml_game/SpriteEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
#include "ObstacleEntity.h"
ObstacleEntity::ObstacleEntity(float x, float y, int objectFrame)
: EnemyEntity (ImageManager::getInstance().getImage(IMAGE_DESTROYABLE), x, y)
{
imagesProLine = 3;
type = ENTITY_ENEMY_NC;
enemyType = EnemyTypeDestroyable;
movingStyle = movWalking;
explosive = false;
dyingSound = SOUND_BARREL_SMASH;
hurtingSound = SOUND_BARREL_HIT;
bloodColor = BloodNone;
obstacleBloodType = BloodBarrel;
+ deathFrame = FRAME_CORPSE_BARREL;
age = 0.0f;
frame = 0;
+ objectIndex = objectFrame;
xGrid = x / TILE_WIDTH;
yGrid = y / TILE_HEIGHT;
game().getCurrentMap()->setObjectTile(xGrid, yGrid, objectFrame);
game().getCurrentMap()->setLogicalTile(xGrid, yGrid, LogicalDestroyable);
- switch (objectFrame)
+ // hp
+ if (objectIndex == MAPOBJ_BARREL || objectIndex == MAPOBJ_BARREL_NO_DROP || objectIndex == MAPOBJ_BARREL_EXPL)
{
- //standard barrel
- case MAPOBJ_BARREL:
hp = 18;
hpMax = 18;
- initialFrame = 0;
- deathFrame = FRAME_CORPSE_BARREL;
- break;
- case MAPOBJ_BARREL + 1:
+ }
+ else if (objectIndex == MAPOBJ_BARREL + 1 || objectIndex == MAPOBJ_BARREL_NO_DROP + 1|| objectIndex == MAPOBJ_BARREL_EXPL + 1)
+ {
hp = 12;
hpMax = 12;
- initialFrame = 0;
- frame = 1;
- deathFrame = FRAME_CORPSE_BARREL;
- break;
- case MAPOBJ_BARREL + 2:
+ }
+ else if (objectIndex == MAPOBJ_BARREL + 2 || objectIndex == MAPOBJ_BARREL_NO_DROP + 2|| objectIndex == MAPOBJ_BARREL_EXPL + 2)
+ {
hp = 6;
hpMax = 6;
- initialFrame = 0;
- frame = 2;
- deathFrame = FRAME_CORPSE_BARREL;
- break;
+ }
- //powder barrel
- case MAPOBJ_BARREL_EXPL:
- hp = 18;
- hpMax = 18;
- initialFrame = 3;
- frame = 3;
- deathFrame = FRAME_CORPSE_SLIME_VIOLET;
- explosive = true;
+ if (objectIndex >= MAPOBJ_BARREL_EXPL && objectIndex < MAPOBJ_BARREL_EXPL + 3)
+ {
obstacleBloodType = BloodBarrelPowder;
- break;
-
- case MAPOBJ_BARREL_EXPL + 1:
- hp = 12;
- hpMax = 12;
- initialFrame = 3;
- frame = 4;
deathFrame = FRAME_CORPSE_SLIME_VIOLET;
explosive = true;
- obstacleBloodType = BloodBarrelPowder;
- break;
- case MAPOBJ_BARREL_EXPL + 2:
- hp = 6;
- hpMax = 6;
initialFrame = 3;
- frame = 5;
- deathFrame = FRAME_CORPSE_SLIME_VIOLET;
- explosive = true;
- obstacleBloodType = BloodBarrelPowder;
- break;
-
- default:
- std::cout << "ERROR: unknown obstacle (" << objectFrame << ")\n";
- isDying = true;
- break;
+ initialObjectIndex = MAPOBJ_BARREL_EXPL;
+ frame = 3 + objectIndex - MAPOBJ_BARREL_EXPL;
+ }
+ else if (objectIndex >= MAPOBJ_BARREL && objectIndex < MAPOBJ_BARREL + 3)
+ {
+ initialFrame = 0;
+ initialObjectIndex = MAPOBJ_BARREL;
+ frame = objectIndex - MAPOBJ_BARREL;
+ }
+ else if (objectIndex >= MAPOBJ_BARREL_NO_DROP && objectIndex < MAPOBJ_BARREL_NO_DROP + 3)
+ {
+ initialFrame = 0;
+ initialObjectIndex = MAPOBJ_BARREL_NO_DROP;
+ frame = objectIndex - MAPOBJ_BARREL_NO_DROP;
}
resistance[ResistanceFrozen] = ResistanceImmune;
resistance[ResistanceRecoil] = ResistanceImmune;
resistance[ResistanceFire] = ResistanceVeryLow;
resistance[ResistancePoison] = ResistanceImmune;
canExplode = false;
}
+int ObstacleEntity::getObjectIndex()
+{
+ return objectIndex;
+}
+
void ObstacleEntity::animate(float delay)
{
testSpriteCollisions();
}
void ObstacleEntity::render(sf::RenderTarget* app)
{
EnemyEntity::render(app);
}
void ObstacleEntity::dying()
{
EnemyEntity::dying();
game().getCurrentMap()->setObjectTile(xGrid, yGrid, 0);
game().getCurrentMap()->setLogicalTile(xGrid, yGrid, LogicalFloor);
for (int i = 0; i < 10; i++)
game().generateBlood(x, y, obstacleBloodType);
if (explosive)
{
new ExplosionEntity(x, y, ExplosionTypeStandard, 16, EnemyTypeNone, true);
SoundManager::getInstance().playSound(SOUND_BOOM_00);
}
}
void ObstacleEntity::calculateBB()
{
boundingBox.left = (int)x - 30;
boundingBox.width = 60;
boundingBox.top = (int)y - 30;
boundingBox.height = 60;
}
void ObstacleEntity::drop()
{
- EnemyEntity::drop();
+ if (initialObjectIndex == MAPOBJ_BARREL)
+ EnemyEntity::drop();
}
void ObstacleEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
if (entity == this) return;
if (!isDying && !isAgonising && collideWithEntity(entity))
{
if (entity->getType() == ENTITY_BOLT )
{
BoltEntity* boltEntity = dynamic_cast<BoltEntity*>(entity);
if (!boltEntity->getDying() && boltEntity->getAge() > 0.05f)
{
EnemyEntity::collideWithBolt(boltEntity);
correctFrame();
}
}
else if (entity->getType() == ENTITY_ENEMY_BOLT )
{
EnemyBoltEntity* boltEntity = dynamic_cast<EnemyBoltEntity*>(entity);
if (!boltEntity->getDying() && boltEntity->getAge() > 0.05f)
{
EnemyEntity::collideWithBolt(boltEntity);
correctFrame();
}
}
else if (entity->getType() >= ENTITY_ENEMY && entity->getType() <= ENTITY_ENEMY_MAX)
{
EnemyEntity* enemyEntity = dynamic_cast<EnemyEntity*>(entity);
if (!enemyEntity->getDying() && enemyEntity->canCollide()&& enemyEntity->getMovingStyle() != movFlying)
{
hurt(getHurtParams(hp, ShotTypeStandard, 0, false, SourceTypeMelee, enemyEntity->getEnemyType(), false));
}
}
}
}
void ObstacleEntity::correctFrame()
{
if (hp > 0)
{
- if ( (hp - 1) / 6 == 1) frame = initialFrame + 1;
- else if ( (hp - 1) / 6 == 0) frame = initialFrame + 2;
- game().getCurrentMap()->setObjectTile(xGrid, yGrid, MAPOBJ_BARREL + frame);
+ if ( (hp - 1) / 6 == 1)
+ {
+ frame = initialFrame + 1;
+ objectIndex = initialObjectIndex + 1;
+ }
+ else if ( (hp - 1) / 6 == 0)
+ {
+ frame = initialFrame + 2;
+ objectIndex = initialObjectIndex + 2;
+ }
+ game().getCurrentMap()->setObjectTile(xGrid, yGrid, objectIndex);
}
}
int ObstacleEntity::hurt(StructHurt hurtParam)
{
int oldHp = hp;
int result = EnemyEntity::hurt(hurtParam);
int diff = oldHp - hp;
for (int i = 0; i < diff; i++)
game().generateBlood(x, y, obstacleBloodType);
return result;
}
diff --git a/src/ObstacleEntity.h b/src/ObstacleEntity.h
index d0f2612..36bdcf5 100644
--- a/src/ObstacleEntity.h
+++ b/src/ObstacleEntity.h
@@ -1,31 +1,35 @@
#ifndef OBSTACLEENTITY_H
#define OBSTACLEENTITY_H
#include "EnemyEntity.h"
class ObstacleEntity : public EnemyEntity
{
public:
ObstacleEntity(float x, float y, int objectFrame);
virtual void animate(float delay);
virtual void calculateBB();
virtual void readCollidingEntity(CollidingSpriteEntity* entity);
virtual void render(sf::RenderTarget* app);
virtual void dying();
virtual int hurt(StructHurt hurtParam);
+ int getObjectIndex();
+
protected:
virtual void drop();
private:
int xGrid;
int yGrid;
int initialFrame;
+ int objectIndex;
+ int initialObjectIndex;
void correctFrame();
bool explosive;
enumBloodColor obstacleBloodType;
};
#endif // OBSTACLEENTITY_H
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Jun 17, 9:11 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70304
Default Alt Text
(16 KB)
Attached To
Mode
R78 witchblast
Attached
Detach File
Event Timeline