Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
diff --git a/src/LittleSpiderEntity.cpp b/src/LittleSpiderEntity.cpp
index 8bdc41f..53781ca 100644
--- a/src/LittleSpiderEntity.cpp
+++ b/src/LittleSpiderEntity.cpp
@@ -1,126 +1,142 @@
#include "LittleSpiderEntity.h"
#include "BoltEntity.h"
#include "PlayerEntity.h"
+#include "SpiderWebEntity.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, EnumSpiderType spideType, bool invocated)
: EnemyEntity (ImageManager::getInstance().getImage(IMAGE_LITTLE_SPIDER), x, y)
{
imagesProLine = 8;
creatureSpeed = 175.0f;
velocity = Vector2D(creatureSpeed * 0.25f);
- hp = 16;
+
meleeDamages = 5;
this->spideType = spideType;
if (spideType == SpiderTypeTarantula)
{
enemyType = invocated ? EnemyTypeSpiderTarantula_invocated : EnemyTypeSpiderTarantula;
frame = 8;
deathFrame = FRAME_CORPSE_LITTLE_SPIDER_TARANTULA;
dyingFrame = 11;
+ hp = 32;
+ webTimer = 3 + 0.1f * (float)(rand() % 50);
+ meleeType = ShotTypePoison;
+ meleeLevel = 1;
}
else
{
enemyType = invocated ? EnemyTypeSpiderLittle_invocated : EnemyTypeSpiderLittle;
frame = 0;
deathFrame = FRAME_CORPSE_LITTLE_SPIDER;
dyingFrame = 3;
+ hp = 16;
}
type = invocated ? ENTITY_ENEMY_INVOCATED : ENTITY_ENEMY;
bloodColor = BloodGreen;
shadowFrame = 4;
agonizingSound = SOUND_SPIDER_LITTLE_DIE;
timer = -1.0f; //(rand() % 50) / 10.0f;
if (invocated) age = 0.0f;
sprite.setOrigin(32.0f, 40.0f);
resistance[ResistancePoison] = ResistanceImmune;
roaming = true;
}
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 ));
roaming = false;
}
frame = ((int)(age * (roaming ? 1.5f : 5.0f))) % 3;
if (spideType == SpiderTypeTarantula)
frame += 8;
+
+ if (spideType == SpiderTypeTarantula)
+ {
+ webTimer = webTimer - delay;
+ if (webTimer <= 0.0f)
+ {
+ webTimer = 3 + 0.1f * (float)(rand() % 50);
+ new SpiderWebEntity(x, y, false);
+ }
+ }
}
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()
{
if (type == ENTITY_ENEMY)
EnemyEntity::drop();
}
diff --git a/src/LittleSpiderEntity.h b/src/LittleSpiderEntity.h
index 761a41e..32d9b1a 100644
--- a/src/LittleSpiderEntity.h
+++ b/src/LittleSpiderEntity.h
@@ -1,30 +1,31 @@
#ifndef LITTLESPIDERENTITY_H
#define LITTLESPIDERENTITY_H
#include "EnemyEntity.h"
#include "PlayerEntity.h"
enum EnumSpiderType { SpiderTypeStandard, SpiderTypeTarantula };
class LittleSpiderEntity : public EnemyEntity
{
public:
LittleSpiderEntity(float x, float y, EnumSpiderType spideType, bool invocated);
virtual void animate(float delay);
virtual void calculateBB();
protected:
virtual void collideMapRight();
virtual void collideMapLeft();
virtual void collideMapTop();
virtual void collideMapBottom();
virtual void collideWithEnemy(EnemyEntity* entity) override;
virtual void drop();
private:
float timer;
+ float webTimer;
bool roaming;
EnumSpiderType spideType;
};
#endif // LITTLESPIDERENTITY_H

File Metadata

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

Event Timeline