- redid forest trees, mountains, houses
- fixed major issue with entering structures
- exploring more ideas for soundtracks
+
+6/29/2016:
+==========
+
+ - added chests
+ - added q to drop items, as objects
+ - chests snag dropped objects, right click to reclaim
+ - control setting is good, needs saving though
3
-canSprint
-1
-canJump
-0
Slow
0
+canJump
+0
+canSprint
+1
};
class Object : public Entity{
-private:
- std::string iname;
public:
+ std::string iname;
std::string pickupDialog;
bool questObject = false;
/***********************************************************************************
* OLD STUFF THAT NEEDS TO GET UPDATED *
**********************************************************************************/
+
+using InventorySlot = std::pair<Item *, unsigned int>;
+
class Inventory {
private:
unsigned int size; //how many slots our inventory has
unsigned int sel; //what item is currently selected
int os = 0;
public:
- std::vector<std::pair<Item*, uint>> Items;
+ std::vector<InventorySlot> Items;
bool invOpen = false; //is the inventory open
bool invOpening = false; //is the opening animation playing
void setSelectionDown();
void draw(void); // Draws a text list of items in this inventory (should only be called for the player for now)
+
+ const Item* getCurrentItem(void);
};
void initInventorySprites(void);
TextureIterator(void) {
position = std::begin(textures);
}
+ ~TextureIterator(void) {
+ textures.clear();
+ }
TextureIterator(const std::vector<std::string> &l) {
for (const auto &s : l)
textures.emplace_back(Texture::loadTexture(s), s);
/**
* Defines how many game ticks it takes to go from day to night or vice versa.
*/
-constexpr const unsigned int DAY_CYCLE = 12000;
+constexpr const unsigned int DAY_CYCLE = 10000;
/**
* Defines the velocity of player when moved by the keyboard
for (const auto &xf : xmlFiles) {
if (xf[0] != '.') {
XMLDocument xmld;
- auto file = (xmlFolder + xf).c_str();
- xmld.LoadFile(file);
+ auto file = xmlFolder + xf;
+ xmld.LoadFile(file.c_str());
auto xmle = xmld.FirstChildElement("World");
xmle->DeleteAttribute("dindex");
xmle = xmle->NextSiblingElement();
}
- xmld.SaveFile(file, false);
+
+ xmld.SaveFile(file.c_str(), false);
}
}
arena->setBackground(WorldBGType::Forest);
arena->setBGM("assets/music/embark.wav");
+
+ player->inv->addItem("Wood Sword", 10);
+
+
// the main loop, in all of its gloriousness..
std::thread([&]{
while (gameRunning) {
Player::~Player()
{
delete inv;
+ delete &tex;
}
void Player::createFromXML(XMLElement *e, World *w=nullptr)
// handle give tags
if ((oxml = exml->FirstChildElement("give"))) {
do player->inv->addItem(oxml->Attribute("id"), oxml->UnsignedAttribute("count"));
- while ((oxml = oxml->NextSiblingElement()));
+ while ((oxml = oxml->NextSiblingElement("give")));
}
// handle take tags
(void)two;
return false;
}
+
+const Item* Inventory::getCurrentItem(void)
+{
+ if (Items.size() > 0)
+ return Items[sel].first;
+ else
+ return nullptr;
+}
width = HLINES(10);
height = HLINES(5);
tex = TextureIterator({"assets/chest.png"});
+ inv = new Inventory(1);
}
void Chest::act(void)
{
- //die();
+ if (isInside(ui::mouse) && player->isNear(this)) {
+ if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)) && !ui::dialogBoxExists)
+ for (auto &i : inv->Items) {
+ player->inv->addItem(i.first->name, i.second);
+ inv->takeItem(i.first->name, i.second);
+ }
+ }
+
+ for (auto &e : currentWorld->entity) {
+ if (e->type == OBJECTT && e->isNear(this)) {
+ auto o = dynamic_cast<Object *>(e);
+ inv->addItem(o->iname, 1);
+ e->health = 0;
+ }
+ }
}
void Chest::onHit(unsigned int _health)
action::disable();
heyOhLetsGo = 0;
+ } else if (SDL_KEY == SDLK_q) {
+ auto item = player->inv->getCurrentItem();
+ if (item != nullptr) {
+ if (player->inv->takeItem(item->name, 1) == 0)
+ currentWorld->addObject(item->name, "o shit waddup",
+ player->loc.x + player->width / 2, player->loc.y + player->height / 2);
+ }
} else switch (SDL_KEY) {
case SDLK_F3:
debug ^= true;
if (entity[i] == e) {
switch (e->type) {
case STRUCTURET:
- killed = "structure";
+ killed = " structure";
build.erase(std::find(std::begin(build), std::end(build), e));
break;
case NPCT:
- killed = "NPC";
+ killed = "n NPC";
npc.erase(std::find(std::begin(npc), std::end(npc), e));
break;
case MOBT:
- killed = "mob";
+ killed = " mob";
mob.erase(std::find(std::begin(mob), std::end(mob), e));
break;
case OBJECTT:
- killed = "object";
+ killed = "n object";
object.erase(std::find(std::begin(object), std::end(object), *Objectp(e)));
break;
default:
break;
}
- std::cout << "Killed a " << killed << "...\n";
+ std::cout << "Killed a" << killed << "...\n";
entity.erase(entity.begin() + i);
return;
}
return nullptr;
_currentXML = xmlFolder + path;
- _currentXMLRaw = readFile(_currentXML.c_str());
+ const char *worthless = readFile(_currentXML.c_str());
+ _currentXMLRaw = worthless;
+ delete[] worthless;
// create a temporary XMLDocument if this isn't the main world
if (!loadedLeft && !loadedRight)
<style background="1" bgm="assets/music/embark.wav" folder="assets/style/classic/"/>
<floor width="1600"/>
<link outside="town.xml"/>
- <npc name="Bob" hasDialog="false" spawnx="30"/>
+ <npc name="Bob" hasDialog="false" spawnx="30" health="1" x="-229.27991" y="0" dindex="9999"/>
</IndoorWorld>
<Dialog name="Guy">
<text id="0" nextid="1">
Hello there! My name is Ralph.
- <gotox>300</gotox>
+ <gotox>300</gotox>
</text>
<text id="1">
...
- <gotox>1000</gotox>
+ <gotox>1000</gotox>
<set id="Slow" value="0"/>
<set id="canSprint" value="1"/>
</text>
<text id="0" stop="true">
Hey friend! It's dangerous out there, here take these!
Wait, promise you'll stop by my stand in the local market!
- <give id="Wood Sword" count="1"/> <give id="Hunters Bow" count="1"/> <give id="Crude Arrow" count="110"/> <give id="Fried Chicken" count="1"/> <give id="Mossy Torch" count="1"/></text>
+ <give id="Wood Sword" count="1"/> <give id="Hunters Bow" count="1"/> <give id="Crude Arrow" count="110"/> <give id="Fried Chicken" count="1"/> <give id="Mossy Torch" count="1"/></text>
</Dialog>
<Dialog name="Bob">
<text id="0" nextid="1" pause="true">
Hey. Have a Dank MayMay :)
- <give id="Dank MayMay" count="1"/></text>
+ <give id="Dank MayMay" count="1"/></text>
<text id="1" nextid="2">
What? You want another Dank MayMay?
</text>
<text id="2" nextid="3" pause="true">
K.
- <give id="Dank MayMay" count="1"/></text>
+ <give id="Dank MayMay" count="1"/></text>
<text id="3" nextid="4">
Well... I'm out of Dank MayMays.
</text>
<text id="4">
Have a sword though.
- <give id="Wood Sword" count="1"/></text>
+ <give id="Wood Sword" count="1"/></text>
</Dialog>
<generation type="Random" width="1600"/>
<time>6000</time>
<spawnx>-300</spawnx>
- <npc name="Sanc" hasDialog="true" health="1" x="414.76144" y="62.599087" dindex="9999"/>
- <npc name="Bob" hasDialog="true" spawnx="30" health="1" x="356.11185" y="60.999081" dindex="0"/>
+ <npc name="Sanc" hasDialog="true" health="1" x="464.45755" y="65.399185" dindex="0"/>
+ <npc name="Bob" hasDialog="true" spawnx="30" health="1" x="-772.5" y="59.999001" dindex="0"/>
<structure type="1" spawnx="300" alive="1"/>
<structure inside="bobshouse.xml" type="1" spawnx="10" alive="1"/>
<chest alive="1"/>
<Dialog name="Bob">
<text id="0" nextid="1" pause="true">
+ <give id="Dank MayMay" count="10"/>
<content alive="1">
Hey there! The name's Bob. Good to see you've finally woken up from your nap by the cliff there... lol
</content>