Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
12 KB
Referenced Files
None
Subscribers
None
diff --git a/media/items.png b/media/items.png
index 29e940e..49e1e78 100644
Binary files a/media/items.png and b/media/items.png differ
diff --git a/src/ItemEntity.cpp b/src/ItemEntity.cpp
index 51630c3..f76efe7 100644
--- a/src/ItemEntity.cpp
+++ b/src/ItemEntity.cpp
@@ -1,141 +1,147 @@
#include "ItemEntity.h"
#include "sfml_game/ImageManager.h"
#include "sfml_game/SoundManager.h"
#include "sfml_game/SpriteEntity.h"
#include "Constants.h"
#include "MagnetEntity.h"
#include "WitchBlastGame.h"
#include <iostream>
#include <sstream>
ItemEntity::ItemEntity(enumItemType itemType, float x, float y)
- : CollidingSpriteEntity(ImageManager::getImageManager()->getImage(itemType >= FirstEquipItem ? IMAGE_ITEMS_EQUIP : IMAGE_ITEMS), x, y, ITEM_WIDTH, ITEM_HEIGHT)
+ : CollidingSpriteEntity(ImageManager::getImageManager()->getImage(itemType >= FirstEquipItem ? IMAGE_ITEMS_EQUIP : IMAGE_ITEMS), x, y, ITEM_WIDTH, ITEM_HEIGHT)
{
type = ENTITY_ITEM;
this->itemType = itemType;
frame = itemType;
if (itemType >= FirstEquipItem) frame = itemType - FirstEquipItem;
isMerchandise = false;
imagesProLine = 10;
setMap(game().getCurrentMap(), TILE_WIDTH, TILE_HEIGHT, OFFSET_X, OFFSET_Y);
isBeating = false;
}
void ItemEntity::setMerchandise(bool isMerchandise)
{
this->isMerchandise = isMerchandise;
}
bool ItemEntity::getMerchandise()
{
return isMerchandise;
}
int ItemEntity::getPrice()
{
return (items[itemType].price);
}
void ItemEntity::animate(float delay)
{
z = y + height;
CollidingSpriteEntity::animate(delay);
if (age > 0.7f) testSpriteCollisions();
if (isBeating)
{
timer -= delay;
if (timer <= 0.0f)
{
timer = HEART_BEAT_DELAY;
SoundManager::getSoundManager()->playSound(SOUND_HEART);
}
float sc;
if (timer > HEART_BEAT_DELAY - 0.25f)
{
sc = timer - HEART_BEAT_DELAY + 1.25f;
}
else
sc = 1.0f;
sprite.setScale(sc, sc);
}
if (itemType == itemBossHeart && !isBeating && game().getCurrentMap()->isCleared())
{
// start beating
isBeating = true;
timer = HEART_BEAT_DELAY;
}
}
void ItemEntity::render(sf::RenderTarget* app)
{
// shadow
sprite.setTextureRect(sf::IntRect(9 * width, 2 * height, width, height));
app->draw(sprite);
// price
if (isMerchandise)
{
std::ostringstream oss;
oss << getPrice() << " $";
game().write(oss.str(), 16, x, y + 18.0f, ALIGN_CENTER, sf::Color(255, 255, 255), app, 0 , 0);
}
CollidingSpriteEntity::render(app);
}
void ItemEntity::calculateBB()
{
boundingBox.left = (int)x - width / 2;
boundingBox.width = width;
boundingBox.top = (int)y - height / 2;
boundingBox.height = height;
}
void ItemEntity::dying()
{
isDying = true;
}
void ItemEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
if (itemType == itemBossHeart && !game().getCurrentMap()->isCleared()) return;
- PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(entity);
- if (collideWithEntity(entity))
+ PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(entity);
+
+ if (collideWithEntity(entity))
+ {
+ if (playerEntity != NULL && !playerEntity->isDead())
{
- if (playerEntity != NULL && !playerEntity->isDead())
+ if (playerEntity->getHp() == playerEntity->getHpMax())
{
- if (isMerchandise == false || playerEntity->getGold() >= getPrice())
- {
- playerEntity->acquireItem(itemType);
+ // don't use health item if you don't need it
+ if (itemType >= itemHealthVerySmall && itemType <= itemHealth) return;
+ }
+ if (isMerchandise == false || playerEntity->getGold() >= getPrice())
+ {
+ playerEntity->acquireItem(itemType);
- if (isMerchandise) playerEntity->pay(getPrice());
+ if (isMerchandise) playerEntity->pay(getPrice());
- dying();
+ dying();
- if (!items[itemType].generatesStance)
- new MagnetEntity(x, y, playerEntity, itemType);
- }
+ if (!items[itemType].generatesStance)
+ new MagnetEntity(x, y, playerEntity, itemType);
}
}
+ }
}
void ItemEntity::collideMapRight()
{
- velocity.x = -velocity.x * 0.66f;
+ velocity.x = -velocity.x * 0.66f;
}
void ItemEntity::collideMapLeft()
{
- velocity.x = -velocity.x * 0.66f;
+ velocity.x = -velocity.x * 0.66f;
}
void ItemEntity::collideMapTop()
{
- velocity.y = -velocity.y * 0.66f;
+ velocity.y = -velocity.y * 0.66f;
}
void ItemEntity::collideMapBottom()
{
- velocity.y = -velocity.y * 0.66f;
+ velocity.y = -velocity.y * 0.66f;
}
diff --git a/src/Items.h b/src/Items.h
index aefb54a..72a45cc 100644
--- a/src/Items.h
+++ b/src/Items.h
@@ -1,225 +1,235 @@
#ifndef ITEMS_H
#define ITEMS_H
#include "Constants.h"
/** Alignment enum
* Alignment of the player and equipment.
*/
enum enumAlignment
{
AlignmentNone, /**< No alignment */
AlignmentLight, /**< Light (order) */
AlignmentDark /**< Dark (chaos) */
};
const int SPECIAL_SHOT_SLOTS_STANDARD = 2;
const int SPECIAL_SHOT_SLOTS_ADVANCED = 2;
const int SPECIAL_SHOT_SLOTS = 1 + SPECIAL_SHOT_SLOTS_STANDARD + SPECIAL_SHOT_SLOTS_ADVANCED;
/** Rarity enum
* Rarity of the equipment.
*/
enum enumRarity
{
RarityCommon, /**< Common */
RarityUnommon, /**< Uncommon */
RarityRare /**< Rare */
};
/** Familiar enum
* Familiars.
*/
enum enumFamiliar
{
FamiliarNone = -1, /**< No familiar */
FamiliarFairy, /**< Standard Fairy */
FamiliarFairyIce /**< Ice Fairy */
};
const int FAIRY_NUMBER = 2;
/** Item type enum
* All the items and equipments.
*/
enum enumItemType
{
ItemCopperCoin,
ItemSilverCoin,
ItemGoldCoin,
- itemHealth,
itemBossHeart,
+ itemHealthVerySmall,
+ itemHealthSmall,
+ itemHealth,
ItemMagicianHat, // first equip item
ItemLeatherBoots,
ItemBookDualShots,
ItemRageAmulet,
ItemBossKey,
ItemVibrationGloves,
ItemMahoganyStaff,
ItemFairy,
ItemLeatherBelt,
ItemBloodSnake,
ItemGemIce,
ItemGemIllusion,
ItemGemStone,
ItemGemLightning,
ItemFairyIce,
ItemRingIce,
ItemRingStone,
ItemRingLightning,
ItemRingIllusion
};
const int FirstEquipItem = (int) ItemMagicianHat; /*!< Used as an offset when creating items */
/*!
* \brief Item structure
*
* Contains all the data for an item.
*/
struct itemStuct
{
enumItemType type; /**< The item ID */
std::string name; /**< The item name */
std::string description; /**< The item description */
int price; /**< The item price (for shops) */
bool equip; /**< True if the item is an equipment */
enumFamiliar familiar; /**< True if the "item" is a familiar */
bool canBeSold; /**< True if the item is can be sold */
bool canBeFound; /**< True if the item is can be found */
bool generatesStance; /**< True if picking the item generates an acquiring stance*/
int level; /**< Minimal level where the item can be found */
enumRarity rarity; /**< Item rarity */
enumAlignment alignment; /**< Item alignment */
int requirement; /**< Pre-requisite item */
enumShotType specialShot; /**< Special shot */
};
-const int NUMBER_ITEMS = 24; /*!< Total number of items */
+const int NUMBER_ITEMS = 26; /*!< Total number of items */
/** Array with all the items and data */
const itemStuct items[NUMBER_ITEMS] =
{
{
ItemCopperCoin, "Copper coin", "A copper coin (value 1)",
1, false, FamiliarNone, false, false, false, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemSilverCoin, "Silver coin", "A silver coin (value 5)",
5, false, FamiliarNone, false, false, false, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemGoldCoin, "Gold coin", "A gold coin (value 20)",
20, false, FamiliarNone, false, false, false, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
- {
- itemHealth, "Health potion", "A health potion",
- 8, false, FamiliarNone, true, false, false, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
- },
{
itemBossHeart, "Titan's Heart", "Increases Max HP",
250, false, FamiliarNone, false, false, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
+ {
+ itemHealthVerySmall, "Apple", "Restores 3 HP",
+ 2, false, FamiliarNone, true, false, false, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
+ },
+ {
+ itemHealthSmall, "Bread", "Restores 7 HP",
+ 4, false, FamiliarNone, true, false, false, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
+ },
+ {
+ itemHealthSmall, "Cheese", "Restores 15 HP",
+ 8, false, FamiliarNone, true, false, false, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
+ },
{
ItemMagicianHat, "Sorcerer's Hat", "Increases fire rate",
20, true, FamiliarNone, true, true, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemLeatherBoots, "Velvet Boots", "Increases speed",
20, true, FamiliarNone, true, true, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemBookDualShots, "Spell : Dual Bolts", "Shoots two bolts",
20, true, FamiliarNone, true, true, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemRageAmulet, "Rage Amulet", "Increases fire range",
20, true, FamiliarNone, true, true, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemBossKey, "Boss Key", "Open the Boss gate",
200, true, FamiliarNone, false, false, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemVibrationGloves, "Vibration Gloves", "Increases bolt's speed rate and vibrates",
20, true, FamiliarNone, true, true, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemMahoganyStaff, "Mahogany Staff", "Increases bolt's speed and damage",
20, true, FamiliarNone, true, true, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemFairy, "Fairy", "Helps you in the dungeon",
20, true, FamiliarFairy, false, true, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemLeatherBelt, "Leather Belt", "Increases fire rate",
20, true, FamiliarNone, true, true, true, 1, RarityCommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemBloodSnake, "Blood Snake", "Increases damage",
25, true, FamiliarNone, true, true, true, 2, RarityUnommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemGemIce, "Ice Gem", "Ice attack (freeze)",
25, true, FamiliarNone, true, true, true, 2, RarityCommon, AlignmentNone, -1, ShotTypeIce
},
{
ItemGemIllusion, "Illusion Gem", "Illusion attack (ignore walls)",
25, true, FamiliarNone, true, true, true, 4, RarityUnommon, AlignmentDark, -1, ShotTypeIllusion
},
{
ItemGemStone, "Stone Gem", "Stone attack (repulse)",
25, true, FamiliarNone, true, true, true, 2, RarityCommon, AlignmentNone, -1, ShotTypeStone
},
{
ItemGemLightning, "Lighting Gem", "Lightning attack (bouncing)",
25, true, FamiliarNone, true, true, true, 2, RarityCommon, AlignmentNone, -1, ShotTypeLightning
},
{
ItemFairyIce, "Ice Fairy", "Helps you in the dungeon",
40, true, FamiliarFairyIce, false, true, true, 2, RarityUnommon, AlignmentNone, -1, ShotTypeStandard
},
{
ItemRingIce, "Sapphire Ring", "Increases ice power",
45, true, FamiliarNone, true, true, true, 3, RarityUnommon, AlignmentNone, ItemGemIce, ShotTypeStandard
},
{
ItemRingStone, "Obsidian Ring", "Increases stone power",
45, true, FamiliarNone, true, true, true, 3, RarityUnommon, AlignmentNone, ItemGemStone, ShotTypeStandard
},
{
ItemRingLightning, "Opal Ring", "Increases lightning power",
45, true, FamiliarNone, true, true, true, 3, RarityUnommon, AlignmentNone, ItemGemLightning, ShotTypeStandard
},
{
ItemRingIllusion, "Quartz Ring", "Increases illusion power",
45, true, FamiliarNone, true, true, true, 4, RarityUnommon, AlignmentNone, ItemGemIllusion, ShotTypeStandard
}
};
const int NUMBER_EQUIP_ITEMS = 19; /*!< Number of equip items */
/** Item equipment type enum
* All the equipments.
*/
enum item_equip_enum {
EQUIP_ENCHANTER_HAT,
EQUIP_LEATHER_BOOTS,
EQUIP_BOOK_DUAL,
EQUIP_CONCENTRATION_AMULET,
EQUIP_BOSS_KEY,
EQUIP_VIBRATION_GLOVES,
EQUIP_MAHOGANY_STAFF,
EQUIP_FAIRY,
EQUIP_LEATHER_BELT,
EQUIP_BLOOD_SNAKE,
EQUIP_GEM_ICE,
EQUIP_GEM_ILLUSION,
EQUIP_GEM_STONE,
EQUIP_GEM_LIGHTNING,
EQUIP_FAIRY_ICE,
EQUIP_RING_ICE,
EQUIP_RING_STONE,
EQUIP_RING_LIGHTNING,
EQUIP_RING_ILLUSION
};
#endif

File Metadata

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

Event Timeline