Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126507
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
28 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/media/items_equip.png b/media/items_equip.png
index 5d8e4b6..ae7a96d 100644
Binary files a/media/items_equip.png and b/media/items_equip.png differ
diff --git a/media/sprite.png b/media/sprite.png
index f2073b9..33eedd6 100644
Binary files a/media/sprite.png and b/media/sprite.png differ
diff --git a/src/ArtefactDescriptionEntity.cpp b/src/ArtefactDescriptionEntity.cpp
index fefc37f..88f234c 100644
--- a/src/ArtefactDescriptionEntity.cpp
+++ b/src/ArtefactDescriptionEntity.cpp
@@ -1,111 +1,113 @@
#include "ArtefactDescriptionEntity.h"
#include "Constants.h"
#include "sfml_game/ImageManager.h"
#include "WitchBlastGame.h"
#include "StaticTextEntity.h"
ArtefactDescriptionEntity::ArtefactDescriptionEntity(ItemEntity::enumItemType itemType, WitchBlastGame* parent/*, sf::Font* my_font*/)
: SpriteEntity (ImageManager::getImageManager()->getImage(IMAGE_ITEMS_EQUIP), 0, 0, ITEM_WIDTH, ITEM_HEIGHT)
{
//font = my_font;
this->setLifetime(6.0f);
this->setFrame(itemType - ItemEntity::itemMagicianHat);
this->setType(ENTITY_ARTIFACT_DESCRIPTION);
float x0 = OFFSET_X + MAP_WIDTH * TILE_WIDTH * 0.5f - ARTEFACT_RECT_WIDTH * 0.5f;
rectangle.setSize(sf::Vector2f(ARTEFACT_RECT_WIDTH, ARTEFACT_RECT_HEIGHT));
rectangle.setPosition(sf::Vector2f(x0, ARTEFACT_POS_Y));
rectangle.setFillColor(sf::Color(20, 20, 70, 180));
rectangleBorder.setSize(sf::Vector2f(ARTEFACT_RECT_WIDTH + ARTEFACT_BORDER * 2.0f,
ARTEFACT_RECT_HEIGHT + ARTEFACT_BORDER * 2.0f));
rectangleBorder.setPosition(sf::Vector2f(x0 - ARTEFACT_BORDER, ARTEFACT_POS_Y - ARTEFACT_BORDER));
rectangleBorder.setFillColor(sf::Color(255, 255, 255, 180));
this->parent = parent;
this->x = x0 + 50.0f;
this->y = 500.0f;
sprite.setScale(3.5f, 3.5f);
z = 5000.0f;
switch (itemType)
{
case (ItemEntity::itemMagicianHat):
artefactName = "Enchanter Hat"; artefactDescription = "Increases fire rate"; break;
case (ItemEntity::itemLeatherBoots):
artefactName = "Leather Boots"; artefactDescription = "Increases speed"; break;
case (ItemEntity::itemBookDualShots):
artefactName = "Spell : Dual Bolts"; artefactDescription = "Shoots two bolts"; break;
case (ItemEntity::itemConcentrationAmulet):
artefactName = "Concentration Amulet"; artefactDescription = "Increases fire range"; break;
case (ItemEntity::itemBossKey):
artefactName = "Boss Key"; artefactDescription = "Open the boss gate"; break;
case (ItemEntity::itemVibrationGloves):
artefactName = "Vibration Gloves"; artefactDescription = "Vibrations + slighty increases fire rate"; break;
case (ItemEntity::itemMahoganyStaff):
artefactName = "Mahogany Staff"; artefactDescription = "Increases bolt's speed and damages"; break;
case (ItemEntity::itemFairy):
artefactName = "Fairy"; artefactDescription = "Help you in the dungeon"; break;
+ case (ItemEntity::itemLeatherBelt):
+ artefactName = "Leather Belt"; artefactDescription = "Increases fire rate"; break;
default: break;
}
}
ArtefactDescriptionEntity::~ArtefactDescriptionEntity()
{
}
void ArtefactDescriptionEntity::animate(float delay)
{
if (age < ARTEFACT_ZOOM_TIME)
{
float perc = 1.0f - age / ARTEFACT_ZOOM_TIME;
sprite.setScale(3.5f + perc * 50.0f, 3.5f + perc * 50.0f);
}
else
{
sprite.setScale(3.5f, 3.5f);
}
SpriteEntity::animate(delay);
}
void ArtefactDescriptionEntity::render(sf::RenderWindow* app)
{
int nx = frame;
int ny = 0;
if (imagesProLine > 0)
{
nx = frame % imagesProLine;
ny = frame / imagesProLine;
}
sprite.setTextureRect(sf::IntRect(nx * width, ny * height, /*(nx + 1) **/ width, /*(ny + 1) */ height));
sprite.setPosition(x, y);
sprite.setRotation(angle);
if (isFading)
{
sprite.setColor(sf::Color(255, 255, 255, (sf::Uint8)(getFade() * 255)));
}
if (isShrinking)
{
sprite.setScale(getFade(), getFade());
}
app->draw(rectangleBorder);
app->draw(rectangle);
app->draw(sprite);
StaticTextEntity::Write(app, artefactName, 22, 315.0f, ARTEFACT_POS_Y + 15.0f, ALIGN_LEFT, sf::Color(255, 255, 255));
StaticTextEntity::Write(app, artefactDescription, 20, 315.0f, ARTEFACT_POS_Y + 55.0f, ALIGN_LEFT, sf::Color(255, 255, 255));
}
diff --git a/src/Constants.h b/src/Constants.h
index 3af66ba..9ee20fb 100644
--- a/src/Constants.h
+++ b/src/Constants.h
@@ -1,247 +1,247 @@
/** This file is part of Ostrich Riders.
*
* 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>
//#define _68X68
const std::string APP_NAME = "Witch Blast";
const std::string APP_VERSION = "0.0.5";
const int SCREEN_WIDTH = 970; //1024;
const int SCREEN_HEIGHT = 720; //768;
const int TILE_WIDTH = 64;
const int TILE_HEIGHT = 64;
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,
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_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
};
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 = 5;
const float INITIAL_BOLT_VELOCITY = 700.0f;
const float FAIRY_SPEED = 180.0f; //400.0f;
const float FAIRY_FIRE_DELAY = 0.8f;
const float FAIRY_BOLT_LIFE = 0.4f;
const int FAIRY_BOLT_DAMAGES = 5;
const float FAIRY_BOLT_VELOCITY = 700.0f;
// Items
-const int NUMBER_EQUIP_ITEMS = 8;
+const int NUMBER_EQUIP_ITEMS = 9;
enum item_equip {
EQUIP_ENCHANTER_HAT,
EQUIP_LEATHER_BOOTS,
EQUIP_BOOK_DUAL,
EQUIP_CONCENTRATION_AMULET,
EQUIP_BOSS_KEY,
EQUIP_VIBRATION_GLOVES,
EQUIP_MAHONAGY_STAFF,
-
- EQUIP_FAIRY
+ EQUIP_FAIRY,
+ EQUIP_LEATHER_BELT
};
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;
// 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;
// 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 = 15;
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 = 10;
const int GREEN_RAT_DAMAGES = 5;
const float GREEN_RAT_FADE = 1.0f;
// Bat
const float BAT_SPEED = 250.0f;
const int BAT_HP = 5;
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 = 10;
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 = 10;
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 = 400;
const int KING_RAT_DAMAGES = 8;
// EFFECTS
const float HURTING_DELAY = 0.4f;
#endif // CONSTANTS_H_INCLUDED
diff --git a/src/ItemEntity.h b/src/ItemEntity.h
index 6f01832..d7c28b8 100644
--- a/src/ItemEntity.h
+++ b/src/ItemEntity.h
@@ -1,58 +1,59 @@
#ifndef ITEMENTITY_H
#define ITEMENTITY_H
#include "sfml_game/CollidingSpriteEntity.h"
class WitchBlastGame;
class ItemEntity : public CollidingSpriteEntity
{
public:
enum enumItemType
{
itemCopperCoin,
itemSilverCoin,
itemGoldCoin,
itemHealth,
itemMagicianHat,
itemLeatherBoots,
itemBookDualShots,
itemConcentrationAmulet,
itemBossKey,
itemVibrationGloves,
itemMahoganyStaff,
- itemFairy
+ itemFairy,
+ itemLeatherBelt
};
void setMerchandise(bool isMerchandise);
bool getMerchandise();
int getPrice();
/*ItemEntity(sf::Texture* image, float x, float y, int itemType, int spriteWidth, int spriteHeight);*/
ItemEntity(enumItemType itemType, float x, float y);
virtual void animate(float delay);
virtual void render(sf::RenderWindow* app);
virtual void calculateBB();
virtual void dying();
void setParent(WitchBlastGame* parent);
enumItemType getItemType() { return itemType; };
protected:
WitchBlastGame* parentGame;
enumItemType itemType;
bool isMerchandise;
virtual void collideMapRight();
virtual void collideMapLeft();
virtual void collideMapTop();
virtual void collideMapBottom();
virtual void readCollidingEntity(CollidingSpriteEntity* entity);
private:
};
#endif // ITEMENTITY_H
diff --git a/src/PlayerEntity.cpp b/src/PlayerEntity.cpp
index 94d7746..21f98e7 100644
--- a/src/PlayerEntity.cpp
+++ b/src/PlayerEntity.cpp
@@ -1,537 +1,552 @@
#include "PlayerEntity.h"
#include "BoltEntity.h"
#include "EnnemyBoltEntity.h"
#include "ItemEntity.h"
#include "FairyEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "Constants.h"
#include "WitchBlastGame.h"
#include <iostream>
PlayerEntity::PlayerEntity(sf::Texture* image, float x = 0.0f, float y = 0.0f) : BaseCreatureEntity (image, x, y, 64, 96)
{
currentFireDelay = -1.0f;
canFirePlayer = true;
type = ENTITY_PLAYER;
imagesProLine = 8;
playerStatus = playerStatusPlaying;
hp = INITIAL_PLAYER_HP;
hpDisplay = hp;
hpMax = INITIAL_PLAYER_HP;
gold = 0;
boltLifeTime = INITIAL_BOLT_LIFE;
bloodColor = bloodRed;
for (int i = 0; i < NUMBER_EQUIP_ITEMS; i++) equip[i] = false;
colliding = 0;
computePlayer();
// TEST
//equip[EQUIP_BOSS_KEY] = true;
}
void PlayerEntity::moveTo(float newX, float newY)
{
float dx = newX - x;
float dy = newY - y;
x = newX;
y = newY;
if (equip[EQUIP_FAIRY])
{
fairy->setX(fairy->getX() + dx);
fairy->setY(fairy->getY() + dy);
}
}
float PlayerEntity::getPercentFireDelay()
{
if (canFirePlayer) return 1.0f;
else return (1.0f - currentFireDelay / fireDelay);
}
int PlayerEntity::getColliding()
{
return colliding;
}
bool PlayerEntity::isDead()
{
return playerStatus==playerStatusDead;
}
void PlayerEntity::setEntering()
{
playerStatus = playerStatusEntering;
}
void PlayerEntity::pay(int price)
{
gold -= price;
if (gold < 0) gold = 0;
SoundManager::getSoundManager()->playSound(SOUND_BLAST_STANDARD);
}
void PlayerEntity::animate(float delay)
{
// rate of fire
if (!canFirePlayer)
{
currentFireDelay -= delay;
canFirePlayer = (currentFireDelay <= 0.0f);
}
// acquisition animation
if (playerStatus == playerStatusAcquire)
{
acquireDelay -= delay;
if (acquireDelay <= 0.0f)
{
equip[acquiredItem] = true;
computePlayer();
playerStatus = playerStatusPlaying;
if (acquiredItem == (int)EQUIP_FAIRY)
{
fairy = new FairyEntity(x, y - 50.0f, this);
}
}
}
else if (playerStatus == playerStatusUnlocking)
{
acquireDelay -= delay;
if (acquireDelay <= 0.0f)
{
playerStatus = playerStatusPlaying;
}
}
//z = y;
if (playerStatus != playerStatusDead) testSpriteCollisions();
colliding = 0;
BaseCreatureEntity::animate(delay);
if (isMoving())
{
frame = ((int)(age * 5.0f)) % 4;
if (frame == 2) frame = 0;
if (frame == 3) frame = 2;
SoundManager::getSoundManager()->playSound(SOUND_STEP);
}
else if (playerStatus == playerStatusAcquire || playerStatus == playerStatusUnlocking)
frame = 3;
else if (playerStatus == playerStatusDead)
frame = 0;
else
frame = 0;
if (x < OFFSET_X)
parentGame->moveToOtherMap(4);
else if (x > OFFSET_X + MAP_WIDTH * TILE_WIDTH)
parentGame->moveToOtherMap(6);
else if (y < OFFSET_Y)
parentGame->moveToOtherMap(8);
else if (y > OFFSET_Y + MAP_HEIGHT * TILE_HEIGHT - 5)
parentGame->moveToOtherMap(2);
if (playerStatus == playerStatusEntering)
{
if (boundingBox.left > OFFSET_X + TILE_WIDTH
&& (boundingBox.left + boundingBox.width) < OFFSET_X + TILE_WIDTH * (MAP_WIDTH - 1)
&& boundingBox.top > OFFSET_Y + TILE_HEIGHT
&& (boundingBox.top + boundingBox.height) < OFFSET_Y + TILE_HEIGHT * (MAP_HEIGHT - 1))
{
playerStatus = playerStatusPlaying;
parentGame->closeDoors();
}
}
if (playerStatus == playerStatusDead)
{
z = OFFSET_Y - 2;
}
}
void PlayerEntity::render(sf::RenderWindow* app)
{
sprite.setPosition(x, y);
if (playerStatus == playerStatusDead)
{
// blood
sprite.setTextureRect(sf::IntRect(6 * width, 0, width, height));
app->draw(sprite);
// body
sprite.setTextureRect(sf::IntRect(3 * width, height, width, height));
app->draw(sprite);
// feet
sprite.setTextureRect(sf::IntRect(3 * width, 2 * height, width, height));
app->draw(sprite);
// hand
sprite.setTextureRect(sf::IntRect(3 * width, 3 * height, width, height));
app->draw(sprite);
}
else
{
// shadow
sprite.setTextureRect(sf::IntRect(7 * width, 0, width, height));
app->draw(sprite);
// body
sprite.setTextureRect(sf::IntRect(frame * width, height, width, height));
app->draw(sprite);
+ // belt
+ if (equip[EQUIP_LEATHER_BELT])
+ {
+ sprite.setTextureRect(sf::IntRect(frame * width, 6 *height, width, height));
+ app->draw(sprite);
+ }
+
// head
if (playerStatus != playerStatusAcquire && playerStatus != playerStatusUnlocking)
{
sprite.setTextureRect(sf::IntRect(0, 0, width, height));
app->draw(sprite);
// hat
if (equip[EQUIP_ENCHANTER_HAT])
{
sprite.setTextureRect(sf::IntRect(3 * width, 0, width, height));
app->draw(sprite);
}
}
// feet
if( equip[EQUIP_LEATHER_BOOTS])
sprite.setTextureRect(sf::IntRect((frame + 4) * width, 2 * height, width, height));
else
sprite.setTextureRect(sf::IntRect(frame * width, 2 * height, width, height));
app->draw(sprite);
// staff
if ( equip[EQUIP_MAHONAGY_STAFF])
sprite.setTextureRect(sf::IntRect(frame * width + 4, 4 * height, width, height));
else
sprite.setTextureRect(sf::IntRect(frame * width + 4, 4 * height, width, height));
app->draw(sprite);
// hands
if( equip[EQUIP_VIBRATION_GLOVES])
sprite.setTextureRect(sf::IntRect((frame + 4) * width, 3 * height, width, height));
else
sprite.setTextureRect(sf::IntRect(frame * width, 3 * height, width, height));
app->draw(sprite);
// head
if (playerStatus == playerStatusAcquire || playerStatus == playerStatusUnlocking)
{
sprite.setTextureRect(sf::IntRect(width, 0, width, height));
app->draw(sprite);
// hat
if (equip[EQUIP_ENCHANTER_HAT])
{
sprite.setTextureRect(sf::IntRect(3 * width, 0, width, height));
app->draw(sprite);
}
// staff
sprite.setTextureRect(sf::IntRect(width * 1, 4 * height, width, height));
app->draw(sprite);
}
// necklace
if (equip[EQUIP_CONCENTRATION_AMULET])
{
sprite.setTextureRect(sf::IntRect(frame * width, 5 * height, width, height));
app->draw(sprite);
sprite.setColor(sf::Color(255,255,255, (1.0f + sin(age * 5.0f)) * 100));
sprite.setTextureRect(sf::IntRect(5 * width, 0, width, height));
app->draw(sprite);
sprite.setColor(sf::Color(255,255,255,255));
}
}
}
void PlayerEntity::calculateBB()
{
boundingBox.left = (int)x - width / 2;
boundingBox.width = width;
boundingBox.top = (int)y - height / 2;
boundingBox.height = height;
float fPrez = 10.0f;
boundingBox.left += fPrez;
boundingBox.width -= (fPrez + fPrez);
boundingBox.top += 52.0f;
boundingBox.height = boundingBox.width - 10.0f;
}
void PlayerEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
EnnemyBoltEntity* boltEntity = dynamic_cast<EnnemyBoltEntity*>(entity);
if (collideWithEntity(entity))
{
if (boltEntity != NULL && !boltEntity->getDying())
{
boltEntity->collide();
hurt(boltEntity->getDamages());
parentGame->generateBlood(x, y, bloodColor);
}
}
}
void PlayerEntity::move(int direction)
{
if (playerStatus == playerStatusPlaying)
{
float speedx = 0.0f, speedy = 0.0f;
if (direction == 1 || direction == 4 || direction == 7)
speedx = - creatureSpeed;
else if (direction == 3 || direction == 6 || direction == 9)
speedx = creatureSpeed;
if (direction == 1 || direction == 2 || direction == 3)
speedy = creatureSpeed;
else if (direction == 7 || direction == 8 || direction == 9)
speedy = - creatureSpeed;
setVelocity(Vector2D(speedx, speedy));
}
}
bool PlayerEntity::isMoving()
{
if (velocity.x < -1.0f || velocity.x > 1.0f) return true;
if (velocity.y < -1.0f || velocity.y > 1.0f) return true;
return false;
}
bool PlayerEntity::isEquiped(int eq)
{
return equip[eq];
}
void PlayerEntity::generateBolt(float velx, float vely)
{
BoltEntity* bolt = new BoltEntity(ImageManager::getImageManager()->getImage(1), x, y + 20, boltLifeTime);
bolt->setMap(map, TILE_WIDTH, TILE_HEIGHT, OFFSET_X, OFFSET_Y);
bolt->setDamages(fireDamages);
bolt->setVelocity(Vector2D(velx, vely));
}
void PlayerEntity::fire(int direction)
{
if (equip[EQUIP_FAIRY] && playerStatus != playerStatusDead)
fairy->fire(direction, map);
if (canFirePlayer && playerStatus != playerStatusDead)
{
SoundManager::getSoundManager()->playSound(SOUND_BLAST_STANDARD);
if (equip[EQUIP_BOOK_DUAL])
{
float shoot_angle = 0.2f;
if ((direction == 4 && velocity.x < -1.0f) || (direction == 6 && velocity.x > 1.0f)
|| (direction == 8 && velocity.y < -1.0f) || (direction == 2 && velocity.y > 1.0f))
shoot_angle = 0.1f;
else if ((direction == 6 && velocity.x < -1.0f) || (direction == 4 && velocity.x > 1.0f)
|| (direction == 2 && velocity.y < -1.0f) || (direction == 8 && velocity.y > 1.0f))
shoot_angle = 0.35f;
if (equip[EQUIP_VIBRATION_GLOVES]) shoot_angle += (1000 - rand() % 2000) * 0.0001f;
switch(direction)
{
case 4: generateBolt(-fireVelocity * cos(shoot_angle), fireVelocity * sin(shoot_angle));
generateBolt(-fireVelocity * cos(shoot_angle), - fireVelocity * sin(shoot_angle));break;
case 6: generateBolt(fireVelocity * cos(shoot_angle), fireVelocity * sin(shoot_angle));
generateBolt(fireVelocity * cos(shoot_angle), - fireVelocity * sin(shoot_angle));break;
case 8: generateBolt(fireVelocity * sin(shoot_angle), -fireVelocity * cos(shoot_angle));
generateBolt(-fireVelocity * sin(shoot_angle), - fireVelocity * cos(shoot_angle));break;
case 2: generateBolt(fireVelocity * sin(shoot_angle), fireVelocity * cos(shoot_angle));
generateBolt(-fireVelocity * sin(shoot_angle), fireVelocity * cos(shoot_angle));break;
}
}
else
{
if (equip[EQUIP_VIBRATION_GLOVES])
{
float shoot_angle = (1000 - rand() % 2000) * 0.0001f;
switch(direction)
{
case 4: generateBolt(-fireVelocity * cos(shoot_angle), fireVelocity * sin(shoot_angle)); break;
case 6: generateBolt(fireVelocity * cos(shoot_angle), fireVelocity * sin(shoot_angle)); break;
case 8: generateBolt(fireVelocity * sin(shoot_angle), -fireVelocity * cos(shoot_angle)); break;
case 2: generateBolt(fireVelocity * sin(shoot_angle), fireVelocity * cos(shoot_angle)); break;
}
}
else
{
switch(direction)
{
case 4: generateBolt(-fireVelocity, 0.0f); break;
case 6: generateBolt(fireVelocity, 0.0f); break;
case 8: generateBolt(0.0f, -fireVelocity); break;
case 2: generateBolt(0.0f, fireVelocity); break;
}
}
}
canFirePlayer = false;
currentFireDelay = fireDelay;
}
}
bool PlayerEntity::canFire()
{
return canFirePlayer;
}
bool PlayerEntity::canMove()
{
return (playerStatus == playerStatusPlaying);
}
void PlayerEntity::hurt(int damages)
{
if (!hurting)
{
SoundManager::getSoundManager()->playSound(SOUND_PLAYER_HIT);
BaseCreatureEntity::hurt(damages);
parentGame->generateBlood(x, y, bloodColor);
parentGame->generateBlood(x, y, bloodColor);
}
}
void PlayerEntity::loseItem(ItemEntity::enumItemType itemType, bool isEquip)
{
CollidingSpriteEntity* itemSprite
= new CollidingSpriteEntity(ImageManager::getImageManager()->getImage(isEquip ? IMAGE_ITEMS_EQUIP : IMAGE_ITEMS), x, y, 32, 32);
itemSprite->setMap(map, TILE_WIDTH, TILE_HEIGHT, OFFSET_X, OFFSET_Y);
itemSprite->setZ(OFFSET_Y - 1);
itemSprite->setFrame(itemType);
itemSprite->setType(ENTITY_BLOOD);
itemSprite->setVelocity(Vector2D(rand()%450));
itemSprite->setViscosity(0.95f);
itemSprite->setSpin( (rand() % 700) - 350.0f);
}
void PlayerEntity::dying()
{
playerStatus = playerStatusDead;
hp = 0;
SoundManager::getSoundManager()->playSound(SOUND_PLAYER_DIE);
setVelocity(Vector2D(0.0f, 0.0f));
int i;
for (i = 0; i < gold; i++) loseItem(ItemEntity::itemCopperCoin, false);
for (i = 0; i < NUMBER_EQUIP_ITEMS; i++)
if (equip[i]) loseItem(ItemEntity::enumItemType(i), true);
for (i = 0; i < 8; i++) parentGame->generateBlood(x, y, bloodColor);
CollidingSpriteEntity* itemSprite
= new CollidingSpriteEntity(ImageManager::getImageManager()->getImage(IMAGE_PLAYER), x, y, 64, 64);
itemSprite->setMap(map, TILE_WIDTH, TILE_HEIGHT, OFFSET_X, OFFSET_Y);
itemSprite->setZ(OFFSET_Y - 1);
itemSprite->setImagesProLine(10);
itemSprite->setFrame(/*11*/1);
itemSprite->setType(ENTITY_BLOOD);
itemSprite->setVelocity(Vector2D(rand()%450));
itemSprite->setViscosity(0.95f);
itemSprite->setSpin( (rand() % 700) - 350.0f);
}
void PlayerEntity::acquireItem(ItemEntity::enumItemType type)
{
if (type >= ItemEntity::itemMagicianHat) acquireStance(type);
else switch (type)
{
case ItemEntity::itemCopperCoin: gold++;
SoundManager::getSoundManager()->playSound(SOUND_COIN_PICK_UP);
break;
case ItemEntity::itemSilverCoin: gold = gold + 5; break;
case ItemEntity::itemGoldCoin: gold = gold + 10; break;
case ItemEntity::itemHealth: hp += 15;
SoundManager::getSoundManager()->playSound(SOUND_DRINK);
if (hp > hpMax) hp = hpMax; break;
default: break;
}
}
void PlayerEntity::computePlayer()
{
- fireDelay = INITIAL_PLAYER_FIRE_DELAY;
- creatureSpeed = INITIAL_PLAYER_SPEED;
- fireVelocity = INITIAL_BOLT_VELOCITY;
- fireDamages = INITIAL_BOLT_DAMAGES;
-
- if (equip[EQUIP_VIBRATION_GLOVES]) fireDelay *= 0.90f;
- if (equip[EQUIP_ENCHANTER_HAT]) fireDelay *= 0.75f;
- if (equip[EQUIP_LEATHER_BOOTS]) creatureSpeed += 50.0f;
- if (equip[EQUIP_BOOK_DUAL]) fireDelay *= 1.6f;
- if (equip[EQUIP_CONCENTRATION_AMULET]) boltLifeTime *= 1.5f;
+ float boltLifeTimeBonus = 1.0f;
+ float fireDelayBonus = 1.0f;
+ float creatureSpeedBonus = 1.0f;
+ float fireVelocityBonus = 1.0f;
+ float fireDamagesBonus = 1.0f;
+
+ if (equip[EQUIP_VIBRATION_GLOVES]) fireDelayBonus -= 0.10f;
+ if (equip[EQUIP_ENCHANTER_HAT]) fireDelayBonus -= 0.2f;
+ if (equip[EQUIP_LEATHER_BELT]) fireDelayBonus -= 0.15f;
+ if (equip[EQUIP_LEATHER_BOOTS]) creatureSpeedBonus += 0.25f;
+ if (equip[EQUIP_BOOK_DUAL]) fireDelayBonus += 0.6f;
+ if (equip[EQUIP_CONCENTRATION_AMULET]) boltLifeTimeBonus += 0.5f;
if (equip[EQUIP_MAHONAGY_STAFF])
{
- fireVelocity *= 1.15f;
- fireDamages *= 1.5f;
+ fireVelocityBonus += 0.15f;
+ fireDamagesBonus += 0.5f;
}
+
+ fireDelay = INITIAL_PLAYER_FIRE_DELAY * fireDelayBonus;
+ creatureSpeed = INITIAL_PLAYER_SPEED * creatureSpeedBonus;
+ fireVelocity = INITIAL_BOLT_VELOCITY * fireVelocityBonus;
+ fireDamages = INITIAL_BOLT_DAMAGES * fireDamagesBonus;
+ boltLifeTime = INITIAL_BOLT_LIFE * boltLifeTimeBonus;
}
void PlayerEntity::acquireStance(ItemEntity::enumItemType type)
{
velocity.x = 0.0f;
velocity.y = 0.0f;
playerStatus = playerStatusAcquire;
acquireDelay = ACQUIRE_DELAY;
acquiredItem = (ItemEntity::enumItemType)(type - ItemEntity::itemMagicianHat);
SoundManager::getSoundManager()->playSound(SOUND_BONUS);
}
void PlayerEntity::collideMapRight()
{
colliding = 6;
}
void PlayerEntity::collideMapLeft()
{
colliding = 4;
}
void PlayerEntity::collideMapTop()
{
colliding = 8;
}
void PlayerEntity::collideMapBottom()
{
colliding = 2;
}
void PlayerEntity::useBossKey()
{
velocity.x = 0.0f;
velocity.y = 0.0f;
playerStatus = playerStatusUnlocking;
acquireDelay = UNLOCK_DELAY;
acquiredItem = (ItemEntity::enumItemType)(type - ItemEntity::itemMagicianHat);
SoundManager::getSoundManager()->playSound(SOUND_BONUS);
equip[EQUIP_BOSS_KEY] = false;
SpriteEntity* spriteItem = new SpriteEntity(
ImageManager::getImageManager()->getImage(IMAGE_ITEMS_EQUIP),
x, y - 60.0f, ITEM_WIDTH, ITEM_HEIGHT);
spriteItem->setFrame(EQUIP_BOSS_KEY);
spriteItem->setZ(z);
spriteItem->setLifetime(UNLOCK_DELAY);
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 11:48 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68875
Default Alt Text
(28 KB)
Attached To
Mode
R78 witchblast
Attached
Detach File
Event Timeline