Added all the assets. Ability system now partially implemented - it needs to interface with the current QMap to check for collisions, etc.. Things may now possess up to 10 abilities, from 1 to 0 on the keyboard. The GodHand ability is always in the first slot. onThought should probably be moved back into Thing, as it has become more generalized - perhaps unhandled thoughts can be passed to the subclass's onThought.
|
@ -39,7 +39,7 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>..\..\src;..\..\src\render;..\..\src\states;..\..\src\things;C:\Dev\glew-1.11.0\include;C:\Dev\SDL2-2.0.3\include;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\..\src;..\..\src\render;..\..\src\states;..\..\src\abilities;..\..\src\things;C:\Dev\glew-1.11.0\include;C:\Dev\SDL2-2.0.3\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Dev\SDL2-2.0.3\lib\x86;C:\Dev\glew-1.11.0\lib\Release\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
@ -79,6 +79,9 @@ xcopy /s /e /d /y "..\..\data" "$(OutDir)data\"</Command>
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\abilities\Ability.cpp" />
|
||||
<ClCompile Include="..\..\src\abilities\GodHand.cpp" />
|
||||
<ClCompile Include="..\..\src\abilities\VampiricNom.cpp" />
|
||||
<ClCompile Include="..\..\src\Controller.cpp" />
|
||||
<ClCompile Include="..\..\src\Core.cpp" />
|
||||
<ClCompile Include="..\..\src\fio.cpp" />
|
||||
|
@ -111,6 +114,9 @@ xcopy /s /e /d /y "..\..\data" "$(OutDir)data\"</Command>
|
|||
<ClCompile Include="..\..\src\Tile.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\abilities\Ability.hpp" />
|
||||
<ClInclude Include="..\..\src\abilities\GodHand.hpp" />
|
||||
<ClInclude Include="..\..\src\abilities\VampiricNom.hpp" />
|
||||
<ClInclude Include="..\..\src\common.hpp" />
|
||||
<ClInclude Include="..\..\src\Controller.hpp" />
|
||||
<ClInclude Include="..\..\src\Core.hpp" />
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
<Filter Include="Classes\Render">
|
||||
<UniqueIdentifier>{0456f39f-2ee3-4214-9084-267f2a828a15}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\Abilities">
|
||||
<UniqueIdentifier>{c1ddd6ae-6d50-4ee0-97b8-599cf2b23e0b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\Controller.cpp">
|
||||
|
@ -117,6 +120,15 @@
|
|||
<ClCompile Include="..\..\src\things\GnashingGibber.cpp">
|
||||
<Filter>Classes\Things</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\abilities\GodHand.cpp">
|
||||
<Filter>Classes\Abilities</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\abilities\Ability.cpp">
|
||||
<Filter>Classes\Abilities</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\abilities\VampiricNom.cpp">
|
||||
<Filter>Classes\Abilities</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\Controller.hpp">
|
||||
|
@ -212,5 +224,14 @@
|
|||
<ClInclude Include="..\..\src\things\GnashingGibber.hpp">
|
||||
<Filter>Classes\Things</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\abilities\Ability.hpp">
|
||||
<Filter>Classes\Abilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\abilities\GodHand.hpp">
|
||||
<Filter>Classes\Abilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\abilities\VampiricNom.hpp">
|
||||
<Filter>Classes\Abilities</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 193 B |
After Width: | Height: | Size: 75 B |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 516 B After Width: | Height: | Size: 917 B |
|
@ -0,0 +1,9 @@
|
|||
#include "Ability.hpp"
|
||||
|
||||
Ability::Ability() {
|
||||
sprite = NULL;
|
||||
}
|
||||
|
||||
Ability::~Ability() {
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef ABILITY_HPP
|
||||
#define ABILITY_HPP
|
||||
#include <string>
|
||||
#include "Sprite.hpp"
|
||||
|
||||
class Thing;
|
||||
|
||||
class Ability {
|
||||
public:
|
||||
Ability();
|
||||
~Ability();
|
||||
Sprite *getSprite() { return sprite; };
|
||||
std::string getName() { return name; };
|
||||
virtual int onUse() { return 0; };
|
||||
virtual int onPrompt() { return 0; };
|
||||
void setOwner(Thing *thing) { owner = thing; };
|
||||
protected:
|
||||
Sprite *sprite;
|
||||
std::string info;
|
||||
std::string name;
|
||||
Thing *owner;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,20 @@
|
|||
#include "GodHand.hpp"
|
||||
#include "Controller.hpp"
|
||||
#include "Thing.hpp"
|
||||
|
||||
GodHand::GodHand() {
|
||||
name = "God Hand";
|
||||
info = "A device of eminence. Allows soul swapping.";
|
||||
sprite = new Sprite("data/sprites/abilities/GodHand.png", 16, 16);
|
||||
}
|
||||
GodHand::~GodHand() {
|
||||
delete sprite;
|
||||
}
|
||||
int GodHand::onUse() {
|
||||
owner->getController()->recvMessage("The nature of Things have changed.");
|
||||
return 0;
|
||||
}
|
||||
int GodHand::onPrompt() {
|
||||
owner->getController()->recvMessage("Soul swap with what?");
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef GODHAND_HPP
|
||||
#define GODHAND_HPP
|
||||
#include "Ability.hpp"
|
||||
|
||||
class GodHand : public Ability {
|
||||
public:
|
||||
GodHand();
|
||||
~GodHand();
|
||||
virtual int onUse();
|
||||
virtual int onPrompt();
|
||||
};
|
||||
#endif
|
|
@ -0,0 +1,20 @@
|
|||
#include "VampiricNom.hpp"
|
||||
#include "Controller.hpp"
|
||||
#include "Thing.hpp"
|
||||
|
||||
VampiricNom::VampiricNom() {
|
||||
name = "Vampiric Noms";
|
||||
info = "Drains target's lifeforce.";
|
||||
sprite = new Sprite("data/sprites/abilities/VampiricNom.png", 16, 16);
|
||||
}
|
||||
VampiricNom::~VampiricNom() {
|
||||
delete sprite;
|
||||
}
|
||||
int VampiricNom::onUse() {
|
||||
owner->getController()->recvMessage("*nom*");
|
||||
return 0;
|
||||
}
|
||||
int VampiricNom::onPrompt() {
|
||||
owner->getController()->recvMessage("Chomp what?");
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef VAMPIRICNOM_HPP
|
||||
#define VAMPIRICNOM_HPP
|
||||
#include "Ability.hpp"
|
||||
|
||||
class VampiricNom : public Ability {
|
||||
public:
|
||||
VampiricNom();
|
||||
~VampiricNom();
|
||||
virtual int onUse();
|
||||
virtual int onPrompt();
|
||||
};
|
||||
#endif
|
|
@ -25,6 +25,7 @@ class Texture {
|
|||
int destroyTexture();
|
||||
GLuint texture; //
|
||||
int w, h; // width and height of this image
|
||||
std::string getName() { return name; };
|
||||
private:
|
||||
std::string name;
|
||||
unsigned int flags; // status flags
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "Denizen.hpp"
|
||||
#include "SightSeer.hpp"
|
||||
#include "GnashingGibber.hpp"
|
||||
#include "GodHand.hpp"
|
||||
#include "common.hpp"
|
||||
#include <algorithm> // remove_if
|
||||
#include <iterator>
|
||||
|
@ -49,6 +50,7 @@ GameState::GameState() {
|
|||
|
||||
pc.thing = new GnashingGibber();
|
||||
pc.thing->setController(&pc);
|
||||
pc.thing->unshiftAbility(new GodHand());
|
||||
current_map->thing.push_back(pc.thing);
|
||||
|
||||
current_map->thing.push_back(new Denizen());
|
||||
|
@ -67,6 +69,12 @@ GameState::GameState() {
|
|||
|
||||
ui_controls = new Ui("data/sprites/ui_controls.png", 192, 128);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Ui* ui_abil = new Ui("data/sprites/null.png", 16, 16);
|
||||
ui_abilities.push_back(ui_abil);
|
||||
ui_state->pushUi(ui_abil);
|
||||
}
|
||||
|
||||
refreshUi();
|
||||
|
||||
core.pushMessage("The Jade Emperor has banished you from the Realm of Heaven");
|
||||
|
@ -275,12 +283,27 @@ int GameState::refreshUi() {
|
|||
ui_sheet->setPosition(width - ui_sheet->getWidth()*2, 0);
|
||||
ui_sheet->doRefresh(width, height);
|
||||
|
||||
ui_character->setPosition(ui_sheet->x + (ui_character->getWidth()), ui_sheet->y+(35*2));
|
||||
ui_character->setPosition(ui_sheet->x + 44 - (ui_character->getWidth()), ui_sheet->y+ 110 - (ui_character->getHeight()));
|
||||
ui_character->doRefresh(width, height);
|
||||
|
||||
ui_sheet_name->setPosition(ui_character->x + (32*2), ui_character->y);
|
||||
ui_sheet_name->doRefresh(width, height);
|
||||
// set sprite render
|
||||
// set ability sprites if possible
|
||||
for (int y = 0; y < 1; y++) {
|
||||
for (int x = 0; x < 5; x++) {
|
||||
int id = x + y;
|
||||
Ability *ability;
|
||||
if ((ability = pc.thing->getAbility(id)) != NULL) {
|
||||
LOG(LOG_INFO) << "ability " << id << " " << ability->getName();
|
||||
ui_abilities[id]->setImage(ability->getSprite()->getTexture()->getName().c_str(), 16, 16); // hue hue
|
||||
ui_abilities[id]->setPosition(ui_sheet->x + 16 + (49*x), ui_sheet->y + 160 + (32*y));
|
||||
ui_abilities[id]->doRefresh(width, height);
|
||||
} else {
|
||||
ui_abilities[id]->setImage("data/sprites/null.png", 16, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -53,5 +53,6 @@ class GameState : public State {
|
|||
Ui *ui_controls;
|
||||
UiText *ui_console;
|
||||
UiText *ui_intro;
|
||||
std::vector<Ui*> ui_abilities;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "GnashingGibber.hpp"
|
||||
#include "VampiricNom.hpp"
|
||||
GnashingGibber::GnashingGibber() {
|
||||
name = "Gnashing Gibber";
|
||||
sprite = new Sprite("data/sprites/gnashing_gibber.png", 16, 32);
|
||||
pushAbility(new VampiricNom());
|
||||
speed = 2;
|
||||
}
|
||||
GnashingGibber::~GnashingGibber() {
|
||||
|
@ -10,20 +12,42 @@ GnashingGibber::~GnashingGibber() {
|
|||
int GnashingGibber::onThought(Thought thought) {
|
||||
switch(thought.type) {
|
||||
case Thought::MOVE:
|
||||
if (thought.loc.x < 0) direction.x = -1.0f;
|
||||
else if (thought.loc.x > 0) direction.x = 1.0f;
|
||||
else direction.x = 0.0f;
|
||||
if (thought.loc.y < 0) direction.y = -1.0f;
|
||||
else if (thought.loc.y > 0) direction.y = 1.0f;
|
||||
else direction.y = 0.0f;
|
||||
if (thought_last.type == Thought::ABILITY) {
|
||||
printMsg("You nom at the air");
|
||||
Ability *ability = getAbility(thought_last.id-1);
|
||||
if (ability != NULL) {
|
||||
ability->onUse();
|
||||
} else {
|
||||
printMsg("You nom at the air");
|
||||
}
|
||||
} else {
|
||||
addVelocity(thought.loc * speed);
|
||||
}
|
||||
break;
|
||||
case Thought::ABILITY:
|
||||
printMsg("Nom where?");
|
||||
Ability *ability;
|
||||
if ((ability = getAbility(thought.id-1)) != NULL) {
|
||||
ability->onPrompt();
|
||||
} else {
|
||||
printMsg("You bite your tongue.");
|
||||
}
|
||||
break;
|
||||
case Thought::WAIT:
|
||||
direction.x = direction.y = direction.z = 0.0f;
|
||||
if (thought_last.type == Thought::ABILITY) {
|
||||
printMsg("You waste time.");
|
||||
Ability *ability = getAbility(thought_last.id-1);
|
||||
if (ability != NULL) {
|
||||
ability->onUse();
|
||||
} else {
|
||||
printMsg("You vibrate violently.");
|
||||
}
|
||||
} else {
|
||||
printMsg("You watch.");
|
||||
printMsg("You vibrate impatiently.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,26 @@ int Thing::pushThought(Thought thought) {
|
|||
thoughts.push_back(thought);
|
||||
return thoughts.size();
|
||||
}
|
||||
int Thing::pushAbility(Ability *ability) {
|
||||
if (abilities.size() >= 10) return -1;
|
||||
LOG(LOG_INFO) << name << " has a new ability: " << ability->getName();
|
||||
abilities.push_back(ability);
|
||||
ability->setOwner(this);
|
||||
return abilities.size();
|
||||
}
|
||||
int Thing::unshiftAbility(Ability *ability) {
|
||||
if (abilities.size() >= 10) return -1;
|
||||
LOG(LOG_INFO) << name << " has a new ability: " << ability->getName();
|
||||
abilities.push_front(ability);
|
||||
ability->setOwner(this);
|
||||
return abilities.size();
|
||||
}
|
||||
Ability *Thing::getAbility(int number) {
|
||||
if (number+1 > abilities.size()) {
|
||||
return NULL;
|
||||
}
|
||||
return abilities.at(number);
|
||||
}
|
||||
/* ======== Velocity/Position ======== */
|
||||
void Thing::addVelocity(Vec3 vel) {
|
||||
velocity += vel;
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include "RenderObject.hpp"
|
||||
#include "Sprite.hpp"
|
||||
#include "Controller.hpp"
|
||||
#include "Ability.hpp"
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
//class Thought; // fwd declaration
|
||||
|
@ -23,7 +25,12 @@ class Thing {
|
|||
//
|
||||
int pushThought(Thought thought);
|
||||
//
|
||||
Ability *getAbility(int number);
|
||||
int pushAbility(Ability *ability);
|
||||
int unshiftAbility(Ability *ability);
|
||||
//
|
||||
void setController(Controller *controller_) { controller = controller_; };
|
||||
Controller* getController() { return controller; };
|
||||
void printMsg(std::string string);
|
||||
//
|
||||
enum Flags {
|
||||
|
@ -42,6 +49,7 @@ class Thing {
|
|||
protected:
|
||||
Controller *controller;
|
||||
std::string name;
|
||||
Vec3 direction; // normalized direction vector
|
||||
Vec3 velocity; // although this is a rug-like, velocity makes life easier
|
||||
Vec3 position;
|
||||
Vec2 scale;
|
||||
|
@ -52,6 +60,8 @@ class Thing {
|
|||
unsigned int thought_delay; // time required for current thought
|
||||
unsigned int thought_elapsed; // elapsed time spent on current thought
|
||||
//
|
||||
std::deque<Ability*> abilities; // our abilities, from 0 - 9
|
||||
//
|
||||
Sprite *sprite;
|
||||
};
|
||||
|
||||
|
|