diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 4 | ||||
-rw-r--r-- | src/entities.cpp | 23 | ||||
-rw-r--r-- | src/gameplay.cpp | 8 | ||||
-rw-r--r-- | src/ui.cpp | 12 | ||||
-rw-r--r-- | src/world.cpp | 34 |
5 files changed, 73 insertions, 8 deletions
diff --git a/src/Makefile b/src/Makefile index a243846..aacef57 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ -LIBS = -lGL -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype +LIBS = -lGL -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype -FLAGS = -m32 -std=c++11 -I../include -I../include/freetype2 +FLAGS = -std=c++11 -I../include -I../include/freetype2 OUT = `echo "" $$(ls -c $(wildcard *.cpp)) | sed s/.cpp/.o/g | sed 's/ / ..\/out\//g'` diff --git a/src/entities.cpp b/src/entities.cpp index b076684..a0005c3 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -6,6 +6,8 @@ extern unsigned int loops; extern World *currentWorld; +extern Player *player; + void Entity::spawn(float x, float y){ //spawns the entity you pass to it based off of coords and global entity settings loc.x = x; loc.y = y; @@ -89,6 +91,18 @@ Mob::Mob(int sub){ inv = new Inventory(NPC_INV_SIZE); } +Object::Object(int id):ID(id){ + type = OBJECTT; + alive = true; + near = false; + width = HLINE * 8; + height = HLINE * 8; + + maxHealth = health = 1; + tex = new Texturec(1, "assets/items/ITEM_SWORD.png"); +} + + void Entity::draw(void){ //draws the entities glPushMatrix(); if(type==NPCT){ @@ -161,6 +175,8 @@ void Entity::draw(void){ //draws the entities default: break; } + }else if(type == OBJECTT){ + tex->bind(0); }else{ tex->bind(0); } @@ -279,6 +295,11 @@ void NPC::interact(){ //have the npc's interact back to the player } } +void Object::interact(){ + this->alive = false; + player->inv->addItem((ITEM_ID)(ID), (char)1); +} + /* * This spawns the structures * @@ -359,4 +380,4 @@ void Mob::wander(int timeRun){ default: break; } -} +}
\ No newline at end of file diff --git a/src/gameplay.cpp b/src/gameplay.cpp index c170511..bfc2bdb 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -5,7 +5,6 @@ extern World *currentWorld; extern Player *player; - extern void mainLoop(void); int compTestQuest(NPC *speaker){ @@ -32,7 +31,6 @@ void initEverything(void){ /* * World creation: */ - World *test=new World(); World *playerSpawnHill=new World(); @@ -89,8 +87,10 @@ void initEverything(void){ * Spawn a mob. */ - currentWorld->addMob(MS_RABBIT,200,100); - currentWorld->addMob(MS_BIRD,-500,500); + test->addMob(MS_RABBIT,200,100); + test->addMob(MS_BIRD,-500,500); + + currentWorld->addObject(2, 500,200); /* * Link all the entities that were just created to the initial world, and setup a test AI function. @@ -108,6 +108,7 @@ namespace ui { case 'y': case 'p': case 'j':y-=fontSize/4;break; + case 'Q':y-=fontSize/5;break; default:break; } glBegin(GL_QUADS); @@ -217,6 +218,7 @@ namespace ui { } setFontSize(14); putText(((SCREEN_WIDTH/2)+offset.x)-125,(offset.y+SCREEN_HEIGHT/2)-fontSize,"Health: %u/%u",player->health>0?(unsigned)player->health:0, + (unsigned)player->maxHealth); if(player->alive){ glColor3ub(255,0,0); @@ -225,6 +227,16 @@ namespace ui { ((SCREEN_WIDTH/2+offset.x)-125)+((player->health/player->maxHealth)*100), (offset.y+SCREEN_HEIGHT/2)-32+12); } + + /* + * Lists all of the quests the player has + */ + putText(((SCREEN_WIDTH/2)+offset.x)-125,(offset.y+SCREEN_HEIGHT/2)-fontSize*4, "Current Quests:",NULL); + + for(auto &c : player->qh.current){ + putText(((SCREEN_WIDTH/2)+offset.x)-125,(offset.y+SCREEN_HEIGHT/2)-fontSize*5, "%s",c->title); + } + } void handleEvents(void){ static bool left=false,right=false; diff --git a/src/world.cpp b/src/world.cpp index 049e498..51f7579 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -286,7 +286,9 @@ LOOP2: /* * Draw the layer up until the grass portion, which is done later. */ - + /* + * TODO: CLYNE CHANGE THE NAME OF THIS + */ bool hey=false; glBegin(GL_QUADS); for(i=is;i<ie-GEN_INC;i++){ @@ -372,6 +374,13 @@ LOOP2: m->draw(); m->loc.y-=(yoff-DRAW_Y_OFFSET); } + for(auto &o : current->object){ + if(o->alive){ + o->loc.y+=(yoff-DRAW_Y_OFFSET); + o->draw(); + o->loc.y-=(yoff-DRAW_Y_OFFSET); + } + } /* * If we're drawing the closest/last world, handle and draw the player. @@ -549,6 +558,18 @@ void World::addStructure(_TYPE t,float x,float y,World *outside,World *inside){ entity.push_back(build.back()); } +/*template<class T> +void World::getEntityLocation(std::vector<T*>&vecBuf, unsigned int n){ + T bufVar = vecBuf.at(n); + unsigned int i = 0; + for(auto &e : entity){ + if(entity.at(i) == bufVar){ + entity.erase(entity.begin()+i); + } + i++; + } +}*/ + void World::addMob(int t,float x,float y){ mob.push_back(new Mob(t)); mob.back()->spawn(x,y); @@ -563,6 +584,17 @@ void World::addNPC(float x,float y){ entity.push_back(npc.back()); } +void World::addObject(int i, float x, float y){ + object.push_back(new Object(i)); + object.back()->spawn(x,y); + + entity.push_back(object.back()); +} + +/*void World::removeObject(Object i){ + object.delete(i); +}*/ + /* * The rest of these functions are explained well enough in world.h ;) */ |