Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
23 KB
Referenced Files
None
Subscribers
None
diff --git a/src/Constants.h b/src/Constants.h
index 594c079..62ffaa2 100644
--- a/src/Constants.h
+++ b/src/Constants.h
@@ -1,364 +1,371 @@
/** 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.2.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_SPIDER_EGG,
IMAGE_LITTLE_SPIDER,
IMAGE_BUTCHER,
IMAGE_GIANT_SLIME,
IMAGE_KING_RAT,
IMAGE_CYCLOP,
IMAGE_GIANT_SPIDER,
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_ROCK_IMPACT,
SOUND_THROW,
SOUND_CYCLOP_00,
SOUND_CYCLOP_DIE,
SOUND_BUTCHER_00,
SOUND_BUTCHER_01,
SOUND_BUTCHER_HURT,
SOUND_BUTCHER_DIE,
SOUND_VIB
};
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_KING_RAT,
FRAME_CORPSE_GIANT_SLIME,
FRAME_CORPSE_CYCLOP,
FRAME_CORPSE_BUTCHER,
FRAME_CORPSE_GIANT_SPIDER
};
// 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.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 = 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 int FAIRY_FIRE_DAMAGES = 12;
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_SLIME_RED,
MONSTER_SLIME_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;
const float SLIME_FIRE_VELOCITY = 240.0f;
// 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;
// Butcher
const int BUTCHER_HP = 100;
const int BUTCHER_DAMAGES = 8;
const int BUTCHER_VELOCITY = 80;
// Giant Slime
const int GIANT_SLIME_HP = 550;
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] = { 5, 7, 9, 12};
const float CYCLOP_FIRE_DELAY[4] = { 0.3f, 0.26f, 0.23f, 0.2f};
-const int CYCLOP_HP = 1000;
+const int CYCLOP_HP = 800;
const int CYCLOP_DAMAGES = 10;
+// Giant Spider
+const float GIANT_SPIDER_SPEED[4] = { 235, 240, 245, 250};
+const int GIANT_SPIDER_NUMBER_EGGS[4] = { 10, 14, 16, 18};
+const float GIANT_SPIDER_FIRE_DELAY[4] = { 0.8f, 0.7f, 0.6f, 0.5f};
+const int GIANT_SPIDER_HP = 1000;
+const int GIANT_SPIDER_DAMAGE = 12;
+
// EFFECTS
const float HURTING_DELAY = 0.4f;
const float HEART_BEAT_DELAY = 1.2f;
#endif // CONSTANTS_H_INCLUDED
diff --git a/src/GiantSpiderEntity.cpp b/src/GiantSpiderEntity.cpp
index 21170d1..bc1cb3f 100644
--- a/src/GiantSpiderEntity.cpp
+++ b/src/GiantSpiderEntity.cpp
@@ -1,275 +1,305 @@
#include "GiantSpiderEntity.h"
#include "EnnemyBoltEntity.h"
#include "PlayerEntity.h"
#include "SpiderEggEntity.h"
#include "sfml_game/SpriteEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
#include <iostream>
GiantSpiderEntity::GiantSpiderEntity(float x, float y)
: EnnemyEntity (ImageManager::getImageManager()->getImage(IMAGE_GIANT_SPIDER), x, y)
{
width = 128;
height = 128;
- creatureSpeed = 240.0f;
+ creatureSpeed = GIANT_SPIDER_SPEED[0];
velocity = Vector2D(0.0f, 0.0f);
- hp = 400;
+ hp = GIANT_SPIDER_HP;
hpMax = hp;
hpDisplay = hp;
- meleeDamages = 12;
+ meleeDamages = GIANT_SPIDER_DAMAGE;
type = ENTITY_ENNEMY;
bloodColor = bloodGreen;
shadowFrame = 3;
dyingFrame = 4;
deathFrame = FRAME_CORPSE_GIANT_SPIDER;
//agonizingSound = SOUND_RAT_DYING;
sprite.setOrigin(64.0f, 64.0f);
h = 2000;
state = 0;
+ hurtLevel = 0;
creatureName = "???";
}
void GiantSpiderEntity::animate(float delay)
{
if (age <= 0.0f)
{
age += delay;
return;
}
if (!isAgonising)
{
if (state == 0) // falling
{
h -= delay * 300.0f;
if (h <= 0.0f)
{
h = 0;
state = 1;
timer = 1.0f;
creatureName = "Giant Spider";
}
}
else if (state == 1) // wait after falling
{
timer -= delay;
if (timer <= 0.0f)
{
state = 2;
velocity = Vector2D(creatureSpeed);
- timer = 6.0f;
+ timer = 10.0f;
fireDelay = 0.5f;
}
}
else if (state == 2) // moving
{
fireDelay -= delay;
if (fireDelay <= 0.0f)
{
fire(1);
fire(0);fire(0);fire(0);fire(0);
- fireDelay = 0.5f;
+ fireDelay = GIANT_SPIDER_FIRE_DELAY[hurtLevel];
}
timer -= delay;
- if (timer <= 0.0f)
+ /*if (timer <= 0.0f)
+ {
+ state = 3;
+ velocity = Vector2D(0.0f, 0.0f);
+ timer = 1.0f;
+ }*/
+ if (getHealthLevel() > hurtLevel)
{
+ hurtLevel++;
state = 3;
velocity = Vector2D(0.0f, 0.0f);
timer = 1.0f;
+ creatureSpeed = GIANT_SPIDER_SPEED[hurtLevel];
}
}
else if (state == 3) // wait after falling
{
timer -= delay;
if (timer <= 0.0f) state = 4;
}
else if (state == 4) // moving up
{
h += delay * 300.0f;
if (h >= 1500.0f)
{
- state = 0;
- for (int i = 0; i < 15; i++)
+ state = 5;
+ timer = 6.0f;
+ for (int i = 0; i < GIANT_SPIDER_NUMBER_EGGS[hurtLevel]; i++)
{
new SpiderEggEntity(OFFSET_X + TILE_WIDTH * 1.5f + rand() % (TILE_WIDTH * 12),
OFFSET_Y + TILE_HEIGHT * 1.5f + rand() % (TILE_HEIGHT * 6));
}
}
}
+ else if (state == 5) // waiting to fall
+ {
+ timer -= delay;
+ if (timer <= 0.0f)
+ state = 0;
+ }
// frame
frame = 0;
if (state == 2)
{
frame = ((int)(age * 6.0f)) % 4;
if (frame == 2) frame = 0;
else if (frame == 3) frame = 2;
}
}
EnnemyEntity::animate(delay);
z = y + 40;
}
+bool GiantSpiderEntity::hurt(int damages, enumShotType hurtingType, int level)
+{
+ if (hurtLevel < getHealthLevel()) damages /= 5;
+ return EnnemyEntity::hurt(damages, hurtingType, level);
+}
+
void GiantSpiderEntity::calculateBB()
{
boundingBox.left = (int)x - 45;
boundingBox.width = 90;
boundingBox.top = (int)y - 25;
boundingBox.height = 65;
}
void GiantSpiderEntity::collideMapRight()
{
velocity.x = -velocity.x;
if (recoil.active) recoil.velocity.x = -recoil.velocity.x;
}
void GiantSpiderEntity::collideMapLeft()
{
velocity.x = -velocity.x;
if (recoil.active) recoil.velocity.x = -recoil.velocity.x;
}
void GiantSpiderEntity::collideMapTop()
{
velocity.y = -velocity.y;
if (recoil.active) recoil.velocity.y = -recoil.velocity.y;
}
void GiantSpiderEntity::collideMapBottom()
{
velocity.y = -velocity.y;
if (recoil.active) recoil.velocity.y = -recoil.velocity.y;
}
void GiantSpiderEntity::collideWithEnnemy(GameEntity* collidingEntity)
{
EnnemyEntity* entity = static_cast<EnnemyEntity*>(collidingEntity);
if (entity->getMovingStyle() == movWalking)
{
- //setVelocity(Vector2D(entity->getX(), entity->getY()).vectorTo(Vector2D(x, y), creatureSpeed ));
Vector2D v = Vector2D(x, y).vectorTo(Vector2D(entity->getX(), entity->getY()), 150.0f);
entity->giveRecoil(false, v, 0.5f);
}
}
void GiantSpiderEntity::calculateRotation()
{
float h0 = 100;
float hf = 18;
if (state == 0)
{
if (h > h0) sprite.setRotation(180);
else if (h < hf) sprite.setRotation(0);
else
{
sprite.setRotation(180 + (h0 - h) * 180 / (h0 - hf));
}
}
if (state == 4)
{
if (h > h0) sprite.setRotation(180);
else if (h < hf) sprite.setRotation(0);
else
{
sprite.setRotation(180 - (h0 - h) * 180 / (h0 - hf));
}
}
else if (state == 2) sprite.setRotation(0);
}
void GiantSpiderEntity::render(sf::RenderTarget* app)
{
if (!isDying)
{
// shadow
sprite.setRotation(0.0f);
- if (state == 0 || state == 4)
+ if (state == 0 || state == 4 || state == 5)
{
int h0 = 850;
int hf = 600;
int fade = 0;
if (h < h0)
{
if (h < hf) fade = 255;
else
{
fade = (h0 - h) * 255 / (h0 - hf);
if (fade < 0) fade = 0;
else if (fade > 255) fade = 255;
}
sprite.setColor(sf::Color(255, 255, 255, fade));
sprite.setPosition(x, y);
sprite.setTextureRect(sf::IntRect(shadowFrame * width, 0, width, height));
app->draw(sprite);
sprite.setColor(sf::Color(255, 255, 255, 255));
}
}
else
{
sprite.setPosition(x, y);
sprite.setTextureRect(sf::IntRect(shadowFrame * width, 0, width, height));
app->draw(sprite);
}
}
calculateRotation();
if (state == 0 || state == 1 || state == 3 || state == 4)
{
if (y - h > 0)
{
int fade = 255;
if (state == 1) fade = 255 * timer;
else if (state == 3) fade = 255 * (1.0f - timer);
sf::RectangleShape line(sf::Vector2f(2, y - h));
line.setPosition(x - 1, 0);
line.setFillColor(sf::Color(255, 255, 255, fade));
app->draw(line);
}
}
sprite.setPosition(x, y - h);
sprite.setTextureRect(sf::IntRect(frame * width, 0, width, height));
app->draw(sprite);
displayLifeBar(creatureName, OFFSET_Y + 25 + (MAP_HEIGHT - 1) * TILE_HEIGHT, app);
if (game().getShowLogical())
{
displayBoundingBox(app);
displayCenterAndZ(app);
}
}
bool GiantSpiderEntity::canCollide()
{
return h <= 70.0f;
}
void GiantSpiderEntity::fire(int fireType)
{
SoundManager::getSoundManager()->playSound(SOUND_BLAST_FLOWER);
EnnemyBoltEntity* bolt;
bolt = new EnnemyBoltEntity(x, y, ShotTypeStandard, 0);
bolt->setDamages(5);
float fireVelocity = 180.0f;
if (specialState[SpecialStateIce].active) fireVelocity *= 0.5f;
bolt->setVelocity(Vector2D(fireVelocity));
//bolt->setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), fireVelocity ));
}
+
+int GiantSpiderEntity::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;
+}
diff --git a/src/GiantSpiderEntity.h b/src/GiantSpiderEntity.h
index 5a3d583..5ad2d39 100644
--- a/src/GiantSpiderEntity.h
+++ b/src/GiantSpiderEntity.h
@@ -1,32 +1,37 @@
#ifndef GIANTSPIDERENTITY_H
#define GIANTSPIDERENTITY_H
#include "EnnemyEntity.h"
class GiantSpiderEntity : public EnnemyEntity
{
public:
GiantSpiderEntity(float x, float y);
virtual void animate(float delay);
virtual void calculateBB();
virtual void render(sf::RenderTarget* app);
protected:
virtual void collideMapRight();
virtual void collideMapLeft();
virtual void collideMapTop();
virtual void collideMapBottom();
virtual void collideWithEnnemy(GameEntity* collidingEntity);
virtual bool canCollide();
+ virtual bool hurt(int damages, enumShotType hurtingType, int level);
+
+ int getHealthLevel();
private:
int state;
float timer;
float fireDelay;
+ int hurtLevel;
+
void calculateRotation();
void fire(int type);
std::string creatureName;
};
#endif // GIANTSPIDERENTITY_H
diff --git a/src/SpiderEggEntity.cpp b/src/SpiderEggEntity.cpp
index 781c63a..0278e65 100644
--- a/src/SpiderEggEntity.cpp
+++ b/src/SpiderEggEntity.cpp
@@ -1,192 +1,192 @@
#include "SpiderEggEntity.h"
#include "PlayerEntity.h"
#include "LittleSpiderEntity.h"
#include "BoltEntity.h"
#include "sfml_game/SpriteEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
SpiderEggEntity::SpiderEggEntity(float x, float y)
: EnnemyEntity (ImageManager::getImageManager()->getImage(IMAGE_SPIDER_EGG), x, y)
{
imagesProLine = 20;
type = ENTITY_ENNEMY_INVOCATED;
movingStyle = movFlying;
bloodColor = bloodGreen;
deathFrame = FRAME_CORPSE_SPIDER_EGG;
age = 0.0f;
h = 1800 + rand() % 1000;
hp = 24;
jumping = false;
hVelocity = 0.0f;
- lifetime = 10.0f + (rand() % 500) / 100;
+ lifetime = 12.0f + (rand() % 700) / 100;
}
void SpiderEggEntity::animate(float delay)
{
if (movingStyle == movFlying)
{
if (jumping)
{
hVelocity -= 300.0f * delay;
h += hVelocity * delay;
if (h <= 0.0f)
{
movingStyle = movWalking;
h = 0.0f;
}
}
else
{
h -= delay * 750.0f;
if (h < 0.0f)
{
h = 0.0f;
hVelocity = 100.0f;
jumping = true;
}
}
}
EnnemyEntity::animate(delay);
z = y + 25;
frame = 0;
if (lifetime - age < 1.0f) frame = 3;
else if (lifetime - age < 2.5f) frame = 2;
else if (lifetime - age < 5.0f) frame = 1;
}
void SpiderEggEntity::dyingFromAge()
{
new LittleSpiderEntity(x, y);
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(18 + rand()%6);
blood->setType(ENTITY_BLOOD);
blood->setVelocity(Vector2D(rand()%250));
blood->setViscosity(0.95f);
float bloodScale = 1.0f + (rand() % 10) * 0.1f;
blood->setScale(bloodScale, bloodScale);
}
isDying = true;
}
void SpiderEggEntity::render(sf::RenderTarget* app)
{
int nx = frame % imagesProLine;
int ny = frame / imagesProLine;
// shadow
if (h <= 1600)
{
int f = 1600 - h;
if (f > 255) f = 255;
sprite.setColor(sf::Color(255, 255, 255, f));
sprite.setPosition(x, y);
sprite.setTextureRect(sf::IntRect(4 * width, 0, width, height));
app->draw(sprite);
sprite.setColor(sf::Color(255, 255, 255, 255));
}
sprite.setPosition(x, y - h);
sprite.setTextureRect(sf::IntRect(nx * width, ny * height, width, height));
app->draw(sprite);
if (game().getShowLogical())
{
displayBoundingBox(app);
displayCenterAndZ(app);
}
}
void SpiderEggEntity::calculateBB()
{
boundingBox.left = (int)x - 20;
boundingBox.width = 40;
boundingBox.top = (int)y - 5;
boundingBox.height = 30;
}
bool SpiderEggEntity::canCollide()
{
return h < 70;
}
void SpiderEggEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
if (!isDying && !isAgonising && collideWithEntity(entity))
{
if (entity->getType() == ENTITY_PLAYER || entity->getType() == ENTITY_BOLT )
{
PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(entity);
BoltEntity* boltEntity = dynamic_cast<BoltEntity*>(entity);
if (movingStyle == movFlying && playerEntity != NULL && !playerEntity->isDead())
{
if (playerEntity->hurt(meleeDamages, ShotTypeStandard, 0))
{
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)
{
float xs = (x + boltEntity->getX()) / 2;
float ys = (y + boltEntity->getY()) / 2;
boltEntity->collide();
hurt(boltEntity->getDamages(), boltEntity->getBoltType(), boltEntity->getLevel());
if (bloodColor > bloodNone) game().generateBlood(x, y, bloodColor);
SoundManager::getSoundManager()->playSound(SOUND_IMPACT);
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)
{
float recoilVelocity = STONE_DECOIL_VELOCITY[boltEntity->getLevel()];
float recoilDelay = STONE_DECOIL_DELAY[boltEntity->getLevel()];
if (resistance[ResistanceRecoil] == ResistanceHigh)
{
recoilVelocity *= 0.75f;
recoilDelay *= 0.75f;
}
else if (resistance[ResistanceRecoil] == ResistanceVeryHigh)
{
recoilVelocity *= 0.5f;
recoilDelay *= 0.5f;
}
Vector2D recoilVector = Vector2D(boltEntity->getX(),
boltEntity->getY()).vectorTo(Vector2D(x, y),
recoilVelocity );
giveRecoil(true, recoilVector, recoilDelay);
}
}
}
}
}

File Metadata

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

Event Timeline