1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
class Tile : public Renderable // A Tile can be drawn to the screen
{
private:
Sprite sprite; // The thing to draw
Vector2f position; // X and Y of it's position
bool passable; // Can you walk through it?
public:
Tile(position, passable);
GetPosition();
IsPassable();
virtual Draw(Window&) { Window.draw(sprite); } // From Renderable
};
// Here is where I am struggling
enum class ItemType { QUEST, WEAPON, ARMOUR, ITEM };
class Item : public Renderable // An Item can be draw?
{
private:
ItemType type;
int value;
public:
Item(value);
};
class QuestItem : public Item
{
private:
int QuestID;
public:
QuestItem(QuestID);
// I am unsure if this needs it's own class, unless it has some unique use
// I can only think of containing a vector of quest ids it's related to
};
// Now I'm going in over my head with complexity, even though it seems simple on paper
enum class TierType { WARRIOR, ROGUE, MAGE };
enum class WeaponType { ONEHANDED, TWOHANDED, OFFHAND } // OFFHAND is shield slot weapon
enum class ElementalType { AIR, EARTH, FIRE, WATER, ELECTRICITY } // Would like to implement in future, for buff and skill upgrades
class WeaponItem : public Item
{
private:
TierType tier;
WeaponType type;
int damage;
public:
WeaponItem(tier, type, damage);
// Getters
// Setters
}
// ...
class Player : public Renderable
{
private:
std::vector<Item*> inventory; // In reality the item will be std::shared_ptr
std::vector<Item*> worn_inventory;
public:
};
class Map : public Renderable // A Map can be draw, right? Or should it be separate?
{
private:
std::vector<Tile> map;
std::vector<Item*> items;
std::vector<Player*> players;
public:
Map();
//Getters
// Setters
virtual Draw(Window&)
{
for(every tile in map) Window.draw(tile); // Draw map
for(every item in items) Window.draw(item); // Draw items
// What about drawing spells and projectiles? If a player casts a spell where does that happen?
for(every player in players) Window.draw(player); // Draw players, monsters, npcs
}
};
|