Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
diff --git a/src/LittleSpiderEntity.cpp b/src/LittleSpiderEntity.cpp
index a60791f..febcffe 100644
--- a/src/LittleSpiderEntity.cpp
+++ b/src/LittleSpiderEntity.cpp
@@ -1,105 +1,105 @@
#include "LittleSpiderEntity.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 "WitchBlastGame.h"
LittleSpiderEntity::LittleSpiderEntity(float x, float y, bool invocated)
: EnemyEntity (ImageManager::getInstance().getImage(IMAGE_LITTLE_SPIDER), x, y)
{
imagesProLine = 8;
creatureSpeed = 175.0f;
- velocity = Vector2D(creatureSpeed);
+ velocity = Vector2D(creatureSpeed * 0.25f);
hp = 16;
meleeDamages = 5;
type = invocated ? ENTITY_ENEMY_INVOCATED : ENTITY_ENEMY;
enemyType = invocated ? EnemyTypeSpiderLittle_invocated : EnemyTypeSpiderLittle;
bloodColor = BloodGreen;
shadowFrame = 4;
dyingFrame = 3;
deathFrame = FRAME_CORPSE_LITTLE_SPIDER;
agonizingSound = SOUND_SPIDER_LITTLE_DIE;
timer = (rand() % 50) / 10.0f;
- age = 0.0f;
+ if (invocated) age = 0.0f;
frame = 8;
sprite.setOrigin(32.0f, 40.0f);
resistance[ResistancePoison] = ResistanceImmune;
}
void LittleSpiderEntity::animate(float delay)
{
if (age > 0.0f && !isAgonising)
{
timer = timer - delay;
if (timer <= 0.0f)
{
timer = (rand() % 50) / 10.0f;
setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), creatureSpeed ));
}
frame = ((int)(age * 5.0f)) % 3;
}
EnemyEntity::animate(delay);
z = y + 21;
}
void LittleSpiderEntity::calculateBB()
{
boundingBox.left = (int)x - 18;
boundingBox.width = 36;
boundingBox.top = (int)y - 10;
boundingBox.height = 32;
}
void LittleSpiderEntity::collideMapRight()
{
velocity.x = -velocity.x;
if (recoil.active) recoil.velocity.x = -recoil.velocity.x;
computeFacingDirection();
}
void LittleSpiderEntity::collideMapLeft()
{
velocity.x = -velocity.x;
if (recoil.active) recoil.velocity.x = -recoil.velocity.x;
computeFacingDirection();
}
void LittleSpiderEntity::collideMapTop()
{
velocity.y = -velocity.y;
if (recoil.active) recoil.velocity.y = -recoil.velocity.y;
computeFacingDirection();
}
void LittleSpiderEntity::collideMapBottom()
{
velocity.y = -velocity.y;
if (recoil.active) recoil.velocity.y = -recoil.velocity.y;
computeFacingDirection();
}
void LittleSpiderEntity::collideWithEnemy(EnemyEntity* entity)
{
if (recoil.active && recoil.stun) return;
if (entity->getMovingStyle() == movWalking )
{
Vector2D vel = Vector2D(entity->getX(), entity->getY()).vectorTo(Vector2D(x, y), 100.0f );
giveRecoil(false, vel, 0.3f);
computeFacingDirection();
}
}
void LittleSpiderEntity::drop()
{
// no drop
}
diff --git a/src/SpiderEggEntity.cpp b/src/SpiderEggEntity.cpp
index e9a32aa..5d0f903 100644
--- a/src/SpiderEggEntity.cpp
+++ b/src/SpiderEggEntity.cpp
@@ -1,162 +1,163 @@
#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, bool invocated)
: EnemyEntity (ImageManager::getInstance().getImage(IMAGE_SPIDER_EGG), x, y)
{
imagesProLine = 20;
type = invocated ? ENTITY_ENEMY_INVOCATED : ENTITY_ENEMY;
enemyType = invocated ? EnemyTypeSpiderEgg_invocated : EnemyTypeSpiderEgg;
this->invocated = invocated;
movingStyle = movFlying;
bloodColor = invocated ? BloodNone : BloodGreen;
deathFrame = FRAME_CORPSE_SPIDER_EGG;
dyingSound = rand() % 2 == 0 ? SOUND_EGG_SMASH_00 : SOUND_EGG_SMASH_01;
meleeDamages = 5;
age = 0.0f;
h = 1800 + rand() % 1000;
hp = 24;
jumping = false;
hVelocity = 0.0f;
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;
}
}
}
EnemyEntity::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, invocated);
+ LittleSpiderEntity* ls = new LittleSpiderEntity(x, y, invocated);
+ ls->setAge(-0.3f);
for (int i = 0; i < 4; i++)
{
SpriteEntity* blood = new SpriteEntity(ImageManager::getInstance().getImage(IMAGE_BLOOD), x, y, 16, 16, 6);
blood->setZ(-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);
}
SoundManager::getInstance().playSound(SOUND_EGG_SMASH_00 + rand() % 2);
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(getHurtParams(meleeDamages, ShotTypeStandard, 0, false, SourceTypeMelee, enemyType, false)))
{
float xs = (x + playerEntity->getX()) / 2;
float ys = (y + playerEntity->getY()) / 2;
SpriteEntity* star = new SpriteEntity(ImageManager::getInstance().getImage(IMAGE_HURT_IMPACT), xs, ys);
star->setFading(true);
star->setZ(y+ 100);
star->setLifetime(0.7f);
star->setType(ENTITY_EFFECT);
star->setSpin(400.0f);
}
inflictsRecoilTo(playerEntity);
}
else if (boltEntity != NULL && !boltEntity->getDying() && boltEntity->getAge() > 0.05f)
{
EnemyEntity::collideWithBolt(boltEntity);
}
}
}
}

File Metadata

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

Event Timeline