Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126350
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
11 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/Constants.h b/src/Constants.h
index 5b15a08..cf82047 100644
--- a/src/Constants.h
+++ b/src/Constants.h
@@ -1,253 +1,255 @@
/** This file is part of Witch Blast.
*
* FreeTumble 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.
*
* FreeTumble 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 FreeTumble. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONSTANTS_H_INCLUDED
#define CONSTANTS_H_INCLUDED
// uncomment to show bounding box in the app
// #define SHOW_BOUNDING_BOX
#include <string>
const std::string APP_NAME = "Witch Blast";
const std::string APP_VERSION = "0.0.8";
// 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 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 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;
enum item_images {
IMAGE_PLAYER_BASE,
IMAGE_PLAYER_EQUIP,
IMAGE_PLAYER_COLLAR,
IMAGE_BOLT,
IMAGE_TILES,
IMAGE_RAT,
IMAGE_MINIMAP,
IMAGE_DOOR,
IMAGE_ITEMS,
IMAGE_ITEMS_EQUIP,
IMAGE_CHEST,
IMAGE_BAT,
IMAGE_FLOWER,
IMAGE_SLIME,
IMAGE_KING_RAT,
IMAGE_BLOOD,
IMAGE_CORPSES,
IMAGE_CORPSES_BIG,
IMAGE_STAR,
IMAGE_STAR_2,
IMAGE_INTERFACE,
IMAGE_HUD_SHOTS,
IMAGE_PNJ,
IMAGE_FAIRY
};
enum sound_resources {
SOUND_STEP,
SOUND_BLAST_STANDARD,
SOUND_BLAST_FLOWER,
SOUND_DOOR_CLOSING,
SOUND_DOOR_OPENING,
SOUND_CHEST_OPENING,
SOUND_IMPACT,
SOUND_BONUS,
SOUND_DRINK,
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_ICE_CHARGE,
SOUND_SHOT_SELECT
};
enum corpses_ressources{
FRAME_CORPSE_RAT,
FRAME_CORPSE_BAT,
FRAME_CORPSE_FLOWER,
FRAME_CORPSE_GREEN_RAT,
FRAME_CORPSE_SLIME,
FRAME_CORPSE_KING_RAT
};
// Player game play
const float INITIAL_PLAYER_SPEED = 180.0f;
const int INITIAL_PLAYER_HP = 20;
const float INITIAL_PLAYER_FIRE_DELAY = 0.7f;
const float ACQUIRE_DELAY = 2.8f;
const float UNLOCK_DELAY = 1.0f;
const float INITIAL_BOLT_LIFE = 0.4f;
const int INITIAL_BOLT_DAMAGES = 8;
const float INITIAL_BOLT_VELOCITY = 700.0f;
const float FAIRY_SPEED = 180.0f;
const float FAIRY_FIRE_DELAY = 0.8f;
const float FAIRY_BOLT_LIFE = 0.4f;
const int FAIRY_BOLT_DAMAGES = 8;
const float FAIRY_BOLT_VELOCITY = 700.0f;
enum chest_type_enum {
CHEST_BASIC,
CHEST_FAIRY
};
// Artefact Info
const float ARTEFACT_RECT_WIDTH = 600.0f;
const float ARTEFACT_RECT_HEIGHT = 100.0f;
const float ARTEFACT_POS_Y = 450.0f;
const float ARTEFACT_BORDER = 8.0f;
const float ARTEFACT_ZOOM_TIME = 0.5f;
// shot types
enum enumShotType {
ShotTypeStandard,
ShotTypeIce,
ShotTypeIllusion,
ShotTypeStone,
ShotTypeLightning
};
// status
const float STATUS_FROZEN_DELAY = 5.0f; // how long the freeze occurs
const float STATUS_FROZEN_BOLT_DELAY = 2.5f; // how long the freeze occurs
const float STATUS_FROZEN_MULT = 0.33f; // speed multiplier (= 3 times slower)
// 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_BOLT = 15;
const int ENTITY_ENNEMY_BOLT = 16;
const int ENTITY_PNJ = 17;
const int ENTITY_CHEST = 18;
const int ENTITY_ITEM = 19;
const int ENTITY_ENNEMY = 21;
const int ENTITY_ENNEMY_INVOCATED = 22;
const int ENTITY_ENNEMY_BOSS = 23;
+const int ENTITY_ENNEMY_MAX = 23;
+
// monster type
enum monster_type_enum
{
MONSTER_RAT,
MONSTER_BAT,
MONSTER_EVIL_FLOWER,
MONSTER_SLIME,
MONSTER_KING_RAT
};
const float DOOR_OPEN_TIME = 1.0f;
const float DOOR_CLOSE_TIME = 1.0f;
// Rat
const float RAT_SPEED = 160.0f;
const int RAT_HP = 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 = 170.0f;
const int GREEN_RAT_HP = 16;
const int GREEN_RAT_DAMAGES = 5;
const float GREEN_RAT_FADE = 1.0f;
// Bat
const float BAT_SPEED = 250.0f;
const int BAT_HP = 8;
const int BAT_DAMAGES = 5;
const int BAT_BB_LEFT = 5;
const int BAT_BB_WIDTH_DIFF = 10;
const int BAT_BB_TOP = 2;
const int BAT_BB_HEIGHT_DIFF = 32;
// Evl Flower
const int EVIL_FLOWER_HP = 16;
const int EVIL_FLOWER_MELEE_DAMAGES = 8;
const int EVIL_FLOWER_MISSILE_DAMAGES = 5;
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.7f;
const float EVIL_FLOWER_FIRE_VELOCITY = 220.0f;
// 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;
// KingRat
const float KING_RAT_SPEED = 200.0f;
const float KING_RAT_RUNNING_SPEED = 600.0f;
const float KING_RAT_BERSERK_SPEED = 250.0f;
const int KING_RAT_HP = 600;
const int KING_RAT_DAMAGES = 8;
// EFFECTS
const float HURTING_DELAY = 0.4f;
#endif // CONSTANTS_H_INCLUDED
diff --git a/src/EnnemyEntity.cpp b/src/EnnemyEntity.cpp
index 04724ab..194cf6b 100644
--- a/src/EnnemyEntity.cpp
+++ b/src/EnnemyEntity.cpp
@@ -1,131 +1,143 @@
#include "EnnemyEntity.h"
#include "BoltEntity.h"
#include "PlayerEntity.h"
#include "sfml_game/SpriteEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include <iostream>
#include "WitchBlastGame.h"
EnnemyEntity::EnnemyEntity(sf::Texture* image, float x, float y)
: BaseCreatureEntity (image, x, y, 64, 64)
{
type = ENTITY_ENNEMY;
bloodColor = bloodRed;
z = y;
age = -0.001f * (rand()%800) - 0.4f;
}
void EnnemyEntity::animate(float delay)
{
if (canCollide()) testSpriteCollisions();
if (age > 0.0f)
BaseCreatureEntity::animate(delay);
else
age += delay;
}
void EnnemyEntity::calculateBB()
{
boundingBox.left = (int)x - width / 2;
boundingBox.width = width;
boundingBox.top = (int)y - height / 2;
boundingBox.height = height;
}
void EnnemyEntity::collideMapRight()
{
velocity.x = 0.0f;
}
void EnnemyEntity::collideMapLeft()
{
velocity.x = 0.0f;
}
void EnnemyEntity::collideMapTop()
{
velocity.y = 0.0f;
}
void EnnemyEntity::collideMapBottom()
{
velocity.y = 0.0f;
}
void EnnemyEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
if (collideWithEntity(entity) &&
(entity->getType() == ENTITY_PLAYER || entity->getType() == ENTITY_BOLT ))
{
PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(entity);
BoltEntity* boltEntity = dynamic_cast<BoltEntity*>(entity);
if (playerEntity != NULL && !playerEntity->isDead())
{
if (playerEntity->hurt(meleeDamages, ShotTypeStandard))
{
float xs = (x + playerEntity->getX()) / 2;
float ys = (y + playerEntity->getY()) / 2;
SpriteEntity* star = new SpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_STAR_2), xs, ys);
star->setFading(true);
star->setZ(y+ 100);
star->setLifetime(0.7f);
star->setType(16);
star->setSpin(400.0f);
}
inflictsRecoilTo(playerEntity);
}
else if (boltEntity != NULL && !boltEntity->getDying() && boltEntity->getAge() > 0.05f)
{
boltEntity->collide();
hurt(boltEntity->getDamages(), boltEntity->getBoltType());
game().generateBlood(x, y, bloodColor);
SoundManager::getSoundManager()->playSound(SOUND_IMPACT);
float xs = (x + boltEntity->getX()) / 2;
float ys = (y + boltEntity->getY()) / 2;
SpriteEntity* star = new SpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_STAR_2), xs, ys);
star->setFading(true);
star->setZ(y+ 100);
star->setLifetime(0.7f);
star->setType(16);
star->setSpin(400.0f);
if (boltEntity->getBoltType() == ShotTypeStone)
{
Vector2D recoilVector = Vector2D(boltEntity->getX(), boltEntity->getY()).vectorTo(Vector2D(x, y), 110 );
giveRecoil(true, recoilVector, 0.15f);
}
}
}
+ else // collision with other enemy ?
+ {
+ if (entity->getType() >= ENTITY_ENNEMY && entity->getType() <= ENTITY_ENNEMY_MAX)
+ {
+ collideWithEnnemy(entity);
+ }
+ }
+}
+
+void EnnemyEntity::collideWithEnnemy(GameEntity* collidingEntity)
+{
+ // To implement the behaviour when colliding with another ennemy
}
void EnnemyEntity::dying()
{
isDying = true;
SpriteEntity* deadRat = new SpriteEntity(ImageManager::getImageManager()->getImage(3), x, y, 64, 64);
//deadRat->setZ(y + height);
deadRat->setZ(OFFSET_Y);
deadRat->setFrame(2);
deadRat->setType(13);
}
void EnnemyEntity::drop()
{
if (rand() % 5 == 0)
{
ItemEntity* newItem = new ItemEntity(ItemCopperCoin, x, y);
newItem->setMap(map, TILE_WIDTH, TILE_HEIGHT, OFFSET_X, OFFSET_Y);
newItem->setVelocity(Vector2D(100.0f + rand()% 250));
newItem->setViscosity(0.96f);
}
}
bool EnnemyEntity::canCollide()
{
return true;
}
diff --git a/src/EnnemyEntity.h b/src/EnnemyEntity.h
index 5ebb34c..0304337 100644
--- a/src/EnnemyEntity.h
+++ b/src/EnnemyEntity.h
@@ -1,29 +1,30 @@
#ifndef ENNEMYPRITE_H
#define ENNEMYPRITE_H
#include "BaseCreatureEntity.h"
class EnnemyEntity : public BaseCreatureEntity
{
public:
EnnemyEntity(sf::Texture* image, float x, float y);
virtual void animate(float delay);
virtual void calculateBB();
protected:
virtual void collideMapRight();
virtual void collideMapLeft();
virtual void collideMapTop();
virtual void collideMapBottom();
virtual void readCollidingEntity(CollidingSpriteEntity* entity);
virtual void dying();
virtual void drop();
+ virtual void collideWithEnnemy(GameEntity* collidingEntity);
virtual bool canCollide();
int meleeDamages;
private:
};
#endif // ENNEMYPRITE_H
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 11:21 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68719
Default Alt Text
(11 KB)
Attached To
Mode
R78 witchblast
Attached
Detach File
Event Timeline