Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F131858
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
83 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/media/blood.png b/media/blood.png
index d1adfa8..d9f1c26 100644
Binary files a/media/blood.png and b/media/blood.png differ
diff --git a/media/corpses.png b/media/corpses.png
index 210d831..1db4061 100644
Binary files a/media/corpses.png and b/media/corpses.png differ
diff --git a/media/destroyable_objects.png b/media/destroyable_objects.png
index 3e4879f..23c5e5b 100644
Binary files a/media/destroyable_objects.png and b/media/destroyable_objects.png differ
diff --git a/src/BaseCreatureEntity.h b/src/BaseCreatureEntity.h
index d27fddc..9ad840d 100644
--- a/src/BaseCreatureEntity.h
+++ b/src/BaseCreatureEntity.h
@@ -1,254 +1,254 @@
#ifndef BASECREATUREENTITY_H
#define BASECREATUREENTITY_H
#include "sfml_game/CollidingSpriteEntity.h"
#include "TextEntity.h"
#include "Constants.h"
enum enemyTypeEnum
{
// normal
EnemyTypeBat,
EnemyTypeBatSkeleton,
EnemyTypeRat,
EnemyTypeRatBlack,
EnemyTypeRatHelmet,
EnemyTypeRatBlackHelmet,
EnemyTypeEvilFlower,
EnemyTypeEvilFlowerIce,
EnemyTypeEvilFlowerFire,
EnemyTypeSnake,
EnemyTypeSnakeBlood,
EnemyTypeSlime,
EnemyTypeSlimeRed,
EnemyTypeSlimeBlue,
EnemyTypeSlimeViolet,
EnemyTypeImpBlue,
EnemyTypeImpRed,
EnemyTypePumpkin,
EnemyTypeWitch,
EnemyTypeWitchRed,
EnemyTypeCauldron,
EnemyTypeCauldronElemental,
EnemyTypeSpiderEgg,
EnemyTypeSpiderLittle,
EnemyTypeGhost,
EnemyTypeZombie,
EnemyTypeZombieDark,
EnemyTypeBogeyman,
EnemyTypeSlimeLarge,
EnemyTypeSlimeRedLarge,
EnemyTypeSlimeBlueLarge,
EnemyTypeSlimeVioletLarge,
// mini boss
EnemyTypeBubble,
EnemyTypeBubbleIce,
EnemyTypeBubbleGreater,
// boss
EnemyTypeButcher,
EnemyTypeSlimeBoss,
EnemyTypeCyclops,
EnemyTypeRatKing,
EnemyTypeSpiderGiant,
EnemyTypeFrancky,
EnemyTypeVampire,
// invocated
EnemyTypeBat_invocated,
EnemyTypeBatSkeleton_invocated,
EnemyTypeRat_invocated,
EnemyTypeRatGreen,
EnemyTypeRatHelmet_invocated,
EnemyTypeSnake_invocated,
EnemyTypeSnakeBlood_invocated,
EnemyTypeSlime_invocated,
EnemyTypeSlimeRed_invocated,
EnemyTypeSlimeBlue_invocated,
EnemyTypeSlimeViolet_invocated,
EnemyTypePumpkin_invocated,
EnemyTypeSpiderEgg_invocated,
EnemyTypeSpiderLittle_invocated,
EnemyTypeZombie_invocated,
EnemyTypeRockFalling,
EnemyTypeRockMissile,
EnemyTypeSpiderWeb,
EnemyTypeFranckyHead,
EnemyTypeFranckyHand,
EnemyTypeFranckyFoot,
EnemyTypeVampireDead,
EnemyTypeNone, // player of fairy
EnemyTypeDestroyable,
NB_ENEMY // = no enemy
};
enum sourceTypeEnum
{
SourceTypeMelee,
SourceTypeBolt,
SourceTypeExplosion,
SourceTypePoison
};
struct StructHurt
{
int damage;
enumShotType hurtingType;
int level;
bool critical;
sourceTypeEnum sourceType;
enemyTypeEnum enemyType;
bool goThrough;
};
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();
float getCreatureSpeed();
IntCoord getCurrentTile();
virtual void animate(float delay);
virtual float animateStates(float delay);
virtual void animateColors(float delay);
virtual void animateRecoil(float delay);
virtual void animatePhysics(float delay);
virtual void render(sf::RenderTarget* app);
virtual void calculateBB();
virtual bool collideWithMap(int direction);
virtual int hurt(StructHurt hurtParam);
virtual void prepareDying();
virtual void dying();
enum enumMovingStyle { movWalking, movFlying};
virtual enumMovingStyle getMovingStyle();
- enum enumBloodColor { BloodNone = -1, BloodRed, BloodGreen, BloodRock, BloodEgg, BloodBubble, BloodBubbleIce, BloodBlack, BloodBarrel};
+ enum enumBloodColor { BloodNone = -1, BloodRed, BloodGreen, BloodRock, BloodEgg, BloodBubble, BloodBubbleIce, BloodBlack, BloodBarrel, BloodBarrelPowder};
enum enumSpecialState
{
SpecialStateIce, // = 0
SpecialStateSlow,
SpecialStatePoison,
SpecialStateConfused,
DivineStateProtection,
DivineStateSpeed,
DivineStateFireRate,
DivineStateFireDamage,
NB_SPECIAL_STATES
};
enum enumStateResistance { ResistanceImmune, ResistanceVeryHigh, ResistanceHigh, ResistanceStandard, ResistanceLow, ResistanceVeryLow};
struct specialStateStuct
{
enumSpecialState type;
bool active;
float timer;
float param1;
float param2;
float param3;
};
specialStateStuct specialState[NB_SPECIAL_STATES];
virtual void setSpecialState(enumSpecialState state, bool active, float timer, float param1, float param2);
enum enumResistances
{
ResistanceIce, // = 0
ResistanceFire,
ResistanceStone,
ResistanceLightning,
ResistanceIllusion,
ResistancePoison,
ResistanceRecoil,
ResistanceFrozen,
NB_RESISTANCES
};
enumStateResistance resistance[NB_RESISTANCES];
bool isSpecialStateActive(enumSpecialState state);
specialStateStuct getSpecialState(enumSpecialState state);
virtual void giveRecoil(bool stun, Vector2D velocity, float timer);
virtual void inflictsRecoilTo(BaseCreatureEntity* targetEntity);
virtual void computeFacingDirection();
virtual void dyingFromAge();
virtual bool canCollide();
bool canSee(float xf, float yf);
bool canWalkTo(float xf, float yf);
void heal(int healPoints);
static StructHurt getHurtParams(int damage,
enumShotType hurtingType,
int level,
bool critical,
sourceTypeEnum sourceType,
enemyTypeEnum enemyType,
bool goThrough)
{
StructHurt hurtParams;
hurtParams.damage = damage;
hurtParams.hurtingType = hurtingType;
hurtParams.level = level;
hurtParams.critical = critical;
hurtParams.sourceType = sourceType;
hurtParams.enemyType = enemyType;
hurtParams.goThrough = goThrough;
return hurtParams;
}
bool intersectsSegments(Vector2D a1, Vector2D a2, Vector2D b1, Vector2D b2);
bool intersectsTile(Vector2D a1, Vector2D a2, int xTile, int yTile);
virtual bool isAttacking(); // true when the monster is performing a melee attack
protected:
int hp;
int hpMax;
int hpDisplay;
float creatureSpeed;
int shadowFrame;
int facingDirection;
float armor;
bool canExplode; // true if the monster can explode with a fire attack
bool displayDamage;
bool hurting;
float hurtingDelay;
enumShotType hurtingType;
enumBloodColor bloodColor;
enumMovingStyle movingStyle;
struct recoilStruct
{
bool active;
Vector2D velocity;
bool stun;
float timer;
} recoil;
void generateStar(sf::Color starColor);
virtual void makeExplode();
private:
bool determineSatusChance(enumStateResistance resistance, int level);
int determineDamageBonus(enumStateResistance resistance, int level);
bool textTooClose(TextEntity* textEntity, float xDistMin, float yDistMin);
};
#endif // BASECREATUREENTITY_H
diff --git a/src/Constants.h b/src/Constants.h
index 599fc4a..8bb667b 100644
--- a/src/Constants.h
+++ b/src/Constants.h
@@ -1,704 +1,705 @@
/** This file is part of Witch Blast.
*
* Witch Blast is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Witch Blast is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Witch Blast. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONSTANTS_H_INCLUDED
#define CONSTANTS_H_INCLUDED
#include <string>
const std::string APP_NAME = "Witch Blast";
const std::string APP_VERSION = "0.6.x";
const std::string CONFIG_FILE = "config.dat";
const std::string SAVE_FILE = "game.sav";
const std::string SAVE_DATA_FILE = "data/data.sav";
const std::string HISCORES_FILE = "data/scores.dat";
const std::string SAVE_VERSION = "SAVE_0.6";
const std::string SCORE_VERSION = "V060_DEV";
const int NB_LANGUAGES = 5;
const std::string languageString[NB_LANGUAGES] = { "english", "french", "german", "spanish", "russian" };
const unsigned int SCORES_MAX = 10;
// Client size
const int SCREEN_WIDTH = 970;
const int SCREEN_HEIGHT = 720;
// Tile set
const int TILE_WIDTH = 64;
const int TILE_HEIGHT = 64;
// Tile map offset
const int OFFSET_X = 5;
const int OFFSET_Y = 5;
const int MAP_WIDTH = 15;
const int MAP_HEIGHT = 9;
const int MENU_MAP_WIDTH = 16;
const int MENU_MAP_HEIGHT = 13;
const int GAME_WIDTH = MAP_WIDTH * TILE_WIDTH;
const int GAME_HEIGHT = MAP_HEIGHT * TILE_HEIGHT;
const int FLOOR_WIDTH = 13;
const int FLOOR_HEIGHT = 7;
const int ITEM_WIDTH = 32;
const int ITEM_HEIGHT = 32;
const int BOLT_WIDTH = 24;
const int BOLT_HEIGHT = 24;
const int BOLT_PRO_LINE = 10;
const int BB_LEFT = 22;
const int BB_RIGHT = 22;
const int BB_TOP = 4;
const int BB_BOTTOM = 31;
const float FADE_IN_DELAY = 1.0f;
const float FADE_OUT_DELAY = 1.0f;
const float EXPLOSION_DELAY = 2.0f;
const float DEATH_CERTIFICATE_DELAY = 3.5f;
const float ACHIEVEMENT_DELAY_MAX = 15.0f;
const float KeyRoomFXDelay = 2.0f;
enum enum_images {
IMAGE_PLAYER_0,
IMAGE_PLAYER_1,
IMAGE_BOLT,
IMAGE_TILES,
IMAGE_RAT,
IMAGE_MINIMAP,
IMAGE_MAP_BACKGROUND,
IMAGE_ITEMS,
IMAGE_ITEMS_EQUIP,
IMAGE_ITEMS_PRES,
IMAGE_ITEMS_EQUIP_PRES,
IMAGE_CHEST,
IMAGE_BAT,
IMAGE_FLOWER,
IMAGE_SLIME,
IMAGE_IMP,
IMAGE_SPIDER_EGG,
IMAGE_SPIDER_WEB,
IMAGE_LITTLE_SPIDER,
IMAGE_BUBBLE,
IMAGE_EYE,
IMAGE_WITCH,
IMAGE_CAULDRON,
IMAGE_SNAKE,
IMAGE_PUMPKIN,
IMAGE_GHOST,
IMAGE_ZOMBIE,
IMAGE_BOGEY,
IMAGE_BUTCHER,
IMAGE_GIANT_SLIME,
IMAGE_KING_RAT,
IMAGE_CYCLOP,
IMAGE_GIANT_SPIDER,
IMAGE_FRANCKY,
IMAGE_VAMPIRE,
IMAGE_VAMPIRE_BAT,
IMAGE_VAMPIRE_PART,
IMAGE_BLOOD,
IMAGE_CORPSES,
IMAGE_CORPSES_BIG,
IMAGE_STAR,
IMAGE_STAR_2,
IMAGE_HURT_IMPACT,
IMAGE_INTERFACE,
IMAGE_HUD_SHOTS,
IMAGE_EXPLOSION,
IMAGE_KEYS_QWER,
IMAGE_KEYS_AZER,
IMAGE_MESSAGE_ICONS,
IMAGE_INTRO,
IMAGE_TITLE,
IMAGE_OVERLAY,
IMAGE_LIGHT_CONE,
IMAGE_DIVINITY,
IMAGE_PNJ,
IMAGE_FAIRY,
IMAGE_KEY_AREA,
IMAGE_UI_LIFE,
IMAGE_UI_MANA,
IMAGE_UI_SPELLS,
IMAGE_UI_MESSAGE,
IMAGE_UI_TOP_LAYER,
IMAGE_UI_ACHIEV,
IMAGE_FOG,
IMAGE_TITLE_ANIM,
IMAGE_SPLATTER,
IMAGE_WITCH_INTRO,
IMAGE_ITEM_DESCRIPTION,
IMAGE_DEATH_CERTIFICATE,
IMAGE_ACHIEVEMENTS,
IMAGE_BOSS_PICTURES,
IMAGE_PORTRAIT_PART,
IMAGE_RANDOM_DUNGEON,
IMAGE_DUNGEON_OBJECTS,
IMAGE_TILES_SHADOW,
IMAGE_TILES_SHADOW_CORNER,
IMAGE_TILES_SHADOW_MEDIUM,
IMAGE_TILES_SHADOW_SMALL,
IMAGE_DOORS,
IMAGE_DESTROYABLE,
NB_IMAGES
};
enum sound_resources {
SOUND_NONE = -1,
SOUND_BLAST_STANDARD,
SOUND_BLAST_FLOWER,
SOUND_BLAST_LIGHTNING,
SOUND_BLAST_FIRE,
SOUND_BLAST_ICE,
SOUND_BLAST_ILLUSION,
SOUND_BLAST_POISON,
SOUND_BLAST_STONE,
SOUND_DOOR_CLOSING,
SOUND_DOOR_OPENING,
SOUND_CHEST_OPENING,
SOUND_IMPACT,
SOUND_BONUS,
SOUND_DRINK,
SOUND_EAT,
SOUND_PLAYER_HIT,
SOUND_PLAYER_DIE,
SOUND_ENNEMY_DYING,
SOUND_COIN_PICK_UP,
SOUND_PAY,
SOUND_WALL_IMPACT,
SOUND_BIG_WALL_IMPACT,
SOUND_KING_RAT_1,
SOUND_KING_RAT_2,
SOUND_KING_RAT_DIE,
SOUND_SLIME_JUMP,
SOUND_SLIME_IMAPCT,
SOUND_SLIME_IMAPCT_WEAK,
SOUND_SLIME_IMAPCT_BOSS,
SOUND_SLIME_SMASH,
SOUND_ICE_CHARGE,
SOUND_ELECTRIC_CHARGE,
SOUND_SHOT_SELECT,
SOUND_HEART,
SOUND_RAT_DYING,
SOUND_BAT_DYING,
SOUND_IMP_HURT,
SOUND_IMP_DYING,
SOUND_ROCK_IMPACT_LIGHT,
SOUND_ROCK_IMPACT_MEDIUM,
SOUND_ROCK_IMPACT_HEAVY,
SOUND_THROW,
SOUND_CYCLOP_00,
SOUND_CYCLOP_DIE,
SOUND_CYCLOPS_IMPACT,
SOUND_BUTCHER_00,
SOUND_BUTCHER_01,
SOUND_BUTCHER_HURT,
SOUND_BUTCHER_DIE,
SOUND_VIB,
SOUND_BOOM_00,
SOUND_CLANG_00,
SOUND_BUBBLE_00,
SOUND_BUBBLE_01,
SOUND_TRAP,
SOUND_EGG_SMASH_00,
SOUND_EGG_SMASH_01,
SOUND_SPIDER_WALKING,
SOUND_SPIDER_WEB,
SOUND_SPIDER_HURT,
SOUND_SPIDER_DIE,
SOUND_SPIDER_LITTLE_DIE,
SOUND_WITCH_00,
SOUND_WITCH_01,
SOUND_WITCH_02,
SOUND_WITCH_DIE_00,
SOUND_WITCH_DIE_01,
SOUND_INVOKE,
SOUND_CAULDRON,
SOUND_CAULDRON_DIE,
SOUND_SNAKE_DIE,
SOUND_PUMPKIN_00,
SOUND_PUMPKIN_01,
SOUND_PUMPKIN_DIE,
SOUND_CRITICAL,
SOUND_GONG,
SOUND_TELEPORT,
SOUND_SPELL_CHARGE,
SOUND_FIREBALL,
SOUND_MESSAGE,
SOUND_EARTHQUAKE,
SOUND_SPELL_FREEZE,
SOUND_SPELL_SHIELD,
SOUND_HEAVY_STEP_00,
SOUND_HEAVY_STEP_01,
SOUND_NIGHT,
SOUND_GRUMBLE,
SOUND_ZOMBIE_00,
SOUND_ZOMBIE_01,
SOUND_ZOMBIE_ATTACKING,
SOUND_ZOMBIE_DYING,
SOUND_GHOST,
SOUND_GHOST_DYING,
SOUND_ELECTRICITY,
SOUND_ELECTRIC_BLAST,
SOUND_FRANCKY_00,
SOUND_FRANCKY_01,
SOUND_FRANCKY_02,
SOUND_FRANCKY_DYING,
SOUND_OM,
SOUND_GLASS,
SOUND_HICCUP,
SOUND_SPLATCH,
SOUND_INTRO_WITCH,
SOUND_FORCE_FIELD,
SOUND_DOOR_OPENING_BOSS,
SOUND_ACHIEVEMENT,
SOUND_VAMPIRE_FLYING,
SOUND_VAMPIRE_FLAP,
SOUND_VAMPIRE_SONIC_RAY,
SOUND_VAMPIRE_LAUGHING,
SOUND_VAMPIRE_TRANSFORM_BOLT,
SOUND_VAMPIRE_TRANSFORM_BAT,
SOUND_VAMPIRE_HYPNOSIS,
SOUND_VAMPIRE_CRY,
SOUND_VAMPIRE_DYING,
SOUND_ICE_BLOCK,
SOUND_BOGEYMAN_DIE,
SOUND_BOGEYMAN_ATTACK,
SOUND_BOGEYMAN_VORTEX_00,
SOUND_BOGEYMAN_VORTEX_01,
SOUND_BARREL_HIT,
SOUND_BARREL_SMASH
};
enum corpses_ressources{
FRAME_CORPSE_RAT,
FRAME_CORPSE_BAT,
FRAME_CORPSE_FLOWER,
FRAME_CORPSE_GREEN_RAT,
FRAME_CORPSE_SLIME,
FRAME_CORPSE_BLACK_RAT,
FRAME_CORPSE_IMP_RED,
FRAME_CORPSE_IMP_BLUE,
FRAME_CORPSE_SLIME_RED,
FRAME_CORPSE_SLIME_BLUE,
FRAME_CORPSE_SPIDER_EGG,
FRAME_CORPSE_LITTLE_SPIDER,
FRAME_CORPSE_SPIDER_WEB,
FRAME_CORPSE_RAT_HELMET,
FRAME_CORPSE_BLACK_RAT_HELMET,
FRAME_CORPSE_SLIME_VIOLET,
FRAME_CORPSE_WITCH,
FRAME_CORPSE_WITCH_RED,
FRAME_CORPSE_CAULDRON,
FRAME_CORPSE_SNAKE,
FRAME_CORPSE_SNAKE_BLOOD,
FRAME_CORPSE_PUMPKIN,
FRAME_CORPSE_FLOWER_ICE,
FRAME_CORPSE_GHOST,
FRAME_CORPSE_ZOMBIE,
FRAME_CORPSE_ZOMBIE_DARK,
FRAME_CORPSE_FRANCKY_TORSO,
FRAME_CORPSE_FRANCKY_HEAD,
FRAME_CORPSE_FRANCKY_HAND,
FRAME_CORPSE_FRANCKY_FOOT,
FRAME_CORPSE_FLOWER_FIRE,
FRAME_CORPSE_VAMPIRE,
FRAME_CORPSE_BAT_SKELETON,
FRAME_CORPSE_CAULDRON_BLUE,
FRAME_CORPSE_CAULDRON_RED,
FRAME_CORPSE_CAULDRON_GREEN,
+ FRAME_CORPSE_BARREL,
FRAME_CORPSE_KING_RAT,
FRAME_CORPSE_GIANT_SLIME,
FRAME_CORPSE_CYCLOP,
FRAME_CORPSE_BUTCHER,
FRAME_CORPSE_GIANT_SPIDER,
FRAME_CORPSE_GIANT_SLIME_RED,
FRAME_CORPSE_GIANT_SLIME_BLUE,
};
// chests
enum chest_type_enum {
ChestBasic,
ChestExit,
ChestChallenge,
ChestFairy,
};
const float CHEST_APPEAR_DELAY = 1.5f;
// Artefact Info
const float ARTEFACT_RECT_WIDTH = 650.0f;
const float ARTEFACT_RECT_HEIGHT = 100.0f;
const float ARTEFACT_POS_Y = 450.0f;
const float ARTEFACT_BORDER = 3.0f;
const float ARTEFACT_ZOOM_TIME = 0.5f;
// shot types
enum enumShotType {
ShotTypeStandard,
ShotTypeIce,
ShotTypeIllusion,
ShotTypeStone,
ShotTypeLightning,
ShotTypeFire,
ShotTypePoison,
ShotTypeBomb,
ShotTypeCold,
ShotTypeDeterministic
};
// special shots effects
const int MAX_SHOT_LEVEL = 3;
const float STATUS_FROZEN_DELAY[MAX_SHOT_LEVEL] // how long the freeze occurs
= { 4.0f, 5.0f, 6.0f };
const float STATUS_FROZEN_BOLT_DELAY[MAX_SHOT_LEVEL] // reload time
= { 3.0f, 2.6f, 2.0f };
const float STATUS_FROZEN_MULT[MAX_SHOT_LEVEL] // speed multiplier (= 3 times slower)
= { 0.38f, 0.33f, 0.28f };
const float STONE_DECOIL_DELAY[MAX_SHOT_LEVEL] // how long the stun occurs
= { 0.15f, 0.175f, 0.2f };
const float STONE_DECOIL_VELOCITY[MAX_SHOT_LEVEL] // Decoil velocity
= { 270.0f, 320.0f, 450.0f };
const float ILLUSION_DAMAGE_DECREASE[MAX_SHOT_LEVEL] // Illusion damage malus
= { 0.8f, 0.9f, 1.0f };
const float LIGHTNING_VISCOSITY_INCREASE[MAX_SHOT_LEVEL] // Air resistance
= { 0.01, 0.015f, 0.02f };
const float FIRE_DAMAGE_INCREASE[MAX_SHOT_LEVEL] // Fire damage's bonus
= { 1.15f, 1.3f, 1.45f };
const float POISON_TIMER[MAX_SHOT_LEVEL]
= { 10.5f, 12.5f, 12.5f };
const float POISON_DAMAGE[MAX_SHOT_LEVEL]
= { 1, 1, 1 };
const float POISON_DELAY[MAX_SHOT_LEVEL]
= { 2.0f, 1.5f, 1.0f };
// divinity
enum enumDivinityType {
DivinityHealer,
DivinityFighter,
DivinityIce,
DivinityStone,
DivinityAir,
NB_DIVINITY
};
const std::string divinityLabel[NB_DIVINITY]
{
"divinity_healer",
"divinity_fighter",
"divinity_ice",
"divinity_stone",
"divinity_air",
};
const int MAX_DIVINITY_LEVEL = 5;
const int DIVINITY_LEVEL_TRESHOLD[MAX_DIVINITY_LEVEL] =
{ 100, 300, 500, 900, 1400};
// entity type
const int ENTITY_PLAYER = 1;
const int ENTITY_FAMILIAR = 2;
const int ENTITY_DOOR = 3;
const int ENTITY_ARTIFACT_DESCRIPTION = 9;
const int ENTITY_BLOOD = 11;
const int ENTITY_CORPSE = 12;
const int ENTITY_EFFECT = 13;
const int ENTITY_FLYING_TEXT = 14;
const int ENTITY_BOLT = 15;
const int ENTITY_ENEMY_BOLT = 16;
const int ENTITY_PNJ = 17;
const int ENTITY_CHEST = 18;
const int ENTITY_ITEM = 19;
const int ENTITY_EXPLOSION = 20;
const int ENTITY_FAMILIAR_LOCAL = 21;
const int ENTITY_ENEMY = 31;
const int ENTITY_ENEMY_INVOCATED = 32;
const int ENTITY_ENEMY_BOSS = 33;
const int ENTITY_ENEMY_NC = 34;
const int ENTITY_ENEMY_MAX = ENTITY_ENEMY_NC;
const int ENTITY_ENEMY_MAX_COUNT = ENTITY_ENEMY_BOSS;
const float DOOR_OPEN_TIME = 1.0f;
const float DOOR_CLOSE_TIME = 1.0f;
// Player game play
const float INITIAL_PLAYER_SPEED = 220.0f;
const int INITIAL_PLAYER_HP = 20;
const float INITIAL_PLAYER_FIRE_DELAY = 0.7f;
const float ACQUIRE_DELAY = 2.3f;
const float UNLOCK_DELAY = 1.2f;
const float WORSHIP_DELAY = 2.0f;
const float INVINCIBLE_DELAY = 1.5f;
const float HICCUP_DELAY = 5.0f;
const float INITIAL_BOLT_LIFE = 0.45f;
const int INITIAL_BOLT_DAMAGES = 8;
const float INITIAL_BOLT_VELOCITY = 700.0f;
const float INITIAL_BOLT_VISCOSITY = 0.98f;
const float FAIRY_SPEED = 220.0f;
const float FAIRY_FIRE_DELAY = 0.8f;
const float ICE_FAIRY_FIRE_DELAY = 1.3f;
const float TARGET_FAIRY_FIRE_DELAY = 1.0f;
const float FAIRY_BOLT_LIFE = 0.4f;
const int FAIRY_BOLT_DAMAGES = 8;
const int FAIRY_FIRE_DAMAGES = 12;
const float FAIRY_BOLT_VELOCITY = 700.0f;
// Rat
const float RAT_SPEED = 195.0f;
const float RAT_SPEED_HELMET = 140.0f;
const int RAT_HP = 16;
const int RAT_HP_HELMET = 24;
const int RAT_DAMAGES = 5;
const int RAT_BB_LEFT = 14;
const int RAT_BB_WIDTH_DIFF = 28;
const int RAT_BB_TOP = 22;
const int RAT_BB_HEIGHT_DIFF = 22;
// Green Rat
const float GREEN_RAT_SPEED = 180.0f;
const int GREEN_RAT_HP = 16;
const int GREEN_RAT_DAMAGES = 5;
const float GREEN_RAT_FADE = 1.0f;
// Black Rat
const float BLACK_RAT_SPEED = 195.0f;
const float BLACK_RAT_SPEED_HELMET = 125.0f;
const int BLACK_RAT_HP = 16;
const int BLACK_RAT_HP_HELMET = 24;
const int BLACK_RAT_DAMAGES = 5;
// Bat
const float BAT_SPEED = 270.0f;
const int BAT_HP = 5;
const int BAT_DAMAGES = 5;
// Zombie
const float ZOMBIE_SPEED = 80.0f;
const int ZOMBIE_HP = 80;
const int ZOMBIE_DAMAGE = 10;
// Evl Flower
const int EVIL_FLOWER_HP = 16;
const int EVIL_FLOWER_MELEE_DAMAGES = 5;
const int EVIL_FLOWER_MISSILE_DAMAGES = 6;
const int EVIL_FLOWER_FIRE_MISSILE_DAMAGES = 8;
const int EVIL_FLOWER_BB_LEFT = 14;
const int EVIL_FLOWER_BB_WIDTH_DIFF = 28;
const int EVIL_FLOWER_BB_TOP = 22;
const int EVIL_FLOWER_BB_HEIGHT_DIFF = 22;
const float EVIL_FLOWER_FIRE_DELAY = 2.2f;
const float EVIL_FLOWER_FIRE_VELOCITY = 230.0f;
// Snake
const float SNAKE_SPEED = 150.0f;
const int SNAKE_HP = 16;
const int SNAKE_DAMAGE = 5;
const float SNAKE_BLOOD_SPEED = 170.0f;
const int SNAKE_BLOOD_HP = 32;
const int SNAKE_BLOOD_DAMAGE = 8;
// Slime
const int SLIME_HP = 16;
const int SLIME_DAMAGES = 5;
const int SLIME_BB_LEFT = 13;
const int SLIME_BB_WIDTH_DIFF = 26;
const int SLIME_BB_TOP = 38;
const int SLIME_BB_HEIGHT_DIFF = 40;
const float SLIME_FIRE_VELOCITY = 240.0f;
// Imp
const float IMP_SPEED = 190.0f;
const int IMP_HP = 20;
const int IMP_MELEE_DAMAGES = 5;
const int IMP_MISSILE_DAMAGES = 8;
const float IMP_FIRE_VELOCITY = 260.0f;
// Witch
const int WITCH_HP = 80;
const int WITCH_DAMAGE = 5;
const int WITCH_VELOCITY = 140.0f;
// Cauldron
const int CAULDRON_HP = 150;
// Ghost
const float GHOST_SPEED = 140.0f;
const int GHOST_HP = 40;
const int GHOST_DAMAGE = 8;
// Butcher
const int BUTCHER_HP = 120;
const int BUTCHER_DAMAGES = 8;
const int BUTCHER_VELOCITY = 100;
// Giant Slime
const int GIANT_SLIME_HP = 250;
const int GIANT_SLIME_DAMAGES = 8;
const int GIANT_SLIME_MISSILE_DAMAGES = 6;
const float GIANT_SLIME_MISSILE_DELAY = 0.33f;
const float GIANT_SLIME_FIRE_VELOCITY = 200.0f;
const int GIANT_SLIME_BB_LEFT = 26;
const int GIANT_SLIME_BB_WIDTH_DIFF = 52;
const int GIANT_SLIME_BB_TOP = 64;
const int GIANT_SLIME_BB_HEIGHT_DIFF = 12;
const int GIANT_SLIME_SPEED = 80.0f;
const float GIANT_SLIME_ULTRA_JUMP_VELOCITY = 1700.0f;
const float GIANT_SLIME_ULTRA_FALL_VELOCITY = -2000.0f;
const float GIANT_SLIME_ULTRA_JUMP_TIMER = 2.3f;
// KingRat
const float KING_RAT_SPEED = 210.0f;
const float KING_RAT_RUNNING_SPEED = 750.0f;
const float KING_RAT_BERSERK_SPEED = 300.0f;
const float KING_RAT_RUNNING_RECOIL = 750.0f;
const int KING_RAT_HP = 700;
const int KING_RAT_DAMAGES = 8;
// Cyclops
const float CYCLOP_SPEED[4] = { 140, 150, 160, 170};
const int CYCLOP_NUMBER_ROCKS[4] = { 5, 7, 9, 12};
const float CYCLOP_FIRE_DELAY[4] = { 0.3f, 0.26f, 0.23f, 0.2f};
const int CYCLOP_HP = 880;
const int CYCLOP_DAMAGES = 8;
// Giant Spider
const float GIANT_SPIDER_SPEED[4] = { 240, 245, 250, 255 };
const int GIANT_SPIDER_NUMBER_EGGS[4] = { 12, 14, 16, 18};
const float GIANT_SPIDER_FIRE_DELAY[4] = { 0.82f, 0.72f, 0.62f, 0.52f};
const int GIANT_SPIDER_HP = 800;
const int GIANT_SPIDER_DAMAGE = 8;
// EFFECTS
const float HURTING_DELAY = 0.4f;
const float HEART_BEAT_DELAY = 1.2f;
// messages
const int NB_MSG_LINES = 3;
enum EnumMessages
{
MsgInfoLevel1,
MsgInfoLevel2,
MsgInfoLevel3,
MsgInfoLevel4,
MsgInfoLevel5,
MsgInfoLevel6,
MsgInfoLevel7,
MsgInfoRatsBats,
MsgInfoSnakes,
MsgInfoWitches,
MsgInfoGold,
MsgInfoFamiliar,
MsgInfoButcher,
MsgInfoGiantSlime,
MsgInfoCyclops,
MsgInfoWererat,
MsgInfoGiantSpiderBefore,
MsgInfoGiantSpiderAfter,
MsgInfoFranky,
MsgInfoVampire,
MsgInfoDivHealer,
MsgInfoDivFighter,
MsgInfoDivIce,
MsgInfoDivStone,
MsgInfoDivAir,
MsgInfoDivIntervention,
MsgInfoDivGift,
MsgInfoDivLevel,
MsgTutoBasics,
MsgTutoTips,
MsgTutoItems,
MsgTutoShops,
MsgTutoBossDoor,
MsgTutoChallengeDoor,
MsgTutoTemple,
MsgTutoHeal,
MsgTutoShots,
MsgTutoSpell,
MsgTutoAchievements,
NB_MESSAGES
};
enum EnumMessagesType
{
MessageTypeInfo,
MessageTypeTutorial,
};
struct messageStruct
{
int icon;
EnumMessagesType messageType;
EnumMessages type;
std::string message[NB_MSG_LINES];
float timer;
float timerMax;
};
enum EnumWorldEvents
{
// info
EventMeetRatsOrBats,
EventMeetSnakes,
EventMeetWitches,
EventGetCoin,
EventPietyMax,
Event4Hits,
// tuto
EventBeingHurted,
EventFindShop,
EventFindBossDoor,
EventFindChallengeDoor,
EventFindTemple,
EventGetItem,
EventGetSpecialShot,
EventGetFamiliar,
EventGetSpell,
EventAchievement,
NB_EVENTS
};
enum EnumInteractionType
{
InteractionTypeTemple,
InteractionTypeMerchandise,
};
#endif // CONSTANTS_H_INCLUDED
diff --git a/src/DungeonMap.cpp b/src/DungeonMap.cpp
index 9051ffe..822cd5b 100644
--- a/src/DungeonMap.cpp
+++ b/src/DungeonMap.cpp
@@ -1,1733 +1,1734 @@
#include "DungeonMap.h"
#include "GameFloor.h"
#include "ItemEntity.h"
#include "ChestEntity.h"
#include "sfml_game/ImageManager.h"
#include <cstdlib>
#include <stdio.h>
#include <iostream>
#include "WitchBlastGame.h"
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;
for (int i = 0; i < NB_RANDOM_TILES_IN_ROOM; i++)
{
randomTileElements[i].type = -1;
randomTileElements[i].x = 0;
randomTileElements[i].y = 0;
randomTileElements[i].rotation = 0;
}
}
DungeonMap::~DungeonMap()
{
}
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;
}
int DungeonMap::getObjectTile(int x, int y)
{
return objectsMap[x][y];
}
logicalMapStateEnum DungeonMap::getLogicalTile(int x, int y)
{
return logicalMap[x][y];
}
void DungeonMap::setObjectTile(int x, int y, int n)
{
objectsMap[x][y] = n;
hasChanged = true;
}
void DungeonMap::setLogicalTile(int x, int y, logicalMapStateEnum state)
{
logicalMap[x][y] = state;
hasChanged = true;
}
int DungeonMap::getFloorOffset()
{
return floorOffset;
}
int DungeonMap::getWallType()
{
return wallType;
}
void DungeonMap::setFloorOffset(int n)
{
floorOffset = n;
}
void DungeonMap::setWallType(int n)
{
wallType = n;
}
doorEnum DungeonMap::getDoorType(int direction)
{
return doorType[direction];
}
void DungeonMap::setDoorType(int direction, doorEnum type)
{
doorType[direction] = type;
}
std::list<DungeonMap::itemListElement> DungeonMap::getItemList()
{
return (itemList);
}
std::list<DungeonMap::chestListElement> DungeonMap::getChestList()
{
return (chestList);
}
std::list<DungeonMap::spriteListElement> DungeonMap::getSpriteList()
{
return (spriteList);
}
DungeonMap::RandomTileElement DungeonMap::getRandomTileElement(int n)
{
if (n < 0 || n >= NB_RANDOM_TILES_IN_ROOM) return RandomTileElement { -1, 0, 0, 0};
return randomTileElements[n];
}
void DungeonMap::setRandomTileElement (int n, RandomTileElement rt)
{
if (n < 0 || n >= NB_RANDOM_TILES_IN_ROOM) return;
randomTileElements[n] = rt;
hasChanged = true;
}
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;
return (logicalMap[x][y] != LogicalFloor);
}
bool DungeonMap::isUpBlocking(int x, int y)
{
if (!inMap(x, y)) return false;
return (logicalMap[x][y] != LogicalFloor);
}
bool DungeonMap::isLeftBlocking(int x, int y)
{
if (!inMap(x, y)) return false;
return (logicalMap[x][y] != LogicalFloor);
}
bool DungeonMap::isRightBlocking(int x, int y)
{
if (!inMap(x, y)) return false;
return (logicalMap[x][y] != LogicalFloor);
}
bool DungeonMap::isWalkable(int x, int y)
{
if (!inMap(x, y)) return true;
if (roomType == roomTypeKey && !cleared)
{
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
if (x >= x0 - 1 && x <= x0 +1 && y >= y0 - 1 && y <= y0 + 1)
return false;
}
return (logicalMap[x][y] == LogicalFloor);
}
bool DungeonMap::isFlyable(int x, int y)
{
if (x < 0) return true;
if (x > MAP_WIDTH - 1) return true;
if (y < 0) return true;
if (y > MAP_HEIGHT - 1) return true;
return (logicalMap[x][y] != LogicalWall);
}
bool DungeonMap::isShootable(int x, int y)
{
if (!inMap(x, y)) return true;
return (logicalMap[x][y] != LogicalWall && logicalMap[x][y] != LogicalObstacle);
}
bool DungeonMap::containsHealth()
{
ItemList::iterator it;
for (it = itemList.begin (); it != itemList.end ();)
{
itemListElement ilm = *it;
it++;
if (ilm.type >= ItemHealthVerySmall && ilm.type <= ItemHealthVerySmallPoison)
return true;
}
return false;
}
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;
}
roomTypeEnum DungeonMap::getNeighbourLeft()
{
if (x > 0) return gameFloor->getRoom(x - 1, y);
else return roomTypeNULL;
}
roomTypeEnum DungeonMap::getNeighbourRight()
{
if (x < MAP_WIDTH - 1) return gameFloor->getRoom(x + 1, y);
else return roomTypeNULL;
}
roomTypeEnum DungeonMap::getNeighbourUp()
{
if (y > 0) return gameFloor->getRoom(x, y - 1);
else return roomTypeNULL;
}
roomTypeEnum DungeonMap::getNeighbourDown()
{
if (y < MAP_HEIGHT - 1) return gameFloor->getRoom(x, y + 1);
else return roomTypeNULL;
}
int DungeonMap::getDivinity(int x, int y)
{
if (x <= 0 || (x >= MAP_WIDTH - 1) || y <= 0 || (y >= MAP_HEIGHT - 1)) return -1;
if (map[x][y] >= MAP_TEMPLE && map[x][y] < MAP_TEMPLE + NB_DIVINITY)
return (map[x][y] - MAP_TEMPLE);
else
return -1;
}
doorEnum getRandomDoor()
{
return (doorEnum)(DoorStandard_0 + ((game().getLevel() - 1) % 8));
/////
int n = rand() % 12;
switch (game().getLevel())
{
case 1:
if (n < 6) return DoorStandard_0;
else return DoorStandard_1;
case 2:
if (n < 5) return DoorStandard_0;
else if (n < 10) return DoorStandard_1;
else return DoorStandard_2;
case 3:
if (n < 6) return DoorStandard_1;
else return DoorStandard_2;
case 4:
if (n < 5) return DoorStandard_1;
else if (n < 10) return DoorStandard_2;
else return DoorStandard_3;
case 5:
if (n < 6) return DoorStandard_2;
else return DoorStandard_3;
case 6:
if (n < 5) return DoorStandard_2;
else if (n < 10) return DoorStandard_3;
else return DoorStandard_4;
default:
if (n < 6) return DoorStandard_3;
else return DoorStandard_4;
}
return (doorEnum)(rand() % 5);
}
void DungeonMap::initRoom(int floorN, int wallN)
{
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
int i, j;
// style
if (floorN < 0) floorOffset = ((game().getLevel() - 1) % 8) * 24 ;
else floorOffset = floorN;
if (wallN < 0) wallType = ((game().getLevel() - 1) % 8) ;
else wallType = wallN;
int wallOffset = wallType * 24;
// doors
for (i = 0; i < 4; i++) doorType[i] = DoorNone;
// outer walls
map[0][0] = wallOffset + MAP_WALL_7 + rand() % 2;
for ( i = 1 ; i < width -1 ; i++)
{
if (i == width / 2)
{
map[i][0] = wallOffset + MAP_WALL_8 + rand() % 2;
map[i][height - 1] = wallOffset + MAP_WALL_8 + rand() % 2;
}
else if (i < width / 2)
{
map[i][0] = wallOffset + MAP_WALL_87 + rand() % 8;
map[i][height - 1] = wallOffset + MAP_WALL_87 + rand() % 8;
}
else
{
map[i][0] = wallOffset + MAP_WALL_87 + rand() % 8;
map[i][height - 1] = wallOffset + MAP_WALL_87 + rand() % 8;
}
}
map[width - 1][0] = wallOffset + MAP_WALL_7 + rand() % 2;
for ( int i = 1 ; i < height -1 ; i++)
{
if (i == height / 2)
{
map[0][i] = wallOffset + MAP_WALL_8 + rand() % 2;
map[width - 1][i] = wallOffset + MAP_WALL_8 + rand() % 2;
}
else if (i < height / 2)
{
map[0][i] = wallOffset + MAP_WALL_87 + rand() % 8;
map[width - 1][i] = wallOffset + MAP_WALL_87 + rand() % 8;
}
else
{
map[0][i] = wallOffset + MAP_WALL_87 + rand() % 8;
map[width - 1][i] = wallOffset + MAP_WALL_87 + rand() % 8;
}
}
map[0][height - 1] = wallOffset + MAP_WALL_7 + rand() % 2;
map[width - 1][height - 1] = wallOffset + MAP_WALL_7 + rand() % 2;
// floor
for ( j = 1 ; j < height - 1 ; j++)
{
for ( i = 1 ; i < width - 1 ; i++)
{
map[i][j] = floorOffset + rand()%(MAP_NORMAL_FLOOR);
while (map[i][j] == map[i - 1][j] || map[i][j] == map[i][j - 1] || map[i][j] == map[i - 1][j - 1] || map[i][j] == map[i + 1][j - 1])
map[i][j] = floorOffset + rand()%(MAP_NORMAL_FLOOR);
}
}
// objects
for ( j = 0 ; j < height; j++)
{
for ( i = 0 ; i < width; i++)
{
objectsMap[i][j] = 0;
if (i == 0 || j == 0 || i == width - 1 || j == height - 1)
logicalMap[i][j] = LogicalWall;
else
logicalMap[i][j] = LogicalFloor;
}
}
// alternative floor
for (i = 0; i < 8; i++)
{
if (rand() % 2 > 0)
{
map[1 + rand() % (MAP_WIDTH - 2)][1 + rand() % (MAP_HEIGHT - 2)] = floorOffset + 16 + i;
}
}
// alternative walls
for (i = 0; i < 8; i++)
{
if (rand() % 2 > 0)
{
int xTile = 0;
int yTile = 0;
int horizontal = rand() % 2;
if (horizontal == 0)
{
yTile = rand() % 2 == 0 ? 0 : MAP_HEIGHT - 1;
xTile = 1 + rand() % 12;
if (xTile > 6) xTile++;
}
else
{
xTile = rand() % 2 == 0 ? 0 : MAP_WIDTH - 1;
yTile = 1 + rand() % 6;
if (yTile > 3) yTile++;
}
map[xTile][yTile] = i + wallOffset + MAP_WALL_87 + 8;
}
}
// doors ?
if (gameFloor != NULL)
{
if (x > 0 && gameFloor->getRoom(x - 1, y) > 0)
{
map[0][MAP_HEIGHT / 2] = floorOffset;
map[0][MAP_HEIGHT / 2 - 1] = floorOffset;
map[0][MAP_HEIGHT / 2 + 1] = floorOffset;
openDoor(0, y0);
if (roomType == roomTypeBoss || gameFloor->getRoom(x - 1, y) == roomTypeBoss)
{
doorType[West] = DoorBoss;
}
else if (roomType == roomTypeChallenge || gameFloor->getRoom(x - 1, y) == roomTypeChallenge)
{
doorType[West] = DoorChallenge;
}
else if (gameFloor->getMap(x - 1, y)->isVisited())
{
doorType[West] = gameFloor->getMap(x - 1, y)->getDoorType(East);
}
else
{
doorType[West] = getRandomDoor();
}
}
if (x < MAP_WIDTH - 1 && gameFloor->getRoom(x + 1, y) > 0)
{
map[MAP_WIDTH - 1][MAP_HEIGHT / 2] = floorOffset;
map[MAP_WIDTH - 1][MAP_HEIGHT / 2 - 1] = floorOffset;
map[MAP_WIDTH - 1][MAP_HEIGHT / 2 + 1] = floorOffset;
openDoor(MAP_WIDTH - 1, y0);
if (roomType == roomTypeBoss || gameFloor->getRoom(x + 1, y) == roomTypeBoss)
{
doorType[East] = DoorBoss;
}
else if (roomType == roomTypeChallenge || gameFloor->getRoom(x + 1, y) == roomTypeChallenge)
{
doorType[East] = DoorChallenge;
}
else if (gameFloor->getMap(x + 1, y)->isVisited())
{
doorType[East] = gameFloor->getMap(x + 1, y)->getDoorType(West);
}
else
{
doorType[East] = getRandomDoor();
}
}
if (y > 0 && gameFloor->getRoom(x, y - 1) > 0)
{
map[MAP_WIDTH / 2][0] = floorOffset;
map[MAP_WIDTH / 2 - 1][0] = floorOffset;
map[MAP_WIDTH / 2 + 1][0] = floorOffset;
openDoor(x0, 0);
if (roomType == roomTypeBoss || gameFloor->getRoom(x, y - 1) == roomTypeBoss)
{
doorType[North] = DoorBoss;
}
else if (roomType == roomTypeChallenge || gameFloor->getRoom(x, y - 1) == roomTypeChallenge)
{
doorType[North] = DoorChallenge;
}
else if (gameFloor->getMap(x, y - 1)->isVisited())
{
doorType[North] = gameFloor->getMap(x, y - 1)->getDoorType(South);
}
else
{
doorType[North] = getRandomDoor();
}
}
if (y < MAP_HEIGHT -1 && gameFloor->getRoom(x, y + 1) > 0)
{
map[MAP_WIDTH / 2][MAP_HEIGHT - 1] = floorOffset;
map[MAP_WIDTH / 2 - 1][MAP_HEIGHT - 1] = floorOffset;
map[MAP_WIDTH / 2 + 1][MAP_HEIGHT - 1] = floorOffset;
openDoor(x0, MAP_HEIGHT -1);
if (roomType == roomTypeBoss || gameFloor->getRoom(x, y + 1) == roomTypeBoss)
{
doorType[South] = DoorBoss;
}
else if (roomType == roomTypeChallenge || gameFloor->getRoom(x, y + 1) == roomTypeChallenge)
{
doorType[South] = DoorChallenge;
}
else if (gameFloor->getMap(x, y + 1)->isVisited())
{
doorType[South] = gameFloor->getMap(x, y + 1)->getDoorType(North);
}
else
{
doorType[South] = getRandomDoor();
}
}
if (game().getLevel() > 1 && roomType == roomTypeStarting)
{
doorType[South] = getRandomDoor();
}
else if (roomType == roomTypeExit)
{
doorType[North] = DoorExit;
}
}
// test
for (int i = 0; i < 8; i++)
{
int objX = 1 + rand() % (MAP_WIDTH - 2);
int objY = 1 + rand() % (MAP_HEIGHT - 2);
- objectsMap[objX][objY] = MAPOBJ_BARREL;
+ if (i == 7) objectsMap[objX][objY] = MAPOBJ_BARREL_EXPL;
+ else objectsMap[objX][objY] = MAPOBJ_BARREL;
}
}
void DungeonMap::openDoor(int x, int y)
{
objectsMap[x][y] = MAPOBJ_DOOR_OPEN;
logicalMap[x][y] = LogicalFloor;
}
void DungeonMap::closeDoor(int x, int y)
{
objectsMap[x][y] = MAPOBJ_DOOR_CLOSED;
logicalMap[x][y] = LogicalWall;
}
bool DungeonMap::isDoor(int x, int y)
{
return objectsMap[x][y] == MAPOBJ_DOOR_OPEN || objectsMap[x][y] == MAPOBJ_DOOR_CLOSED;
}
void DungeonMap::makePatternTile(int x, int y)
{
if (map[x][y] < 24 * MAP_NB_FLOORS && (map[x][y] % 24) < 8) map[x][y] += 8;
else map[x][y] = floorOffset + 8 + rand() % 8;
}
void DungeonMap::initPattern(patternEnum n)
{
int i, j;
if (n == PatternSmallChecker)
{
for ( i = 2 ; i < width - 2 ; i++)
for ( j = 2 ; j < height - 2 ; j++)
{
if ((i + j) % 2 == 1) makePatternTile(i, j);
}
}
if (n == PatternBigChecker)
{
for ( i = 1 ; i < width - 1 ; i++)
for ( j = 1 ; j < height - 1 ; j++)
{
if ((i + j) % 2 == 1) makePatternTile(i, j);
}
}
if (n == PatternBorder)
{
for ( i = 1 ; i < width - 1 ; i++)
for ( j = 1 ; j < height - 1 ; j++)
{
if (i == 1 || j == 1 || i == width - 2 || j == height - 2)
makePatternTile(i, j);
}
}
if (n == PatternBigCircle)
{
for ( i = 2 ; i < width - 2 ; i++)
for ( j = 2 ; j < height - 2 ; j++)
{
if (i == 2 || j == 2 || i == width - 3 || j == height - 3)
makePatternTile(i, j);
}
}
if (n == PatternSmallCircle || n == PatternSmallStar)
{
for ( i = 5 ; i < 10 ; i++)
for ( j = 2 ; j < height - 2 ; j++)
{
if (i == 5 || i == 9 || j == 2 || j == height - 3)
makePatternTile(i, j);
}
}
if (n == PatternSmallStar)
{
makePatternTile(7, 1);
makePatternTile(7, height - 2);
makePatternTile(4, 4);
makePatternTile(10, 4);
}
if (n == PatternSmallDisc)
{
for ( i = 5 ; i < 10 ; i++)
for ( j = 2 ; j < height - 2 ; j++)
{
makePatternTile(i, j);
}
}
}
void DungeonMap::generateInselRoom()
{
for (int i = 1; i < MAP_WIDTH - 1; i++)
for (int j = 1; j < MAP_HEIGHT - 1; j++)
{
if (i != MAP_WIDTH / 2 && j != MAP_HEIGHT / 2
&& !(i == MAP_WIDTH / 2 - 1 && j == MAP_HEIGHT / 2 - 1)
&& !(i == MAP_WIDTH / 2 - 1 && j == MAP_HEIGHT / 2 + 1)
&& !(i == MAP_WIDTH / 2 + 1 && j == MAP_HEIGHT / 2 - 1)
&& !(i == MAP_WIDTH / 2 + 1 && j == MAP_HEIGHT / 2 + 1)
)
addHole(i, j);
}
objectsMap[MAP_WIDTH / 2 - 2][MAP_HEIGHT / 2 - 1] = MAPOBJ_WALL_SPECIAL;
objectsMap[MAP_WIDTH / 2 - 1][MAP_HEIGHT / 2 - 2] = MAPOBJ_WALL_SPECIAL;
logicalMap[MAP_WIDTH / 2 - 2][MAP_HEIGHT / 2 - 1] = LogicalObstacle;
logicalMap[MAP_WIDTH / 2 - 1][MAP_HEIGHT / 2 - 2] = LogicalObstacle;
objectsMap[MAP_WIDTH / 2 + 2][MAP_HEIGHT / 2 - 1] = MAPOBJ_WALL_SPECIAL + 1;
objectsMap[MAP_WIDTH / 2 + 1][MAP_HEIGHT / 2 - 2] = MAPOBJ_WALL_SPECIAL + 1;
logicalMap[MAP_WIDTH / 2 + 2][MAP_HEIGHT / 2 - 1] = LogicalObstacle;
logicalMap[MAP_WIDTH / 2 + 1][MAP_HEIGHT / 2 - 2] = LogicalObstacle;
objectsMap[MAP_WIDTH / 2 - 2][MAP_HEIGHT / 2 + 1] = MAPOBJ_WALL_SPECIAL + 2;
objectsMap[MAP_WIDTH / 2 - 1][MAP_HEIGHT / 2 + 2] = MAPOBJ_WALL_SPECIAL + 2;
logicalMap[MAP_WIDTH / 2 - 2][MAP_HEIGHT / 2 + 1] = LogicalObstacle;
logicalMap[MAP_WIDTH / 2 - 1][MAP_HEIGHT / 2 + 2] = LogicalObstacle;
objectsMap[MAP_WIDTH / 2 + 2][MAP_HEIGHT / 2 + 1] = MAPOBJ_WALL_SPECIAL + 3;
objectsMap[MAP_WIDTH / 2 + 1][MAP_HEIGHT / 2 + 2] = MAPOBJ_WALL_SPECIAL + 3;
logicalMap[MAP_WIDTH / 2 + 2][MAP_HEIGHT / 2 + 1] = LogicalObstacle;
logicalMap[MAP_WIDTH / 2 + 1][MAP_HEIGHT / 2 + 2] = LogicalObstacle;
if (!hasNeighbourUp())
addHole(MAP_WIDTH / 2, 1);
if (!hasNeighbourDown())
addHole(MAP_WIDTH / 2, MAP_HEIGHT - 2);
if (!hasNeighbourLeft())
for (int i = 0; i < 4; i++)
{
addHole(1 + i, MAP_HEIGHT / 2);
addHole(1 + i, MAP_HEIGHT / 2 + 1);
}
if (!hasNeighbourRight())
for (int i = 0; i < 4; i++)
{
addHole(MAP_WIDTH - 2 - i, MAP_HEIGHT / 2);
addHole(MAP_WIDTH - 2 - i, MAP_HEIGHT / 2 + 1);
}
addHole(MAP_WIDTH / 2 - 1 , MAP_HEIGHT - 2);
addHole(MAP_WIDTH / 2 + 1 , MAP_HEIGHT - 2);
addHole(MAP_WIDTH / 2 - 2 , MAP_HEIGHT - 3);
addHole(MAP_WIDTH / 2 + 2 , MAP_HEIGHT - 3);
if (rand() % 2 == 0) makePatternTile(MAP_WIDTH / 2, MAP_HEIGHT / 2);
}
Vector2D DungeonMap::generateBonusRoom()
{
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
initRoom();
if (game().getLevel() == 1 || rand() % 3 > 0)
{
if (rand() % 3 == 0)
{
if (rand() % 2 == 0) initPattern(PatternSmallDisc);
else initPattern(PatternSmallStar);
}
objectsMap[x0 - 1][y0 - 1] = MAPOBJ_WALL_SPECIAL;
objectsMap[x0 - 1][y0 + 1] = MAPOBJ_WALL_SPECIAL + 2;
objectsMap[x0 + 1][y0 - 1] = MAPOBJ_WALL_SPECIAL + 1;
objectsMap[x0 + 1][y0 + 1] = MAPOBJ_WALL_SPECIAL + 3;
logicalMap[x0 - 1][y0 - 1] = LogicalObstacle;
logicalMap[x0 - 1][y0 + 1] = LogicalObstacle;
logicalMap[x0 + 1][y0 - 1] = LogicalObstacle;
logicalMap[x0 + 1][y0 + 1] = LogicalObstacle;
}
else
{
generateInselRoom();
}
generateRandomTiles();
return (Vector2D(x0 * TILE_WIDTH + TILE_WIDTH / 2, y0 * TILE_HEIGHT + TILE_HEIGHT / 2));
}
Vector2D DungeonMap::generateChestRoom()
{
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
if (game().getLevel() == 1 || rand() % 3 > 0)
{
initRoom(); // (8 * 24, 2);
{
if (rand() % 2 == 0) initPattern(PatternSmallDisc);
else initPattern(PatternSmallStar);
}
objectsMap[x0 - 1][y0 - 1] = MAPOBJ_WALL_SPECIAL;
objectsMap[x0 - 1][y0 + 1] = MAPOBJ_WALL_SPECIAL + 2;
objectsMap[x0 + 1][y0 - 1] = MAPOBJ_WALL_SPECIAL + 1;
objectsMap[x0 + 1][y0 + 1] = MAPOBJ_WALL_SPECIAL + 3;
logicalMap[x0 - 1][y0 - 1] = LogicalObstacle;
logicalMap[x0 - 1][y0 + 1] = LogicalObstacle;
logicalMap[x0 + 1][y0 - 1] = LogicalObstacle;
logicalMap[x0 + 1][y0 + 1] = LogicalObstacle;
}
else
{
initRoom();
generateInselRoom();
}
generateRandomTiles();
return (Vector2D(x0 * TILE_WIDTH + TILE_WIDTH / 2, y0 * TILE_HEIGHT + TILE_HEIGHT / 2));
}
void DungeonMap::generateTemple(int x, int y, enumDivinityType type)
{
map[x][y] = MAP_TEMPLE + (int)type;
addHole(x - 1, y - 2);
addHole(x - 1, y - 1);
addHole(x - 1, y);
addHole(x + 1, y - 2);
addHole(x + 1, y - 1);
addHole(x + 1, y );
objectsMap[x][y - 2] = MAPOBJ_TEMPLE_WALL + (int)type;
objectsMap[x][y - 1] = MAPOBJ_TEMPLE_WALL + 10 + (int)type;
logicalMap[x][y - 2] = LogicalObstacle;
logicalMap[x][y - 1] = LogicalObstacle;
}
void DungeonMap::generateTempleRoom()
{
initRoom();
int x0 = MAP_WIDTH / 2;
int y0 = 1 + MAP_HEIGHT / 2;
if (rand() % 3 == 0)
{
if (rand() % 2 == 0) initPattern(PatternSmallDisc);
else initPattern(PatternSmallStar);
}
int d0, d1, d2;
d0 = rand() % NB_DIVINITY;
d1 = d0;
while (d0 == d1) d1 = rand() % NB_DIVINITY;
if (rand() % 2 == 0)
{
// three temple
d2 = d0;
while (d0 == d2 || d1 == d2) d2 = rand() % NB_DIVINITY;
generateTemple(x0 - 2, y0, (enumDivinityType)d0);
generateTemple(x0 + 2, y0, (enumDivinityType)d1);
generateTemple(x0, y0, (enumDivinityType)d2);
}
else
{
// two temples
generateTemple(x0 - 1, y0, (enumDivinityType)d0);
generateTemple(x0 + 1, y0, (enumDivinityType)d1);
}
// no random tiles in temples
//generateRandomTiles();
}
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;
}
}
void DungeonMap::generateTable(int x0, int y0, int w, int h, int n)
{
int xf = x0 + w - 1;
int yf = y0 + h - 1;
objectsMap[x0][y0] = n;
objectsMap[x0][yf] = n + 6;
objectsMap[xf][y0] = n + 2;
objectsMap[xf][yf] = n + 8;
int i, j;
for (i = x0 + 1; i <= xf - 1; i++)
{
objectsMap[i][y0] = n + 1;
objectsMap[i][yf] = n + 7;
for (j = y0 + 1; j <= yf - 1; j++)
objectsMap[i][j] = n + 4;
}
for (j = y0 + 1; j <= yf - 1; j++)
{
objectsMap[x0][j] = n + 3;
objectsMap[xf][j] = n + 5;
}
for (i = x0; i <= xf; i++)
for (j = y0; j <= yf; j++)
logicalMap[i][j] = LogicalObstacle;
}
void DungeonMap::generateLongObject(int x0, int y0, int w, int n)
{
int xf = x0 + w - 1;
objectsMap[x0][y0] = n;
logicalMap[x0][y0] = LogicalObstacle;
for (int i = x0 + 1; i <= xf - 1; i++)
{
objectsMap[i][y0] = n + 1;
logicalMap[i][y0] = LogicalObstacle;
}
objectsMap[xf][y0] = n + 2;
logicalMap[xf][y0] = LogicalObstacle;
}
Vector2D DungeonMap::generateMerchantRoom()
{
initRoom();
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
for (int i = x0 - 3; i <= x0 + 3; i++)
{
if (i == x0 - 3) objectsMap[i][y0] = MAPOBJ_SHOP_LEFT;
else if (i == x0 + 3) objectsMap[i][y0] = MAPOBJ_SHOP_RIGHT;
else objectsMap[i][y0] = MAPOBJ_SHOP;
logicalMap[i][y0] = LogicalObstacle;
}
if (!hasNeighbourUp())
{
objectsMap[x0 - 1][0] = MAPOBJ_PNW;
objectsMap[x0][0] = MAPOBJ_PNW + 1;
objectsMap[x0 + 1][0] = MAPOBJ_PNW + 2;
}
else
{
objectsMap[x0 - 1][MAP_HEIGHT - 1] = MAPOBJ_PNW +3;
objectsMap[x0][MAP_HEIGHT - 1] = MAPOBJ_PNW + 4;
objectsMap[x0 + 1][MAP_HEIGHT - 1] = MAPOBJ_PNW + 5;
}
generateRandomTiles();
return (Vector2D(x0 * TILE_WIDTH + TILE_WIDTH / 2, y0 * TILE_HEIGHT + TILE_HEIGHT / 2));
}
Vector2D DungeonMap::generateKeyRoom()
{
initRoom();
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
objectsMap[x0 - 1][y0 - 1] = MAPOBJ_WALL_SPECIAL;
objectsMap[x0 - 1][y0 + 1] = MAPOBJ_WALL_SPECIAL + 2;
objectsMap[x0 + 1][y0 - 1] = MAPOBJ_WALL_SPECIAL + 1;
objectsMap[x0 + 1][y0 + 1] = MAPOBJ_WALL_SPECIAL + 3;
logicalMap[x0 - 1][y0 - 1] = LogicalObstacle;
logicalMap[x0 - 1][y0 + 1] = LogicalObstacle;
logicalMap[x0 + 1][y0 - 1] = LogicalObstacle;
logicalMap[x0 + 1][y0 + 1] = LogicalObstacle;
if (rand() % 3 == 0)
{
if (rand() % 2 == 0) initPattern(PatternSmallCircle);
else initPattern(PatternSmallStar);
}
generateCarpet(x0 - 1, y0 - 1, 3, 3, MAP_CARPET);
generateRandomTiles();
return (Vector2D(x0 * TILE_WIDTH + TILE_WIDTH / 2, y0 * TILE_HEIGHT + TILE_HEIGHT / 2));
}
void DungeonMap::generateExitRoom()
{
initRoom();
int x0 = MAP_WIDTH / 2;
map[x0][0] = floorOffset;
map[x0 - 1][0] = floorOffset;
map[x0 + 1][0] = floorOffset;
logicalMap[x0][0] = LogicalFloor;
if (rand() % 3 == 0) initPattern(PatternBorder);
generateRandomTiles();
}
void DungeonMap::generateRoomRandom(int type)
{
if (rand() % 3 == 0) generateRoomWithHoles(type);
else generateRoomWithoutHoles(type);
}
void DungeonMap::generateRoomWithoutHoles(int type)
{
initRoom();
int x0 = MAP_WIDTH / 2;
int y0 = MAP_HEIGHT / 2;
int i, j, r;
if (type <= 0) // empty room
{
if (roomType == roomTypeStarting)
{
generateCarpet(5, 3, 5, 3, MAP_CARPET);
if (game().getLevel() > 1)
{
map[x0][MAP_HEIGHT - 1] = floorOffset;
}
}
else if (roomType == roomTypeBoss && (game().getLevel() == 2) ) // giant slime
{
// good ?
objectsMap[1][1] = MAPOBJ_GRID;
objectsMap[1][MAP_HEIGHT -2] = MAPOBJ_GRID;
objectsMap[MAP_WIDTH - 2][1] = MAPOBJ_GRID;
objectsMap[MAP_WIDTH - 2][MAP_HEIGHT -2] = MAPOBJ_GRID;
}
if (roomType == roomTypeStandard)
{
if (rand() % 3 > 0 && gameFloor->neighboorCount(x, y) > 1)
{
if (type == 0 && game().getLevel() < 6) generateCorridors();
}
else
{
if (rand() % 3 == 0) initPattern((patternEnum)(rand() % 4));
}
}
}
if (type == 1) // corner block
{
if (rand() % 3 == 0) initPattern(PatternSmallChecker);
int wallOffset = wallType * 24;
map[0][0] = MAP_WALL_X;
map[0][1] = wallOffset + MAP_WALL_7;
map[1][1] = wallOffset + MAP_WALL_77;
map[1][0] = wallOffset + MAP_WALL_7;
logicalMap[1][1] = LogicalWall;
map[0][MAP_HEIGHT - 1] = MAP_WALL_X;
map[0][MAP_HEIGHT - 2] = wallOffset + MAP_WALL_7;
map[1][MAP_HEIGHT - 2] = wallOffset + MAP_WALL_77;
map[1][MAP_HEIGHT - 1] = wallOffset + MAP_WALL_7;
logicalMap[1][MAP_HEIGHT -2] = LogicalWall;
map[MAP_WIDTH - 1][0] = MAP_WALL_X;
map[MAP_WIDTH - 1][1] = wallOffset + MAP_WALL_7;
map[MAP_WIDTH - 2][1] = wallOffset + MAP_WALL_77;
map[MAP_WIDTH - 2][0] = wallOffset + MAP_WALL_7;
logicalMap[MAP_WIDTH - 2][1] = LogicalWall;
map[MAP_WIDTH - 1][MAP_HEIGHT -1] = MAP_WALL_X;
map[MAP_WIDTH - 1][MAP_HEIGHT -2] = wallOffset + MAP_WALL_7;
map[MAP_WIDTH - 2][MAP_HEIGHT -2] = wallOffset + MAP_WALL_77;
map[MAP_WIDTH - 2][MAP_HEIGHT -1] = wallOffset + MAP_WALL_7;
logicalMap[MAP_WIDTH - 2][MAP_HEIGHT -2] = LogicalWall;
}
if (type == 2) // blocks in the middle
{
if (rand() % 3 == 0) initPattern(PatternBorder);
r = 1 + rand() % 3;
generateTable(x0 - r, y0 - 1, 1 + 2 * r, 3, MAPOBJ_BIG_OBSTACLE);
}
if (type == 3)
{
// big blocks in the corners
generateTable(2, 2, 2, 2, MAPOBJ_BIG_OBSTACLE);
generateTable(2, MAP_HEIGHT - 4, 2, 2, MAPOBJ_BIG_OBSTACLE);
generateTable(MAP_WIDTH - 4, MAP_HEIGHT - 4, 2, 2, MAPOBJ_BIG_OBSTACLE);
generateTable(MAP_WIDTH - 4, 2, 2, 2, MAPOBJ_BIG_OBSTACLE);
}
if (type == 4)
{
// objects
if (rand() % 2 == 0)
{
// type 1
if (rand() % 3 == 0) initPattern(PatternSmallChecker);
bool leftOriented = rand() % 2 == 0;
int bankType = rand() % 4;
if (bankType == 2)
{
int xPlayer = game().getPlayerPosition().x;
if (xPlayer > GAME_WIDTH / 2 - TILE_WIDTH && xPlayer < GAME_WIDTH / 2 + TILE_WIDTH)
bankType = rand() % 2;
}
int x0 = leftOriented ? 5 : 3;
if (leftOriented)
{
objectsMap[2][4] = MAPOBJ_CHURCH_FURN_L;
logicalMap[2][4] = LogicalObstacle;
}
else
{
objectsMap[12][4] = MAPOBJ_CHURCH_FURN_R;
logicalMap[12][4] = LogicalObstacle;
}
for (int i = 0; i < 3; i++)
{
int xPos = x0 + i * 3;
switch (bankType)
{
case 0:
objectsMap[xPos][2] = MAPOBJ_BANK_TOP;
objectsMap[xPos][3] = MAPOBJ_BANK_BOTTOM;
objectsMap[xPos][5] = MAPOBJ_BANK_TOP;
objectsMap[xPos][6] = MAPOBJ_BANK_BOTTOM;
for (int j = 2; j <= 6; j++) if (j != 4) logicalMap[xPos][j] = LogicalObstacle;
break;
case 1:
objectsMap[xPos][2] = MAPOBJ_BANK_TOP;
objectsMap[xPos][3] = MAPOBJ_BANK;
objectsMap[xPos][4] = MAPOBJ_BANK;
objectsMap[xPos][5] = MAPOBJ_BANK;
objectsMap[xPos][6] = MAPOBJ_BANK_BOTTOM;
for (int j = 2; j <= 6; j++) logicalMap[xPos][j] = LogicalObstacle;
break;
default:
objectsMap[xPos][1] = MAPOBJ_BANK_TOP;
objectsMap[xPos][2] = MAPOBJ_BANK;
objectsMap[xPos][3] = MAPOBJ_BANK_BOTTOM;
objectsMap[xPos][5] = MAPOBJ_BANK_TOP;
objectsMap[xPos][6] = MAPOBJ_BANK;
objectsMap[xPos][7] = MAPOBJ_BANK_BOTTOM;
for (int j = 1; j <= 7; j++) if (j != 4) logicalMap[xPos][j] = LogicalObstacle;
break;
}
}
}
else
{
initPattern(PatternSmallStar);
generateLongObject(2, 2, 3, MAPOBJ_LONG_LEFT);
generateLongObject(2, 6, 3, MAPOBJ_LONG_LEFT);
generateLongObject(10, 2, 3, MAPOBJ_LONG_LEFT);
generateLongObject(10, 6, 3, MAPOBJ_LONG_LEFT);
generateLongObject(6, 4, 3, MAPOBJ_LONG_LEFT);
}
}
if (type == ROOM_TYPE_CHECKER)
{
// "checker"
if (rand() % 3 == 0) initPattern(PatternSmallChecker);
for (i = 2; i < MAP_WIDTH - 2; i = i + 2)
for (j = 2; j < MAP_HEIGHT - 2; j = j + 2)
{
objectsMap[i][j] = game().getLevel() >= 6 ? MAPOBJ_TOMB : MAPOBJ_OBSTACLE;
logicalMap[i][j] = LogicalObstacle;
}
}
generateRandomTiles();
}
void DungeonMap::addHole(int x, int y)
{
int n = MAPOBJ_HOLE;
if (y > 0 && logicalMap[x][y - 1] == LogicalHole)
n = MAPOBJ_HOLE_BOTTOM;
else if (logicalMap[x - 1][y] == LogicalHole && logicalMap[x - 1][y - 1] == LogicalHole)
n = MAPOBJ_HOLE_LEFT;
else if (logicalMap[x + 1][y] == LogicalHole && logicalMap[x + 1][y - 1] == LogicalHole)
n = MAPOBJ_HOLE_RIGHT;
objectsMap[x][y] = n;
logicalMap[x][y] = LogicalHole;
if (logicalMap[x][y + 1] == LogicalHole && objectsMap[x - 1][y + 1] == MAPOBJ_HOLE_TOP)
objectsMap[x - 1][y + 1] = MAPOBJ_HOLE_LEFT;
if (logicalMap[x][y + 1] == LogicalHole && objectsMap[x + 1][y + 1] == MAPOBJ_HOLE_TOP)
objectsMap[x + 1][y + 1] = MAPOBJ_HOLE_RIGHT;
}
void DungeonMap::generateRoomWithHoles(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, MAP_CARPET);
if (game().getLevel() > 1)
{
map[x0 - 1][MAP_HEIGHT - 1] = 62;
map[x0][MAP_HEIGHT - 1] = 63;
map[x0 + 1][MAP_HEIGHT - 1] = 64;
}
}
/*else if (rand() % 2 == 0)
{
for (int i = 1; i <= MAP_WIDTH - 2; i++)
{
if (i != MAP_WIDTH / 2 || !hasNeighbourUp()) addHole(i, 1);
}
for (int i = 2; i <= MAP_HEIGHT - 3; i++)
{
if (i != MAP_HEIGHT / 2 || !hasNeighbourLeft()) addHole(1, i);
if (i != MAP_HEIGHT / 2 || !hasNeighbourRight()) addHole(MAP_WIDTH - 2, i);
}
addHole(MAP_WIDTH - 2, MAP_HEIGHT - 2);
for (int i = 1; i <= MAP_WIDTH - 3; i++)
{
if (i != MAP_WIDTH / 2 || !hasNeighbourDown()) addHole(i, MAP_HEIGHT - 2);
}
}*/
}
else if (type == 1)
{
// corner hole
if (rand() % 3 == 0) initPattern(PatternSmallChecker);
addHole(1, 1);
addHole(MAP_WIDTH - 2, MAP_HEIGHT -2);
addHole(1, MAP_HEIGHT -2);
addHole(MAP_WIDTH - 2, 1);
}
else if (type == 2)
{
// blocks in the middle
if (rand() % 3 == 0) initPattern(PatternBorder);
/*if (false) //irregular // TO CORRECT
{
r = 1; //rand() % 2;
for (i = x0 - r; i <= x0 + r; i++)
{
if (rand() % 3 == 0) addHole(i, y0 - 1);
addHole(i, y0);
if (rand() % 3 == 0) addHole(i, y0 + 1);
}
for (j = y0 - 1; j <= y0 + 1; j++)
{
if (rand() % 3 == 0) addHole(x0 - r - 1, j);
if (rand() % 3 == 0) addHole(x0 + r + 1, j);
}
}
else*/
{
r = 1 + rand() % 2;
for (i = x0 - r; i <= x0 + r; i++)
for (j = y0 - 1; j <= y0 + 1; j++)
{
addHole(i, j);
}
}
}
else if (type == 3)
{
// 4 holes
addHole(2, 2);
addHole(2, 3);
addHole(3, 2);
addHole(3, 3);
addHole(MAP_WIDTH - 4, 2);
addHole(MAP_WIDTH - 4, 3);
addHole(MAP_WIDTH - 3, 2);
addHole(MAP_WIDTH - 3, 3);
addHole(2, MAP_HEIGHT - 4);
addHole(2, MAP_HEIGHT - 3);
addHole(3, MAP_HEIGHT - 4);
addHole(3, MAP_HEIGHT - 3);
addHole(MAP_WIDTH - 4, MAP_HEIGHT - 4);
addHole(MAP_WIDTH - 4, MAP_HEIGHT - 3);
addHole(MAP_WIDTH - 3, MAP_HEIGHT - 4);
addHole(MAP_WIDTH - 3, MAP_HEIGHT - 3);
}
else if (type == 4)
{
if (rand() % 2 == 0)
{
// holes and (sometimes) obstacles randomly
if (rand() % 3 == 0) initPattern(PatternBigCircle);
int r = 6 + rand()% 5;
int obstacleType = rand() % 2;
for (int i = 0; i < r; i++)
{
int rx = 1 + rand() % (MAP_WIDTH - 3);
int ry = 1 + rand() % (MAP_HEIGHT - 3);
bool ok = true;
bool isObstacle = (obstacleType == 1) && rand() % 2 == 0;
if ( (rx == 1 && ry == MAP_HEIGHT / 2)
|| (rx == MAP_WIDTH - 2 && ry == MAP_HEIGHT / 2)
|| (rx == MAP_WIDTH /2 && ry == MAP_HEIGHT - 2)
|| (rx == MAP_WIDTH /2 && ry == 1) )
{
ok = false;
}
else
{
for (int ix = -1; ix <= 1; ix++)
for (int iy = -1; iy <= 1; iy++)
{
ok = ok && logicalMap[rx + ix][ry + iy] != LogicalHole;
ok = ok && logicalMap[rx + ix][ry + iy] != LogicalObstacle;
}
}
if (ok)
{
if (!isObstacle)
{
addHole(rx, ry);
}
else
{
objectsMap[rx][ry] = MAPOBJ_OBSTACLE;
logicalMap[rx][ry] = LogicalObstacle;
}
}
else
{
i--;
}
}
}
else
{
// big holes left and right
bool holesNW = rand() % 2 == 0;
for (int i = 0; i < 5; i++)
{
if (holesNW)
{
addHole(1 + i, 1);
addHole(1 + i, 2);
addHole(MAP_WIDTH - 2 - i, MAP_HEIGHT - 3);
addHole(MAP_WIDTH - 2 - i, MAP_HEIGHT - 2);
}
else
{
addHole(1 + i, MAP_HEIGHT - 3);
addHole(1 + i, MAP_HEIGHT - 2);
addHole(MAP_WIDTH - 2 - i, 1);
addHole(MAP_WIDTH - 2 - i, 2);
}
}
}
}
else //if (type == 5)
{
// "checker"
for (i = 2; i < MAP_WIDTH - 2; i = i + 2)
for (j = 2; j < MAP_HEIGHT - 2; j = j + 2)
{
addHole(i, j);
}
}
generateRandomTiles();
}
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);
}
}
void DungeonMap::restoreSprites()
{
SpriteList::iterator it;
for (it = spriteList.begin (); it != spriteList.end ();)
{
spriteListElement ilm = *it;
it++;
if (ilm.type == ENTITY_BLOOD)
game().getCurrentMapEntity()->addBlood(ilm.x, ilm.y, ilm.frame, ilm.scale);
else if (ilm.type == ENTITY_CORPSE)
game().getCurrentMapEntity()->addCorpse(ilm.x, ilm.y, ilm.frame);
}
}
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);
}
}
void DungeonMap::restoreMapObjects()
{
restoreItems();
restoreSprites();
restoreChests();
cleanMapObjects();
}
void DungeonMap::cleanMapObjects()
{
itemList.clear();
spriteList.clear();
chestList.clear();
}
void DungeonMap::addRandomGrids(int n)
{
int counter = n;
while (counter > 0)
{
int rx = 1 + rand() % (MAP_WIDTH - 2);
int ry = 1 + rand() % (MAP_HEIGHT - 2);
if (logicalMap[rx][ry] == LogicalFloor
|| objectsMap[rx][ry] == 0)
{
objectsMap[rx][ry] = MAPOBJ_GRID;
counter--;
}
}
}
void DungeonMap::generateCorridors()
{
int xCor = 1 + rand()% 4;
int yCor = 1 + rand()% 1;
int wallOffset = wallType * 24;
if (!hasNeighbourLeft())
{
for (int i = 0; i < xCor; i++)
for (int j = 0; j < MAP_HEIGHT; j++)
{
map[i][j] = MAP_WALL_X;
logicalMap[i][j] = LogicalWall;
}
}
if (!hasNeighbourRight())
{
for (int i = MAP_WIDTH - 1; i > MAP_WIDTH - 1 - xCor; i--)
for (int j = 0; j < MAP_HEIGHT; j++)
{
map[i][j] = MAP_WALL_X;
logicalMap[i][j] = LogicalWall;
}
}
if (!hasNeighbourUp())
{
for (int i = 0; i < MAP_WIDTH; i++)
for (int j = 0; j < yCor; j++)
{
map[i][j] = MAP_WALL_X;
logicalMap[i][j] = LogicalWall;
}
}
if (!hasNeighbourDown())
{
for (int i = 0; i < MAP_WIDTH; i++)
for (int j = MAP_HEIGHT - 1; j > MAP_HEIGHT - 1 - yCor; j--)
{
map[i][j] = MAP_WALL_X;
logicalMap[i][j] = LogicalWall;
}
}
//
for (int i = 0; i < MAP_WIDTH; i++)
{
for (int j = 0; j < MAP_HEIGHT; j++)
{
if (map[i][j] != MAP_WALL_X)
{
if (getTile(i - 1, j) == MAP_WALL_X)
{
if (j == 0 || getTile(i, j - 1) == MAP_WALL_X)
{
map[i][j] = wallOffset + MAP_WALL_7;
}
else if (j == MAP_HEIGHT - 1 || getTile(i, j + 1) == MAP_WALL_X)
{
map[i][j] = wallOffset + MAP_WALL_7;
}
else
{
if (j < MAP_HEIGHT / 2) map[i][j] = wallOffset + MAP_WALL_87 + rand() % 8;
else if (j > MAP_HEIGHT / 2) map[i][j] = wallOffset + MAP_WALL_87 + rand() % 8;
else map[i][j] = wallOffset + MAP_WALL_8;
}
logicalMap[i][j] = LogicalWall;
}
else if (getTile(i + 1, j) == MAP_WALL_X)
{
if (j == 0 || getTile(i, j - 1) == MAP_WALL_X)
{
map[i][j] = wallOffset + MAP_WALL_7;
map[i][j] = wallOffset + MAP_WALL_7;
}
else if (j == MAP_HEIGHT - 1 || getTile(i, j + 1) == MAP_WALL_X) map[i][j] = wallOffset + MAP_WALL_7;
else
{
if (j < MAP_HEIGHT / 2) map[i][j] = wallOffset + MAP_WALL_87 + rand() % 8;
else if (j > MAP_HEIGHT / 2) map[i][j] = wallOffset + MAP_WALL_87 + rand() % 8;
else map[i][j] = wallOffset + MAP_WALL_8;
}
logicalMap[i][j] = LogicalWall;
}
else if (getTile(i, j - 1) == MAP_WALL_X)
{
if (i == 0) map[i][j] = wallOffset + MAP_WALL_7;
else if (i == MAP_WIDTH - 1) map[i][j] = wallOffset + MAP_WALL_7;
else
{
if (i < MAP_WIDTH / 2) map[i][j] = wallOffset + MAP_WALL_87 + rand() % 8;
else if (i > MAP_WIDTH / 2) map[i][j] = wallOffset + MAP_WALL_87 + rand() % 8;
else map[i][j] = wallOffset + MAP_WALL_8;
}
logicalMap[i][j] = LogicalWall;
}
else if (getTile(i, j + 1) == MAP_WALL_X)
{
if (i == 0) map[i][j] = wallOffset + MAP_WALL_7;
else if (i == MAP_WIDTH - 1) map[i][j] = wallOffset + MAP_WALL_7;
else
{
if (i < MAP_WIDTH / 2) map[i][j] = wallOffset + MAP_WALL_87 + rand() % 8;
else if (i > MAP_WIDTH / 2) map[i][j] = wallOffset + MAP_WALL_87 + rand() % 8;
else map[i][j] = wallOffset + MAP_WALL_8;
}
logicalMap[i][j] = LogicalWall;
}
}
}
}
}
void DungeonMap::generateRandomTiles()
{
for (int i = 0; i < NB_RANDOM_TILES_IN_ROOM; i++)
generateRandomTile(i);
}
void DungeonMap::generateRandomTile(int index)
{
bool ok = false;
for (int i = 0; !ok && i < NB_RANDOM_TILE_TRY; i++)
{
int n = rand() % NB_RANDOM_TILES;
int xTile, yTile;
if (randomDungeonTiles[n].canBeOnWall)
{
xTile = rand() % (GAME_WIDTH - randomDungeonTiles[n].width);
yTile = rand() % (GAME_HEIGHT - randomDungeonTiles[n].height);
}
else
{
xTile = TILE_WIDTH + rand() % (GAME_WIDTH - 2 * TILE_WIDTH - randomDungeonTiles[n].width);
yTile = TILE_HEIGHT + rand() % (GAME_HEIGHT - 2 * TILE_HEIGHT - randomDungeonTiles[n].height);
}
int x0 = xTile / TILE_WIDTH;
int xf = (xTile + randomDungeonTiles[n].width) / TILE_WIDTH;
int y0 = yTile / TILE_HEIGHT;
int yf = (yTile + randomDungeonTiles[n].height) / TILE_HEIGHT;
ok = true;
// proceed rarity
if (randomDungeonTiles[n].rarity > 1 && (rand() % randomDungeonTiles[n].rarity) != 0 )
{
ok = false;
}
// each random sprite type should be present no more that once in a room
for (int j = 0; j < index; j++)
{
if (n == randomTileElements[j].type) ok = false;
}
if (!randomDungeonTiles[n].randomPlace || roomType == roomTypeKey)
{
for (int ix = x0; ix <= xf; ix++)
for (int iy = y0; iy <= yf; iy++)
{
ok = ok && isWalkable(ix, iy);
}
}
if (ok && !randomDungeonTiles[n].canBeOnWall)
{
for (int ix = x0; ix <= xf; ix++)
for (int iy = y0; iy <= yf; iy++)
{
ok = ok && isFlyable(ix, iy);
}
}
if (ok)
{
randomTileElements[index].type = n;
randomTileElements[index].x = xTile;
randomTileElements[index].y = yTile;
if (randomDungeonTiles[n].canRotate)
randomTileElements[index].rotation = rand()% 360;
else
randomTileElements[index].rotation = 0;
}
}
}
diff --git a/src/DungeonMap.h b/src/DungeonMap.h
index 281013a..2c0e98c 100644
--- a/src/DungeonMap.h
+++ b/src/DungeonMap.h
@@ -1,278 +1,280 @@
#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 = 1010;
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 e488e7c..d2c9746 100644
--- a/src/ObstacleEntity.cpp
+++ b/src/ObstacleEntity.cpp
@@ -1,141 +1,198 @@
#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;
- bloodColor = BloodBarrel;
+ explosive = false;
dyingSound = SOUND_BARREL_SMASH;
hurtingSound = SOUND_BARREL_HIT;
+ bloodColor = BloodNone;
+ obstacleBloodType = BloodBarrel;
age = 0.0f;
frame = 0;
xGrid = x / TILE_WIDTH;
yGrid = y / TILE_HEIGHT;
game().getCurrentMap()->setObjectTile(xGrid, yGrid, objectFrame);
game().getCurrentMap()->setLogicalTile(xGrid, yGrid, LogicalDestroyable);
switch (objectFrame)
{
+ //standard barrel
case MAPOBJ_BARREL:
hp = 18;
hpMax = 18;
initialFrame = 0;
+ deathFrame = FRAME_CORPSE_BARREL;
break;
case MAPOBJ_BARREL + 1:
hp = 12;
hpMax = 12;
initialFrame = 0;
frame = 1;
+ deathFrame = FRAME_CORPSE_BARREL;
break;
case MAPOBJ_BARREL + 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;
+ 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;
}
resistance[ResistanceFrozen] = ResistanceImmune;
resistance[ResistanceRecoil] = ResistanceImmune;
resistance[ResistanceFire] = ResistanceVeryLow;
resistance[ResistancePoison] = ResistanceImmune;
canExplode = false;
}
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();
}
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);
}
}
+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 b2d1849..d0f2612 100644
--- a/src/ObstacleEntity.h
+++ b/src/ObstacleEntity.h
@@ -1,28 +1,31 @@
#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);
protected:
virtual void drop();
private:
int xGrid;
int yGrid;
int initialFrame;
void correctFrame();
+ bool explosive;
+ enumBloodColor obstacleBloodType;
};
#endif // OBSTACLEENTITY_H
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jun 16, 12:22 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70447
Default Alt Text
(83 KB)
Attached To
Mode
R78 witchblast
Attached
Detach File
Event Timeline