Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
40 KB
Referenced Files
None
Subscribers
None
diff --git a/src/GiantSlimeEntity.cpp b/src/GiantSlimeEntity.cpp
index ee4f87e..396e7b2 100644
--- a/src/GiantSlimeEntity.cpp
+++ b/src/GiantSlimeEntity.cpp
@@ -1,464 +1,469 @@
#include "GiantSlimeEntity.h"
#include "BoltEntity.h"
#include "EnemyBoltEntity.h"
#include "PlayerEntity.h"
#include "SlimeEntity.h"
#include "sfml_game/SpriteEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
#include "TextMapper.h"
#include <iostream>
GiantSlimeEntity::GiantSlimeEntity(float x, float y)
: EnemyEntity (ImageManager::getInstance().getImage(IMAGE_GIANT_SLIME), x, y)
{
width = 128;
height = 128;
creatureSpeed = GIANT_SLIME_SPEED;
velocity = Vector2D(creatureSpeed);
hp = GIANT_SLIME_HP;
hpDisplay = hp;
hpMax = GIANT_SLIME_HP;
meleeDamages = GIANT_SLIME_DAMAGES;
missileDelay = GIANT_SLIME_MISSILE_DELAY;
type = ENTITY_ENEMY_BOSS;
enemyType = EnemyTypeSlimeBoss;
bloodColor = BloodGreen;
shadowFrame = 3;
frame = 0;
sprite.setOrigin(64.0f, 64.0f);
h = 0.0f;
age = -2.0f;
changeToState(0);
slimeCounter = 0;
slimeTimer =5.0f;
resistance[ResistanceFrozen] = ResistanceVeryHigh;
resistance[ResistanceRecoil] = ResistanceVeryHigh;
resistance[ResistancePoison] = ResistanceVeryHigh;
sprite.setOrigin(64, 84);
canExplode = false;
}
void GiantSlimeEntity::changeToState(int n)
{
if (n == 0) // walking
{
state = 0;
counter = 8 + rand() % 7;
timer = -1.0f;
viscosity = 1.0f;
}
else if (n == 1 || n == 3 || n == 5 || n == 8) // waiting
{
state = n;
timer = 1.2f;
setVelocity(Vector2D(0.0f, 0.0f));
}
else if (n == 2) // jumping
{
state = 2;
timer = 4.0f;
viscosity = 0.991f;
SoundManager::getInstance().playSound(SOUND_SLIME_JUMP);
hVelocity = 420.0f + rand() % 380;
isFirstJumping = true;
float randVel = 350.0f + rand() % 200;
if (rand() % 2 == 0)
{
float tan = (game().getPlayer()->getX() - x) / (game().getPlayer()->getY() - y);
float angle = atan(tan);
if (game().getPlayer()->getY() > y)
setVelocity(Vector2D(sin(angle) * randVel,
cos(angle) * randVel));
else
setVelocity(Vector2D(-sin(angle) * randVel,
-cos(angle) * randVel));
}
else
velocity = Vector2D(randVel);
}
else if (n == 4) // walking
{
state = 4;
if (hp <= hpMax / 4)
counter = 26;
if (hp <= hpMax / 2)
counter = 18;
else
counter = 12;
timer = GIANT_SLIME_MISSILE_DELAY;
}
else if (n == 6) // jumping
{
state = 6;
timer = 1.2f;
viscosity = 1.0f;
SoundManager::getInstance().playSound(SOUND_SLIME_JUMP);
hVelocity = GIANT_SLIME_ULTRA_JUMP_VELOCITY;
}
else if (n == 7) // falling
{
isFalling = false;
state = 7;
timer = GIANT_SLIME_ULTRA_JUMP_TIMER;
hVelocity = GIANT_SLIME_ULTRA_FALL_VELOCITY;
h = 1500;
}
}
void GiantSlimeEntity::animate(float delay)
{
slimeTimer -= delay;
if (slimeTimer <= 0.0f)
{
+ slimeTypeEnum slimeType = SlimeTypeStandard;
+ if (game().isAdvancedLevel())
+ {
+ slimeType = (slimeTypeEnum)(slimeType + rand() % 3);
+ }
switch (slimeCounter)
{
case 0:
- new SlimeEntity(TILE_WIDTH * 1.5f, TILE_HEIGHT * 1.5f, SlimeTypeStandard, true);
+ new SlimeEntity(TILE_WIDTH * 1.5f, TILE_HEIGHT * 1.5f, slimeType, true);
break;
case 1:
- new SlimeEntity(TILE_WIDTH * (MAP_WIDTH - 2) + TILE_WIDTH * 0.5f, TILE_HEIGHT * 1.5f, SlimeTypeStandard, true);
+ new SlimeEntity(TILE_WIDTH * (MAP_WIDTH - 2) + TILE_WIDTH * 0.5f, TILE_HEIGHT * 1.5f, slimeType, true);
break;
case 2:
- new SlimeEntity(TILE_WIDTH * (MAP_WIDTH - 2) + TILE_WIDTH * 0.5f, TILE_HEIGHT * (MAP_HEIGHT - 2) + TILE_HEIGHT * 0.5f, SlimeTypeStandard, true);
+ new SlimeEntity(TILE_WIDTH * (MAP_WIDTH - 2) + TILE_WIDTH * 0.5f, TILE_HEIGHT * (MAP_HEIGHT - 2) + TILE_HEIGHT * 0.5f, slimeType, true);
break;
case 3:
- new SlimeEntity(TILE_WIDTH * 1.5f, TILE_HEIGHT * (MAP_HEIGHT - 2) + TILE_HEIGHT * 0.5f, SlimeTypeStandard, true);
+ new SlimeEntity(TILE_WIDTH * 1.5f, TILE_HEIGHT * (MAP_HEIGHT - 2) + TILE_HEIGHT * 0.5f, slimeType, true);
break;
}
slimeTimer = 7.0f;
slimeCounter ++;
if (slimeCounter == 4) slimeCounter = 0;
}
if (age <= 0.0f)
{
age += delay;
return;
}
EnemyEntity::animate(delay);
if (specialState[SpecialStateIce].active) delay *= specialState[SpecialStateIce].param1;
timer -= delay;
if (timer <= 0.0f)
{
if (state == 0) // walking
{
counter--;
if (counter >= 0)
{
timer = 0.5f;
if (hp <= hpMax / 4)
creatureSpeed = GIANT_SLIME_SPEED * 1.4f;
if (hp <= hpMax / 2)
creatureSpeed = GIANT_SLIME_SPEED * 1.2f;
else
creatureSpeed = GIANT_SLIME_SPEED;
setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), GIANT_SLIME_SPEED ));
}
else
{
int r = rand() % 3;
if (r == 0) changeToState(1);
else if (r == 1) changeToState(3);
else changeToState(5);
}
}
else if (state == 1) // waiting for jumping
{
changeToState(2);
}
else if (state == 2) // jumping
{
changeToState(8);
}
else if (state == 3)
{
changeToState(4);
}
else if (state == 4) // walking
{
counter--;
if (counter >= 0)
{
if (hp <= hpMax / 4)
timer = missileDelay * 0.6f;
if (hp <= hpMax / 2)
timer = missileDelay * 0.8f;
else
timer = missileDelay;
fire();
}
else
{
changeToState(8);
}
}
else if (state == 5)
{
changeToState(6);
}
else if (state == 6) // jump
{
changeToState(7); // fall
}
else if (state == 7) // jump
{
}
else if (state == 8) // jump
{
changeToState(0); // fall
}
}
if (state == 0) // walking
{
frame = ((int)(age * 2.0f)) % 2;
}
else if (state == 1 || state == 5) // waiting to jump
{
if (timer < 0.25f)
frame = 1;
else
frame = 0;
}
else if (state == 2) // jumping
{
hVelocity -= 700.0f * delay;
h += hVelocity * delay;
if (h <= 0.0f)
{
if (hp <= 0)
dying();
else
{
h = 0.0f;
if (isFirstJumping)
{
isFirstJumping = false;
hVelocity = 160.0f;
SoundManager::getInstance().playSound(SOUND_SLIME_IMAPCT);
}
else
{
SoundManager::getInstance().playSound(SOUND_SLIME_IMAPCT_WEAK);
viscosity = 0.96f;
changeToState(0);
}
}
}
if (hVelocity > 0.0f) frame = 2;
else frame = 0;
}
else if (state == 6) // ultra jump
{
if (h < 2000)
h += hVelocity * delay;
}
else if (state == 7) // ultra jump
{
if (!isFalling && timer <= 2.2f)
{
isFalling = true;
x = game().getPlayer()->getX();
y = game().getPlayer()->getY();
// to prevent collisions
float x0 = TILE_WIDTH + 1;
float xf = TILE_WIDTH * (MAP_WIDTH - 1) - 1;
float y0 = TILE_HEIGHT + 1;
float yf = TILE_HEIGHT * (MAP_HEIGHT - 1) - 1;
calculateBB();
if (boundingBox.left < x0) x += (x0 - boundingBox.left);
else if (boundingBox.left + boundingBox.width > xf) x -= (boundingBox.left + boundingBox.width - xf);
if (boundingBox.top < y0) y += (y0 - boundingBox.top);
else if (boundingBox.top + boundingBox.height > yf) y -= (boundingBox.top + boundingBox.height - yf);
}
if (timer < 2.3f)
{
h += hVelocity * delay;
if (h <= 0)
{
h = 0;
changeToState(8);
game().makeShake(0.8f);
SoundManager::getInstance().playSound(SOUND_SLIME_IMAPCT_BOSS);
}
}
}
if (state == 6 && timer < 0.5f)
{
int fade = timer * 512;
if (fade < 0) fade = 0;
sprite.setColor(sf::Color(255, 255, 255, fade));
}
else if (state == 7 && timer < 1.5f)
sprite.setColor(sf::Color(255, 255, 255, 255));
else if (state == 7 && timer < 2.0f)
sprite.setColor(sf::Color(255, 255, 255, (2.0f - timer) * 512));
else if (state == 7)
sprite.setColor(sf::Color(255, 255, 255, 0));
isMirroring = (frame == 2) && (velocity.x < 0.0f);
z = y + 26;
}
void GiantSlimeEntity::calculateBB()
{
boundingBox.left = (int)x - width / 2 + GIANT_SLIME_BB_LEFT;
boundingBox.width = width - GIANT_SLIME_BB_WIDTH_DIFF;
boundingBox.top = (int)y - height / 2 + 40;
boundingBox.height = height - 76;
}
void GiantSlimeEntity::collideMapRight()
{
velocity.x = -velocity.x;
}
void GiantSlimeEntity::collideMapLeft()
{
velocity.x = -velocity.x;
}
void GiantSlimeEntity::collideMapTop()
{
velocity.y = -velocity.y;
}
void GiantSlimeEntity::collideMapBottom()
{
velocity.y = -velocity.y;
}
void GiantSlimeEntity::dying()
{
isDying = true;
game().addKilledEnemy(enemyType, hurtingType);
game().addCorpse(x, y, FRAME_CORPSE_GIANT_SLIME);
float xSlime = x;
float ySlime = y;
if (x <= 1.5 * TILE_WIDTH) x = 1.5f * TILE_WIDTH + 2;
else if (x >= TILE_WIDTH * MAP_WIDTH - 1.5f * TILE_WIDTH) x = TILE_WIDTH * MAP_WIDTH - 1.5f * TILE_WIDTH -3;
if (y <= 1.5 * TILE_HEIGHT) y = 1.5 * TILE_HEIGHT + 2;
else if (y >= TILE_HEIGHT * MAP_HEIGHT - 1.5f * TILE_HEIGHT) y = TILE_HEIGHT * MAP_HEIGHT - 1.5f * TILE_HEIGHT -3;
for (int i = 0; i < 9; i++)
{
game().generateBlood(xSlime, ySlime, bloodColor);
new SlimeEntity(x, y, SlimeTypeStandard, true);
}
game().makeShake(1.0f);
SoundManager::getInstance().playSound(SOUND_SLIME_SMASH);
ItemEntity* newItem = new ItemEntity(ItemBossHeart, x, y);
newItem->setVelocity(Vector2D(100.0f + rand()% 250));
newItem->setViscosity(0.96f);
SpriteEntity* star = new SpriteEntity(ImageManager::getInstance().getImage(IMAGE_GIANT_SLIME), x, y, 128, 128, 8);
star->setFrame(4);
star->setFading(true);
star->setZ(y+ 100);
star->setAge(-0.4f);
star->setLifetime(0.3f);
star->setType(ENTITY_EFFECT);
star->setSpin(400.0f);
}
void GiantSlimeEntity::render(sf::RenderTarget* app)
{
if (!isDying)
{
// shadow
sprite.setPosition(x, y);
if (isMirroring)
sprite.setTextureRect(sf::IntRect(shadowFrame * width + width, 0, -width, height));
else
sprite.setTextureRect(sf::IntRect(shadowFrame * width, 0, width, height));
app->draw(sprite);
}
sprite.setPosition(x, y - h);
if (isMirroring)
sprite.setTextureRect(sf::IntRect(frame * width + width, 0, -width, height));
else
sprite.setTextureRect(sf::IntRect(frame * width, 0, width, height));
app->draw(sprite);
renderLifeBar(app, tools::getLabel("enemy_giant_slime"));
if (game().getShowLogical())
{
displayBoundingBox(app);
displayCenterAndZ(app);
}
}
void GiantSlimeEntity::collideWithEnemy(EnemyEntity* entity)
{
if (entity->getMovingStyle() == movWalking)
{
inflictsRecoilTo(entity);
}
}
void GiantSlimeEntity::inflictsRecoilTo(BaseCreatureEntity* targetEntity)
{
if (state == 7)
{
Vector2D recoilVector = Vector2D(x, y).vectorTo(Vector2D(targetEntity->getX(), targetEntity->getY()), KING_RAT_RUNNING_RECOIL );
targetEntity->giveRecoil(true, recoilVector, 1.0f);
}
}
bool GiantSlimeEntity::canCollide()
{
return h <= 70.0f;
}
BaseCreatureEntity::enumMovingStyle GiantSlimeEntity::getMovingStyle()
{
if (h <= 70.0f)
return movWalking;
else
return movFlying;
}
void GiantSlimeEntity::fire()
{
SoundManager::getInstance().playSound(SOUND_BLAST_FLOWER);
EnemyBoltEntity* bolt = new EnemyBoltEntity
(x, y + 10, ShotTypeStandard, 0, enemyType);
bolt->setFrame(1);
bolt->setMap(map, TILE_WIDTH, TILE_HEIGHT, 0, 0);
bolt->setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(),GIANT_SLIME_FIRE_VELOCITY ));
}
diff --git a/src/WitchBlastGame.h b/src/WitchBlastGame.h
index 4a319db..e7c3288 100644
--- a/src/WitchBlastGame.h
+++ b/src/WitchBlastGame.h
@@ -1,1082 +1,1082 @@
/** 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 WITCH_BLAST_GAME_H
#define WITCH_BLAST_GAME_H
#include "sfml_game/Game.h"
#include "sfml_game/TileMapEntity.h"
#include "PlayerEntity.h"
#include "DungeonMapEntity.h"
#include "EnemyEntity.h"
#include "DoorEntity.h"
#include "GameFloor.h"
#include "Config.h"
#include "Achievements.h"
#include <queue>
#include <thread>
// for tests
//#define TEST_MODE
const int ALIGN_LEFT = 0; /*!< Text alignment left */
const int ALIGN_RIGHT = 1; /*!< Text alignment right */
const int ALIGN_CENTER = 2; /*!< Text alignment centered */
const int X_GAME_FADE_IN = 0; /*!< Fade In effect ID */
const int X_GAME_FADE_OUT = 1; /*!< Fade out effect ID */
const int X_GAME_COLOR_RED = 0; /*!< Red light color effect ID */
const int X_GAME_COLOR_GREEN = 1; /*!< Green light color effect ID */
const int X_GAME_COLOR_BLUE = 2; /*!< Blue light color effect ID */
const int X_GAME_COLOR_VIOLET = 3; /*!< Violet light color effect ID */
const int X_GAME_COLOR_BROWN = 4; /*!< Brown light color effect ID */
const int X_GAME_COLOR_WHITE = 5; /*!< White light color effect ID */
unsigned const int NumberKeys = 13; /*!< Number of input keys on the game */
/** Input key string
* Keys in the config file.
*/
const std::string inputKeyString[NumberKeys] =
{
"key_move_up",
"key_move_down",
"key_move_left",
"key_move_right",
"key_fire_up",
"key_fire_down",
"key_fire_left",
"key_fire_right",
"key_fire_select",
"key_spell",
"key_interact",
"key_time",
"key_fire"
};
/** Credits: coder */
const std::string creditsCode[] =
{
"Seby",
"END"
};
/** Credits: 2D artists */
const std::string credits2D[] =
{
"Pierre \"dejam0rt\" Baron",
"END"
};
/** Credits: Sound */
const std::string creditsSound[] =
{
"www.freesound.org/",
"www.freesfx.co.uk/",
"www.universal-soundbank.com/",
"END"
};
/** Credits: Music */
const std::string creditsMusic[] =
{
"Yan Dupuis",
"END"
};
/** Credits: Translation */
const std::string creditsTranslate[] =
{
"achpile (russian)",
"AFS (spanish)",
"Geheim (german)",
"END"
};
/** Struct for game parameters */
struct parameterStruct
{
int language; /*!< Language ID (english = 0) */
int musicVolume; /*!< music volume (0 to 100) */
int soundVolume; /*!< sound volume (0 to 100) */
bool zoom; /*!< zoom effect (false = disabled) */
bool vsync; /*!< monitor vsync (false = disabled) */
bool bloodSpread; /*!< blood spread (false = disabled) */
bool fullscreen; /*!< full screen (false = disabled) */
bool displayBossPortrait;
std::string playerName; /*!< player name */
};
struct structPotionMap
{
enumItemType effect;
bool known;
};
/*! \class WitchBlastGame
* \brief Main class of the game
*
* WitchBlastGame load the game ressources and do a large part of the game logic (game loop...),
* watches the input, manages the game states, ...
*/
class WitchBlastGame : public Game
{
public:
// DATA TYPES
/** Savegame header data */
struct saveHeaderStruct
{
bool ok; /**< Save game OK ? */
int level; /**< Level the save game */
float gameTime; /**< How long it has been played */
int shotType; /**< Current special shot type */
std::string date; /**< Date of the save game */
std::string time; /**< Time of the save game */
};
// PUBLIC METHODS
/*!
* \brief Constructor
*/
WitchBlastGame();
/*!
* \brief Destructor
*/
virtual ~WitchBlastGame();
/*!
* \brief Accessor on the current dungeon map
* \return a pointer to the current dungeon map
*/
DungeonMap* getCurrentMap();
GameFloor* getCurrentFloor();
int getFloorX();
int getFloorY();
/*!
* \brief Accessor on the current dungeon map entity
* \return a pointer to the current dungeon map entity
*/
DungeonMapEntity* getCurrentMapEntity();
/*!
* \brief Accessor on the player
* \return a pointer to the player
*/
PlayerEntity* getPlayer();
/*!
* \brief Accessor on the player's position
* \return a Vector2D of the player's position
*/
Vector2D getPlayerPosition();
/*!
* \brief accessor on the level
* \return : the level
*/
int getLevel();
/*!
* \brief accessor on the level
* \return : the challenge level
*/
int getChallengeLevel();
/*!
* \brief accessor on showLogical flag
* \return : the value of the flag
*/
bool getShowLogical();
float getDeltaTime();
/*!
* \brief accessor on the parameters
* \return : the parameters
*/
parameterStruct getParameters();
/*!
* \brief Start the game and the game loop
* This method starts the game and the game loop.
* The game loop watches the events, the inputs, update and draw the game elements.
*/
virtual void startGame();
/*!
* \brief Move the player to another map (room)
* Moves the player to another room of the dungeon.
* It's called when a player walk through an opened door.
* \param direction : direction of the new map. 4 = left, 8 = north, 6 = right, 2 = south
*/
void moveToOtherMap(int direction);
/*!
* \brief Closes the doors of the room
* Closes the doors of the room.
* It's called when the player enter in an area with monsters.
*/
void closeDoors();
/*!
* \brief Opens the doors of the room
* Opens the doors of the room.
* It's called when the player destroy the last monster of a room.
*/
void openDoors();
/*!
* \brief Count the enemies in the room
* Count the enemies in the room.
* It's called when the room is closed : 0 enemy = room is cleared and doors shall open.
* \return amount of enemies
*/
/*!
* \brief Refreshes the minimap
*
* Refresh the minimap.
* Called when the player changes room.
*/
void refreshMinimap();
int getEnemyCount();
int getUndeadCount();
void animateEffects();
EnemyEntity* getBoss();
void destroyUndead(int damage);
int getItemsCount();
/*!
* \brief Return the position of the nearest enemy
* \param x : x position of the source
* \param y : y position of the source
* \return position of the nearest enemy (negative position when no enemy found)
*/
Vector2D getNearestEnemy(float x, float y);
/*!
* \brief Generates blood
* \param x : x position of the blood
* \param y : y position of the blood
* \param bloodColor : color of the blood (red; green, ...)
*/
void generateBlood(float x, float y, BaseCreatureEntity::enumBloodColor bloodColor);
/*!
* \brief Add a corpse on the map
* \param x : x position of the corpse
* \param y : y position of the corpse
* \param frame : frame of the corpse in the spritesheet
*/
void addCorpse(float x, float y, int frame);
/*!
* \brief Show a "popup" with artefact's description
* Show a "popup" with artefact's description.
* Artefact's description consists of zoomed picture of the item, name and description.
* It's called when a player get an equipment item.
* \param itemType : item identifier
*/
void showArtefactDescription(enumItemType itemType);
/*!
* \brief Make a "shake" effet
* \param duration : duration of the effect
*/
void makeShake(float duration);
/*!
* \brief Make a "color fade" effet
* \param color : the color of the effect
* \param duration : duration of the effect
*/
void makeColorEffect(int color, float duration);
/*!
* \brief Write a string on screen
* \param str : the string
* \param size : the character size
* \param x : x position
* \param y : y position
* \param align : alignment (ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT)
* \param color : color of the string
* \param app : the rendering target
* \param xShadow : offset of the shadow (x)
* \param yShadow : offset of the shadow (y)
*/
void write(std::string str, int size, float x, float y, int align, sf::Color color, sf::RenderTarget* app, int xShadow, int yShadow);
/*!
* \brief Save the game
* Save the game to file : complete floor and maps, items and blood position, player current equipment and stats....
*/
void saveGame();
/*!
* \brief Load the game
* Load the game from file. After restoring the game, the file is destroy.
* \return true if succeeded
*/
bool loadGame();
/*!
* \brief Save the game data (general)
*/
void saveGameData();
/*!
* \brief Load the game data (general)
*/
void loadGameData();
/*!
* \brief Load the savegame data
* \return the savegame data
*/
saveHeaderStruct loadGameHeader();
/*!
* \brief Returns a random equip object
*
* Returns a random equip object (not an object the player already possesses) .
* \param toSale : true if it's an item for sale
*
* \return the equipment item ID
*/
item_equip_enum getRandomEquipItem(bool toSale, bool noFairy);
/*!
* \brief Returns a random spell object
*/
enumItemType getItemSpell();
/*!
* \brief Generate a random challenge loot
*
* \param x : x position of the bonus
* \param y : y position of the bonus
*/
void generateChallengeBonus(float x, float y);
/*!
* \brief Adds monsters
*
* Adds monsters to the room in suitable places.
* \param monsterType : monster type
* \param amount : amount of monsters
*/
void findPlaceMonsters(enemyTypeEnum monsterType, int amount);
/*!
* \brief Add a monster to the "killed monsters" table
* \param enemyType : ID of the monster
*/
void addKilledEnemy(enemyTypeEnum enemyType, enumShotType damageType);
/*!
* \brief Proceed an event
* \param event : ID of the event
*/
void proceedEvent(EnumWorldEvents event);
/*!
* \brief Proceed a message
* \param event : ID of the message
*/
void testAndAddMessageToQueue(EnumMessages type);
/*!
* \brief Proceed a divinity level up message
* \param label : the message to proceed
*/
void addDivLevelMessageToQueue(std::string label);
std::string enemyToString(enemyTypeEnum enemyType);
std::string sourceToString(sourceTypeEnum sourceType, enemyTypeEnum enemyType);
void saveScreen();
void saveDeathScreen();
struct StructScore
{
std::string name;
int score;
int level;
int shotType;
bool equip[NUMBER_EQUIP_ITEMS];
int divinity;
int killedBy;
int time;
};
void calculateScore();
void addLifeBarToDisplay(std::string label, int hp, int hpMax);
void revealFloor();
void activateKeyRoomEffect(bool withColorEffect);
void generateStar(sf::Color starColor, float xStar, float yStar);
void registerAchievement(enumAchievementType achievement);
void renderDoors();
void setDoorVisible(int n);
bool isPresentItem(int n);
void addPresentItem(int n);
/*!
* \brief Checks if player opens a door
*
* Checks if player opens a door (collide with the door and gets the key).
* If positive, opens the door.
*/
void verifyDoorUnlocking();
float getGameTime();
std::string equipToString(bool equip[NUMBER_EQUIP_ITEMS]);
enumItemType getPotion(enumItemType source);
bool potionEffectKnown(enumItemType source);
void setPotionToKnown(enumItemType source);
void addPotionToMap(enumItemType source, enumItemType effect, bool known);
void acquireAlchemyBook();
void forget();
void forgetPotions();
+ /*!
+ * \brief Returns true if the difficulty for the map is "advanced"
+ */
+ bool isAdvancedLevel();
+
protected:
/*!
* \brief Rendering method
*
* Render all the game objects to the screen.
* Called in the game loop.
*/
virtual void onRender();
/*!
* \brief Update method
*
* Update all the game objects to the screen.
* Called in the game loop.
*/
virtual void onUpdate();
/*!
* \brief render the HUD for shot types
*
* Render the HUD for shot types.
* Display the available shot types and highlight the current one.
*
* \param app : Rendering target
*/
void renderHudShots(sf::RenderTarget* app);
void killArtefactDescription();
private:
Config config;
float deltaTime;
// game logic / data
GameMap* miniMap; /*!< Pointer to the logical minimap */
DungeonMap* currentMap; /*!< Pointer to the logical current map */
GameFloor* currentFloor; /*!< Pointer to the logical floor (level) */
bool showLogical; /*!< True if showing bounding boxes, z and center */
bool showGameTime; /*!< True if showing the game time */
// game play
int level; /*!< Level (floor) */
int score; /*!< score (calculated at the end of the game) */
int bodyCount; /*!< killed monsters (calculated at the end of the game) */
int challengeLevel; /*!< Level (challenge) */
float gameTime; /*!< "age" of the current game */
int floorX; /*!< X position of the room in the level */
int floorY; /*!< Y position of the room in the level */
bool roomClosed; /*!< True if the room is closed */
bool bossRoomOpened; /*!< True if the boss gate has been opened in this level */
int firingDirection; /*!< Save the firing direction - for the "one button" gameplay */
bool isPlayerAlive; /*!< Dying sets this bool to false (trigger the ending music) */
bool monsterArray[MAP_WIDTH][MAP_HEIGHT]; /*!< use to remember if a case has a monster in monster spawn */
int killedEnemies[NB_ENEMY];
// game objects
PlayerEntity* player; /*!< Pointer to the player entity */
DungeonMapEntity* dungeonEntity; /*!< TileMap of the room (main game board) + blood, items, etc...*/
TileMapEntity* miniMapEntity;
// displaying objects
DoorEntity* doorEntity[4]; /*!< Pointers to the door graphical entity */
sf::Font font; /*!< The font used for displaying text */
sf::Text myText; /*!< The text to be displayed */
sf::Sprite introScreenSprite;
sf::Sprite titleSprite;
struct uiSpritesStruct
{
sf::Sprite gui;
sf::Sprite keySprite; /*!< A simple sprite with the boss key (displayed on the HUD) */
sf::Sprite shotsSprite; /*!< A simple sprite for the available shot types (displayed on the HUD) */
sf::Sprite topLayer;
sf::Sprite msgBoxSprite;
sf::Sprite iconSprite;
sf::Sprite mapBgSprite;
} uiSprites;
struct lifeBarStruct
{
bool toDisplay;
std::string label;
int hp;
int hpMax;
} lifeBar;
float xOffset, yOffset; /*!< Main game client position in the GUI */
sf::Music music; /*!< Current game music */
/** Music enum
* Identify the various music tracks of the game.
*/
enum musicEnum
{
MusicDungeon, /**< Main game music - played when playing the game */
MusicEnding, /**< Ending music - played when the player has died */
MusicBoss, /**< Boss music - for epic fights ! */
MusicIntro, /**< Main menu music */
MusicChallenge /**< Challenge music - for epic fights ! */
};
/** Game states enum
* Used for the different game states
*/
enum gameStateEnum
{
gameStateInit, /**< Game initialization */
gameStateIntro, /** < Intro animation */
gameStateMenu, /**< Menu */
gameStateKeyConfig, /**< Key config */
gameStateJoystickConfig, /**< Joystick config */
gameStatePlaying, /**< Playing */
gameStatePlayingPause, /**< Playing / Pause */
gameStatePlayingDisplayBoss, /**< Playing / DisplayBoss */
};
gameStateEnum gameState; /*!< Store the game state */
float bossDisplayTimer;
int bossDisplayState;
/** Special game states enum
* Used for effects such as fade in...
*/
enum xGameTypeEnum
{
xGameTypeFade, /**< Fade effect */
xGameTypeShake, /**< Shake effect */
xGameTypeFadeColor, /**< Color fade effect */
NB_X_GAME
};
struct xGameStruct
{
bool active;
int param;
float timer;
float duration;
} xGame[NB_X_GAME];
/** Input Keys enum
* Used for the input binding
*/
enum inputKeyEnum
{
KeyUp,
KeyDown,
KeyLeft,
KeyRight,
KeyFireUp,
KeyFireDown,
KeyFireLeft,
KeyFireRight,
KeyFireSelect,
KeySpell,
KeyInteract,
KeyTimeControl,
KeyFire
};
const std::string inputKeyStr[NumberKeys] =
{
"_move_up",
"_move_down",
"_move_left",
"_move_right",
"_fire_up",
"_fire_down",
"_fire_left",
"_fire_right",
"_spell",
"_interact",
"_fire",
"_time_control",
"_fire_select"
};
sf::Keyboard::Key input[NumberKeys]; /*!< Input key array */
struct JoystickInputStruct
{
bool isButton;
sf::Joystick::Axis axis;
int value;
};
JoystickInputStruct joystickInput[NumberKeys];
std::string scoreSaveFile;
/*!
* \brief Starts the game
*
* Start a new game or load it from file.
*
* \param fromSaveFile : true if we want to try to load the game from a file
*/
void startNewGame(bool fromSaveFile, int startingLevel);
/*!
* \brief Starts a new level
*
* Start a new level.
* Called for each level of the game.
*/
void startNewLevel();
/*!
* \brief Starts the level
*
* Starts the level.
* Called after loading the game or creating a new level.
* \param isFight : true if loading in fight
*/
void playLevel(bool isFight);
/*!
* \brief Creates a level
*
* Creates a random level (a level is a floor that consists of rooms).
*/
void createFloor();
/*!
* \brief Create or refresh the room
*
* Create a room (if this is a new one) or refresh it.
* Called when the player changes room.
* Checks the visibility of the doors and close it if there are monsters.
* Loads the map items and sprites.
*/
void refreshMap();
/*!
* \brief Check if a door is present, and its style
*
* \param doorId : index of the door
* \param roomCurrent : type of the current door
* \param roomNeighbour : type of the neighbour door
*/
void checkDoor(int doorId, roomTypeEnum roomCurrent, roomTypeEnum roomNeighbour, bool isNeighbourKnown);
/*!
* \brief Generates a room
*
* Generates a room.
* Called when the player moves to a room for the first time.
*/
void generateMap();
/*!
* \brief Generates a standard room
*
* Generates a standard room with monsters.
* Called during the generation when the map has no particular type.
*/
void generateStandardMap();
- /*!
- * \brief Returns true if the difficulty for the map is "advanced"
- */
- bool isAdvancedLevel();
-
/*!
* \brief Checks if the room will be closed
*
* Checks if the room will be closed.
* Called when entering a room. If the room is not clear, closes the doors.
*/
void checkEntering();
/*!
* \brief Saves the map items
*
* Saves the map objects such as items, corpses, blood, chest.
* Called when leaving the door.
*/
void saveMapItems();
/*!
* \brief Initializes the monster array
*
* Initializes the monster array (to empty).
*/
void initMonsterArray();
/*!
* \brief Adds a monster
*
* Adds a monster to the room.
* \param monsterType : monster type
* \param xm : x position of the monster
* \param ym : y position of the monster
*/
void addMonster(enemyTypeEnum monsterType, float xm, float ym);
/*!
* \brief Checks if player can interact with something
*/
void checkInteraction();
/*!
* \brief Plays a music
*
* Plays a music.
*
* \param musicChoice : music track ID
*/
void playMusic(musicEnum musicChoice);
/*!
* \brief Update the music volume (with parameters.volumeMusic)
*/
void updateMusicVolume();
/*!
* \brief Add a key to the player input map from a string key (from file)
* \param logicInput : input function (move left, fire up, etc...)
* \param key : Key as string
*/
void addKey(int logicInput, std::string key);
/*!
* \brief Save configuration to "config.dat"
*/
void saveConfigurationToFile();
/*!
* \brief Configure with data from "config.dat"
*/
void configureFromFile();
/*!
* \brief Update the game
*/
void updateRunningGame();
/*!
* \brief Render the game
*/
void renderRunningGame();
void renderGame();
void renderHud();
void renderLifeBar();
void renderMessages();
void renderBossPortrait();
/*!
* \brief Update the menu
*/
void updateMenu();
/*!
* \brief Render the menu
*/
void renderMenu();
/*!
* \brief Render the menu
*/
void renderInGameMenu();
/*!
* \brief initialize the intro
*/
void prepareIntro();
/*!
* \brief Update the intro
*/
void updateIntro();
/*!
* \brief Render the intro
*/
void renderIntro();
/*!
* \brief Render the credits screen
*/
void renderCredits();
/*!
* \brief Render the achievements screen
*/
void renderAchievements();
/*!
* \brief Render the scores screen
*/
void renderHiScores();
void renderScores(std::vector <StructScore> scoresToRender, std::string title);
/** Menu keys enum
* Identify the various keys of the menu.
*/
enum menuItemEnum
{
MenuStartNew, /**< When starting the game */
MenuStartOld, /**< When restoring the game */
MenuConfig, /**< When configuring the game */
MenuKeys, /**< When configuring keys */
MenuJoystick, /**< When configuring joystick */
MenuConfigBack, /**< Back to the main menu */
MenuTutoReset, /**< Reset the tutorials */
MenuLanguage, /**< When configuring the language */
MenuExit, /**< When exiting the game */
MenuAchievements, /**< Display the Achievements */
MenuCredits, /**< Display the credits screen */
MenuHiScores, /**< Display the hi-scores screen */
MenuPlayerName, /**< To enter/change the player name */
MenuVolumeSound,
MenuVolumeMusic,
MenuContinue, /**< Continue the game */
MenuSaveAndQuit, /**< Save and return to main */
};
/** Menu states enum
* Identify the various states of the menu.
*/
enum menuStateEnum
{
MenuStateMain,
MenuStateConfig,
MenuStateKeys,
MenuStateJoystick,
MenuStateHiScores,
MenuStateChangeName,
MenuStateCredits,
MenuStateAchievements,
MenuStateFirst /**< First time, we choose language and keyboard */
};
menuStateEnum menuState;
/*!
* \brief Menu item structure
*/
struct menuItemStuct
{
menuItemEnum id; /**< Id of the action */
std::string label; /**< Label of the menu item */
std::string description; /**< Description of the menu item */
};
int menuScoreIndex;
/*!
* \brief Menu structure
*/
struct menuStuct
{
std::vector<menuItemStuct> items; /**< Menu items */
unsigned int index; /**< Position int the menu */
float age; /**< Age of the menu */
};
menuStuct menuMain;
menuStuct menuFirst;
menuStuct menuConfig;
menuStuct menuJoystick;
menuStuct menuInGame;
unsigned int menuKeyIndex;
unsigned int menuAchIndex;
/*!
* \brief Build the menu items
*/
void buildMenu(bool rebuild);
/*!
* \brief Build the menu items (in game)
*/
void buildInGameMenu();
/*!
* \brief Switch to the menu
*/
void switchToMenu();
/*!
* \brief Save language config and default keys configuration
*/
void registerLanguage();
parameterStruct parameters;
void resetKilledEnemies();
std::queue <messageStruct> messagesQueue;
bool worldEvent[NB_EVENTS];
void initEvents();
bool gameMessagesToSkip[NB_MESSAGES];
struct achievementStruct
{
enumAchievementType type;
std::string message;
float timer;
bool hasStarted;
int counter;
};
std::queue <achievementStruct> achievementsQueue;
void renderPlayer(float x, float y, bool equip[NUMBER_EQUIP_ITEMS], int shotType,
int frame, int spriteDy);
void renderDeathScreen(float x, float y);
bool equipToDisplay[NUMBER_EQUIP_ITEMS];
bool equipNudeToDisplay[NUMBER_EQUIP_ITEMS];
saveHeaderStruct saveHeader;
struct StructMonster
{
enemyTypeEnum id;
float x;
float y;
};
/*!
* \brief Data for "in fight" game saving
*/
struct StructSaveInFight
{
bool isFight; /**< True if loading during a fight */
float x; /**< Player x position */
float y; /**< Player y position */
int direction; /**< Player direction */
std::vector<StructMonster> monsters; /**< Monsters */
};
StructSaveInFight saveInFight; /**< Data for "in fight" game saving */
SpriteEntity* introSprites[8];
int introState;
int introSoundState;
int currentStandardMusic;
std::vector <StructScore> scores;
std::vector <StructScore> scoresOnline;
std::vector <StructScore> scoresOnlineDay;
StructScore lastScore;
void loadHiScores();
void loadHiScoresOnline(bool fromDayOnly);
void saveHiScores();
enum enumNetworkScoreState
{
ScoreOK,
ScoreLoading,
ScoreLoadingDay
} scoreState;
struct StructInteraction
{
bool active;
EnumInteractionType type;
int id;
std::string label;
} interaction;
void enableAA(bool enable);
enum achievementStatus { AchievementDone, AchievementUndone, AchievementPending};
achievementStatus achievementState[NB_ACHIEVEMENTS];
bool isItemLocked(enumItemType item);
bool isFunctionalityLocked(enumFunctionalityType func);
int getAchievementsPercents();
struct globalDataStruct
{
int killedMonster[NB_ENEMY];
} globalData;
void generateUiParticle(float x, float y);
bool presentItems[NUMBER_EQUIP_ITEMS];
void resetPresentItems();
bool isPressing(inputKeyEnum k, bool oneShot);
bool getPressingState(inputKeyEnum k);
void updateActionKeys();
struct ActionKeyStruct
{
bool isPressed;
bool isTriggered;
} actionKey[NumberKeys];
bool isInputPressed[NumberKeys];
bool gameFromSaveFile;
// scoring server
std::thread sendScoreThread;
void sendScoreToServer();
void sendScoreToServerThread();
std::thread receiveScoreThread;
void receiveScoreFromServer();
void receiveScoreFromServerThread();
void checkDestroyableObjects();
std::map<enumItemType, structPotionMap> potionMap;
void randomizePotionMap();
};
/*!
* \brief Returns the game reference
*
* Returns the game reference.
*
* \return a reference to the game
*/
WitchBlastGame& game();
#endif // WITCH_BLAST_GAME_H

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 16, 12:14 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
71357
Default Alt Text
(40 KB)

Event Timeline