Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
22 KB
Referenced Files
None
Subscribers
None
diff --git a/media/blood.png b/media/blood.png
index 083482f..6c8e06c 100644
Binary files a/media/blood.png and b/media/blood.png differ
diff --git a/media/corpses_big.png b/media/corpses_big.png
index 0eb3191..0a5ed3a 100644
Binary files a/media/corpses_big.png and b/media/corpses_big.png differ
diff --git a/media/cyclop.png b/media/cyclop.png
new file mode 100644
index 0000000..c79c815
Binary files /dev/null and b/media/cyclop.png differ
diff --git a/media/sound/cyclop00.ogg b/media/sound/cyclop00.ogg
new file mode 100644
index 0000000..9a44b3f
Binary files /dev/null and b/media/sound/cyclop00.ogg differ
diff --git a/media/sound/rock_impact.ogg b/media/sound/rock_impact.ogg
new file mode 100644
index 0000000..fad3064
Binary files /dev/null and b/media/sound/rock_impact.ogg differ
diff --git a/media/sound/throw.ogg b/media/sound/throw.ogg
new file mode 100644
index 0000000..a087b41
Binary files /dev/null and b/media/sound/throw.ogg differ
diff --git a/src/Constants.h b/src/Constants.h
index 1bb2ed2..eee3ca0 100644
--- a/src/Constants.h
+++ b/src/Constants.h
@@ -1,330 +1,343 @@
/** 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
// 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.1.3";
+const std::string APP_VERSION = "0.1.5";
const std::string CONFIG_FILE = "config.dat";
const std::string SAVE_FILE = "game.sav";
const std::string SAVE_VERSION = "SAVE_0.1.2.1";
// 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 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_IMP,
IMAGE_GIANT_SLIME,
IMAGE_KING_RAT,
+ IMAGE_CYCLOP,
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_NONE = -1,
SOUND_BLAST_STANDARD,
SOUND_BLAST_FLOWER,
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_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_IMP_DYING,
+ SOUND_ROCK_IMPACT,
+ SOUND_THROW,
+ SOUND_CYCLOP00
};
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_KING_RAT,
- FRAME_CORPSE_GIANT_SLIME
+ FRAME_CORPSE_GIANT_SLIME,
+ FRAME_CORPSE_CYCLOP
};
// 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 INITIAL_BOLT_VISCOSITY = 0.97f;
const float FAIRY_SPEED = 180.0f;
const float FAIRY_FIRE_DELAY = 0.8f;
const float ICE_FAIRY_FIRE_DELAY = 1.3f;
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_EXIT,
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,
ShotTypeFire
};
// 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.3f, 0.5f };
const float STONE_DECOIL_VELOCITY[MAX_SHOT_LEVEL] // Decoil power
= { 110.0f, 160.0f, 220.0f };
const float ILLUSION_DAMAGES_DECREASE[MAX_SHOT_LEVEL] // Decoil power
= { 0.8f, 0.9f, 1.0f };
const float LIGHTNING_VISCOSITY_INCREASE[MAX_SHOT_LEVEL] // Decoil power
= { 0.01, 0.015f, 0.02f };
// 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_BLACK_RAT,
MONSTER_IMP_RED,
MONSTER_IMP_BLUE,
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;
// Black Rat
const float BLACK_RAT_SPEED = 160.0f;
const int BLACK_RAT_HP = 24;
const int BLACK_RAT_DAMAGES = 5;
// 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;
// Imp
const float IMP_SPEED = 180.0f;
const int IMP_HP = 20;
const int IMP_MELEE_DAMAGES = 5;
const int IMP_MISSILE_DAMAGES = 8;
const int IMP_BB_LEFT = 5;
const int IMP_BB_WIDTH_DIFF = 10;
const int IMP_BB_TOP = 2;
const int IMP_BB_HEIGHT_DIFF = 32;
const float IMP_FIRE_VELOCITY = 250.0f;
// Giant Slime
const int GIANT_SLIME_HP = 650;
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 = 85.0f;
// 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 float KING_RAT_RUNNING_RECOIL = 750.0f;
const int KING_RAT_HP = 700;
const int KING_RAT_DAMAGES = 8;
+// Cyclop
+const float CYCLOP_SPEED[4] = { 120, 130, 140, 150};
+const int CYCLOP_NUMBER_ROCKS[4] = { 2, 4, 6, 8};
+const float CYCLOP_FIRE_DELAY[4] = { 0.35f, 0.3f, 0.25f, 0.2f};
+//const float KING_RAT_RUNNING_RECOIL = 750.0f;
+//const int KING_RAT_HP = 700;
+//const int KING_RAT_DAMAGES = 8;
+
// EFFECTS
const float HURTING_DELAY = 0.4f;
const float HEART_BEAT_DELAY = 1.2f;
#endif // CONSTANTS_H_INCLUDED
diff --git a/src/CyclopEntity.cpp b/src/CyclopEntity.cpp
new file mode 100644
index 0000000..b0d3a09
--- /dev/null
+++ b/src/CyclopEntity.cpp
@@ -0,0 +1,285 @@
+#include "CyclopEntity.h"
+#include "BoltEntity.h"
+#include "PlayerEntity.h"
+#include "RockMissileEntity.h"
+#include "sfml_game/SpriteEntity.h"
+#include "sfml_game/ImageManager.h"
+#include "sfml_game/SoundManager.h"
+#include "Constants.h"
+#include "WitchBlastGame.h"
+
+#include <iostream>
+
+CyclopEntity::CyclopEntity(float x, float y)
+ : EnnemyEntity (ImageManager::getImageManager()->getImage(IMAGE_CYCLOP), x, y)
+{
+ width = 128;
+ height = 192;
+ creatureSpeed = CYCLOP_SPEED[0];
+ velocity = Vector2D(creatureSpeed);
+ hp = 300;
+ hpDisplay = hp;
+ hpMax = 300;
+ meleeDamages = 10;
+
+
+ type = ENTITY_ENNEMY_BOSS;
+ bloodColor = bloodRed;
+ shadowFrame = 8;
+ dyingFrame = 5;
+ deathFrame = FRAME_CORPSE_CYCLOP;
+ frame = 0;
+ if (game().getPlayerPosition().x > x) isMirroring = true;
+ sprite.setOrigin(64.0f, 64.0f);
+
+ state = 0;
+ timer = 2.0f;
+ counter = 10;
+ age = -1.5f;
+
+ resistance[ResistanceFrozen] = ResistanceVeryHigh;
+}
+
+int CyclopEntity::getHealthLevel()
+{
+ int healthLevel = 0;
+ if (hp <= hpMax * 0.25) healthLevel = 3;
+ else if (hp <= hpMax * 0.5) healthLevel = 2;
+ else if (hp <= hpMax * 0.75) healthLevel = 1;
+ return healthLevel;
+}
+
+void CyclopEntity::fire()
+{
+ new RockMissileEntity(x, y+30);
+ SoundManager::getSoundManager()->playSound(SOUND_THROW);
+}
+
+void CyclopEntity::computeStates(float delay)
+{
+ timer -= delay;
+
+ if (timer <= 0.0f)
+ {
+ if (state == 0) // walking
+ {
+ if (counter > 0)
+ {
+ counter--;
+ timer = 0.5f;
+ creatureSpeed = CYCLOP_SPEED[getHealthLevel()];
+ setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), creatureSpeed ));
+ }
+ else
+ {
+ state = 1; // charge
+ timer = 0.9f;
+ velocity.x = 0.0f;
+ velocity.y = 0.0f;
+ counter = CYCLOP_NUMBER_ROCKS[getHealthLevel()];
+ SoundManager::getSoundManager()->playSound(SOUND_CYCLOP00);
+ }
+ }
+ else if (state == 1) // fire
+ {
+ state = 2;
+ fire();
+ timer = 0.2;
+ }
+ else if (state == 2) // fire end
+ {
+ if (counter <= 1)
+ {
+ state = 0;
+ timer = CYCLOP_FIRE_DELAY[getHealthLevel()];
+ counter = 10;
+ }
+ else
+ {
+ counter--;
+ state = 1;
+ timer = 0.2f;
+ }
+ }
+ }
+}
+
+void CyclopEntity::animate(float delay)
+{
+ if (age <= 0.0f)
+ {
+ age += delay;
+ return;
+ }
+
+ if (isAgonising)
+ {
+ if (h < -0.01f)
+ {
+ isDying = true;
+ SpriteEntity* corpse;
+ corpse = new SpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_CORPSES_BIG), x, y + 48, 128, 128);
+ corpse->setFrame(deathFrame - FRAME_CORPSE_KING_RAT);
+
+ corpse->setZ(OFFSET_Y);
+ corpse->setType(ENTITY_CORPSE);
+ if (dyingSound != SOUND_NONE) SoundManager::getSoundManager()->playSound(dyingSound);
+ }
+ else
+ {
+ frame = dyingFrame;
+ hVelocity -= 700.0f * delay;
+ h += hVelocity * delay;
+ }
+
+ return;
+ }
+
+ // special states
+ if (specialState[SpecialStateIce].active) delay *= specialState[SpecialStateIce].parameter;
+
+ // IA
+ computeStates(delay);
+
+ // collisions
+ if (canCollide()) testSpriteCollisions();
+ BaseCreatureEntity::animate(delay);
+
+ // current frame
+ if (state == 0)
+ {
+ int r = ((int)(age * 5.0f)) % 4;
+ if (r == 2) frame = 0;
+ else if (r == 3) frame = 2;
+ else frame = r;
+ }
+ else if (state == 1)
+ {
+ isMirroring = game().getPlayer()->getX() > x;
+ frame = 3;
+ }
+ else if (state == 2)
+ {
+ frame = 4;
+ }
+
+
+ // frame's mirroring
+ if (velocity.x > 1.0f)
+ isMirroring = true;
+ else if (velocity.x < -1.0f)
+ isMirroring = false;
+}
+
+bool CyclopEntity::hurt(int damages, enumShotType hurtingType, int level)
+{
+ return EnnemyEntity::hurt(damages, hurtingType, level);
+}
+
+void CyclopEntity::calculateBB()
+{
+ boundingBox.left = OFFSET_X + (int)x - width / 2 + 32;
+ boundingBox.width = 58;
+ boundingBox.top = OFFSET_Y + (int)y - height / 2 + 120;
+ boundingBox.height = 90;
+}
+
+void CyclopEntity::afterWallCollide()
+{
+}
+void CyclopEntity::collideMapRight()
+{
+ velocity.x = -velocity.x;
+
+ afterWallCollide();
+}
+
+void CyclopEntity::collideMapLeft()
+{
+ velocity.x = -velocity.x;
+
+ afterWallCollide();
+}
+
+void CyclopEntity::collideMapTop()
+{
+ velocity.y = -velocity.y;
+
+ afterWallCollide();
+}
+
+void CyclopEntity::collideMapBottom()
+{
+ velocity.y = -velocity.y;
+
+ afterWallCollide();
+}
+
+
+void CyclopEntity::dying()
+{
+ ItemEntity* newItem = new ItemEntity(itemBossHeart, x, y);
+ newItem->setVelocity(Vector2D(100.0f + rand()% 250));
+ newItem->setViscosity(0.96f);
+ EnnemyEntity::dying();
+}
+
+
+void CyclopEntity::render(sf::RenderTarget* app)
+{
+ EnnemyEntity::render(app);
+
+ // stones
+ if (state == 1)
+ {
+ sprite.setTextureRect(sf::IntRect(1152, 0, 64, 64)); // small
+ //sprite.setTextureRect(sf::IntRect(1152, 64, 64, 64)); // medium
+ if (isMirroring)
+ sprite.setPosition(x + 60, y);
+ else
+ sprite.setPosition(x + 4, y);
+
+ // medium
+ /*if (isMirroring)
+ sprite.setPosition(x + 60, y - 12);
+ else
+ sprite.setPosition(x + 4, y - 12);*/
+
+ app->draw(sprite);
+
+ sprite.setPosition(x, y);
+ }
+
+ float l = hpDisplay * ((MAP_WIDTH - 1) * TILE_WIDTH) / hpMax;
+
+ sf::RectangleShape rectangle(sf::Vector2f((MAP_WIDTH - 1) * TILE_WIDTH, 25));
+ rectangle.setFillColor(sf::Color(0, 0, 0,128));
+ rectangle.setPosition(sf::Vector2f(OFFSET_X + TILE_WIDTH / 2, OFFSET_Y + 25 + (MAP_HEIGHT - 1) * TILE_HEIGHT));
+ app->draw(rectangle);
+
+ rectangle.setSize(sf::Vector2f(l, 25));
+ rectangle.setFillColor(sf::Color(190, 20, 20));
+ rectangle.setPosition(sf::Vector2f(OFFSET_X + TILE_WIDTH / 2, OFFSET_Y + 25 + (MAP_HEIGHT - 1) * TILE_HEIGHT));
+ app->draw(rectangle);
+
+ game().write( "Cimmerian Cyclop",
+ 18,
+ OFFSET_X + TILE_WIDTH / 2 + 10.0f,
+ OFFSET_Y + 25 + (MAP_HEIGHT - 1) * TILE_HEIGHT + 1.0f,
+ ALIGN_LEFT,
+ sf::Color(255, 255, 255),
+ app, 0 , 0);
+}
+
+void CyclopEntity::collideWithEnnemy(GameEntity* collidingEntity)
+{
+ EnnemyEntity* entity = static_cast<EnnemyEntity*>(collidingEntity);
+ if (entity->getMovingStyle() == movWalking)
+ {
+ inflictsRecoilTo(entity);
+ }
+}
+
+void CyclopEntity::inflictsRecoilTo(BaseCreatureEntity* targetEntity)
+{
+}
diff --git a/src/CyclopEntity.h b/src/CyclopEntity.h
new file mode 100644
index 0000000..f8d51e9
--- /dev/null
+++ b/src/CyclopEntity.h
@@ -0,0 +1,36 @@
+#ifndef CYCLOPENTITY_H
+#define CYCLOPENTITY_H
+
+#include "EnnemyEntity.h"
+#include "PlayerEntity.h"
+
+class CyclopEntity : public EnnemyEntity
+{
+ public:
+ CyclopEntity(float x, float y);
+ virtual void animate(float delay);
+ virtual void render(sf::RenderTarget* app);
+ virtual void calculateBB();
+ virtual void inflictsRecoilTo(BaseCreatureEntity* targetEntity);
+ protected:
+ virtual void collideMapRight();
+ virtual void collideMapLeft();
+ virtual void collideMapTop();
+ virtual void collideMapBottom();
+ void afterWallCollide();
+ virtual bool hurt(int damages, enumShotType hurtingType, int level);
+
+ virtual void collideWithEnnemy(GameEntity* collidingEntity);
+ virtual void dying();
+
+ void computeStates(float delay);
+ int getHealthLevel();
+ private:
+ float timer;
+ int state;
+ int counter;
+
+ void fire();
+};
+
+#endif // CYCLOPENTITY_H
diff --git a/src/RockMissileEntity.cpp b/src/RockMissileEntity.cpp
new file mode 100644
index 0000000..50a88a3
--- /dev/null
+++ b/src/RockMissileEntity.cpp
@@ -0,0 +1,127 @@
+#include "RockMissileEntity.h"
+#include "PlayerEntity.h"
+#include "sfml_game/SpriteEntity.h"
+#include "sfml_game/ImageManager.h"
+#include "sfml_game/SoundManager.h"
+#include "Constants.h"
+#include "WitchBlastGame.h"
+
+RockMissileEntity::RockMissileEntity(float x, float y)
+ : EnnemyEntity (ImageManager::getImageManager()->getImage(IMAGE_CYCLOP), x, y)
+{
+
+ Vector2D targetPos = game().getPlayerPosition();
+ imagesProLine = 20;
+ collisionDirection = -1;
+ type = ENTITY_ENNEMY;
+ movingStyle = movFlying;
+ bloodColor = bloodNone; // stones don't bleed
+ hasCollided = false;
+
+ age = 0.0f;
+
+ rockType = rand() % 3;
+ if (rockType == 2) rockType = 0;
+
+ if (rockType == 0)
+ {
+ creatureSpeed = 500.0f;
+ hp = BAT_HP;
+ meleeDamages = BAT_DAMAGES;
+ frame = 18;
+ }
+ else
+ {
+ creatureSpeed = 450.0f;
+ hp = BAT_HP * 2;
+ meleeDamages = BAT_DAMAGES;
+ frame = 38;
+ }
+
+ setVelocity(Vector2D(x, y).vectorNearlyTo(targetPos, creatureSpeed, 0.4f));
+}
+
+void RockMissileEntity::animate(float delay)
+{
+ EnnemyEntity::animate(delay);
+}
+
+void RockMissileEntity::calculateBB()
+{
+ boundingBox.left = (int)x - 10;
+ boundingBox.width = 20;
+ boundingBox.top = (int)y - 10;
+ boundingBox.height = 20;
+}
+
+void RockMissileEntity::collideWall()
+{
+ if (rockType == 1 && !hasCollided)
+ {
+ hasCollided = true;
+ if (collisionDirection == DIRECTION_RIGHT || collisionDirection == DIRECTION_LEFT) velocity.x = -velocity.x;
+ else velocity.y = -velocity.y;
+ }
+ else
+ {
+ dying();
+ }
+}
+
+void RockMissileEntity::collideMapRight()
+{
+ collisionDirection = DIRECTION_RIGHT;
+ collideWall();
+}
+
+void RockMissileEntity::collideMapLeft()
+{
+ collisionDirection = DIRECTION_LEFT;
+ collideWall();
+}
+
+void RockMissileEntity::collideMapTop()
+{
+ collisionDirection = DIRECTION_TOP;
+ collideWall();
+}
+
+void RockMissileEntity::collideMapBottom()
+{
+ collisionDirection = DIRECTION_BOTTOM;
+ collideWall();
+}
+
+void RockMissileEntity::collideWithEnnemy(GameEntity* collidingEntity)
+{
+}
+
+void RockMissileEntity::dying()
+{
+ isDying = true;
+ SoundManager::getSoundManager()->playSound(SOUND_ROCK_IMPACT);
+ game().makeShake(0.1f);
+
+ for (int i = 0; i < 4; i++)
+ {
+ SpriteEntity* blood = new SpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_BLOOD), x, y, 16, 16, 6);
+ blood->setZ(OFFSET_Y - 1);
+
+ blood->setFrame(12 + rand()%6);
+ blood->setType(ENTITY_BLOOD);
+ blood->setVelocity(Vector2D(rand()%150));
+ blood->setViscosity(0.95f);
+
+ float bloodScale = 1.0f + (rand() % 10) * 0.1f;
+ blood->setScale(bloodScale, bloodScale);
+
+ if ((collisionDirection == DIRECTION_LEFT) && (blood->getVelocity().x < 0.0f))
+ blood->setVelocity(Vector2D(-blood->getVelocity().x * 0.25f, blood->getVelocity().y));
+ else if ((collisionDirection == DIRECTION_RIGHT) && (blood->getVelocity().x > 0.0f))
+ blood->setVelocity(Vector2D(-blood->getVelocity().x * 0.25f, blood->getVelocity().y));
+ else if ((collisionDirection == DIRECTION_TOP) && (blood->getVelocity().y < 0.0f))
+ blood->setVelocity(Vector2D(blood->getVelocity().x, -blood->getVelocity().y * 0.25f));
+ else if ((collisionDirection == DIRECTION_BOTTOM) && (blood->getVelocity().y > 0.0f))
+ blood->setVelocity(Vector2D(blood->getVelocity().x, -blood->getVelocity().y * 0.25f));
+ }
+}
diff --git a/src/RockMissileEntity.h b/src/RockMissileEntity.h
new file mode 100644
index 0000000..695eeef
--- /dev/null
+++ b/src/RockMissileEntity.h
@@ -0,0 +1,29 @@
+#ifndef ROCKMISSILENTITY_H
+#define ROCKMISSILENTITY_H
+
+#include "EnnemyEntity.h"
+
+class RockMissileEntity : public EnnemyEntity
+{
+ public:
+ RockMissileEntity(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 collideWithEnnemy(GameEntity* collidingEntity);
+
+ virtual void dying();
+ private:
+ int collisionDirection;
+ int rockType;
+ bool hasCollided;
+
+ void collideWall();
+};
+
+#endif // ROCKMISSILENTITY_H

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 10:38 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68468
Default Alt Text
(22 KB)

Event Timeline