From: drumsetmonkey Date: Sun, 24 Apr 2016 01:55:31 +0000 (-0400) Subject: Fixed some bugs X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=debb080a17eba2b2957e99ba7f1ce0fa0c4d2e4e;p=clyne%2Fgamedev.git Fixed some bugs --- debb080a17eba2b2957e99ba7f1ce0fa0c4d2e4e diff --cc Makefile index eb38b52,dd1267f..4370fb1 --- a/Makefile +++ b/Makefile @@@ -12,7 -12,7 +12,7 @@@ ifeq ($(TARGET_OS),win32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype endif - CXXFLAGS = -g -m$(TARGET_BITS) -std=c++1z -CXXFLAGS = -m$(TARGET_BITS) -std=c++17 ++CXXFLAGS = -g -m$(TARGET_BITS) -std=c++17 CXXINC = -Iinclude -Iinclude/freetype CXXWARN = -Wall -Wextra -Werror -pedantic-errors diff --cc include/ui.hpp index 3aaeb00,5ddf165..144a87e --- a/include/ui.hpp +++ b/include/ui.hpp @@@ -11,13 -11,14 +11,15 @@@ #include #include + #include + #include #include +#include FT_FREETYPE_H + #include #include -#include FT_FREETYPE_H #define SDL_KEY e.key.keysym.sym diff --cc include/world.hpp index 3625849,dcd047b..9a1d701 --- a/include/world.hpp +++ b/include/world.hpp @@@ -130,14 -82,11 +82,11 @@@ extern const float GRAVITY_CONSTANT class Village { public: std::string name; - vec2 start; - vec2 end; + vec2 start, end; bool in; - std::vector build; Village(const char *meme, World *w); - ~Village(void){} + ~Village(void) {} }; /** diff --cc main.cpp index 2aa1e28,3037c77..8e07818 --- a/main.cpp +++ b/main.cpp @@@ -60,12 -27,15 +27,9 @@@ World *currentWorld = NULL *currentWorldToLeft = NULL, *currentWorldToRight = NULL; - /** - * The player object. - */ - + // the player object Player *player; -/** - * TODO - */ - -extern Menu *currentMenu; - /** * The current number of ticks, used for logic operations and day/night cycles. */ diff --cc src/inventory.cpp index 224ee12,84f8871..c6b28d9 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@@ -472,11 -447,13 +462,13 @@@ void Inventory::draw(void) selected = true; } } - if((ui::mouse.x - offset.x) < mouseStart.x){ + if ((ui::mouse.x - offset.x) < mouseStart.x) { thing = (mouseStart.x - (ui::mouse.x - offset.x))/80; - if ((int)sel-(int)thing<0)highlight=0; - else highlight=sel-thing; - if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) { + if ((int)sel - (int)thing < 0) + highlight = 0; + else + highlight = sel - thing; + if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)){ sel = highlight; mouseSel=false; invHover=false; @@@ -484,17 -461,16 +476,15 @@@ } } } - std::cout << "Rays" << std::endl; - for(auto &r : iray) { - std::cout << "Setting angle" << std::endl; - angle=180-(angleB*a) - angleB/2.0f; - std::cout << "Currcourd" << std::endl; + + a = 0; + for (auto &r : iray) { + angle = 180 - (angleB * a) - angleB / 2.0f; - curCoord[a].x += float(range) * cos(angle*PI/180); curCoord[a].y += float(range) * sin(angle*PI/180); - std::cout << "Ray.end" << std::endl; r.end = curCoord[a]; - std::cout << "Draw" << std::endl; + // square drawing glColor4f(0.0f, 0.0f, 0.0f, a == highlight ? 0.5f : 0.1f); glBegin(GL_QUADS); glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2)); @@@ -526,14 -500,16 +514,15 @@@ } a++; } + + if (highlight < items.size()) { + ui::putStringCentered(player->loc.x + player->width / 2, + player->loc.y + range * 0.75f, + itemMap[items[highlight].id]->name.c_str() + ); + } } - - if(!items.empty() && items.size() > sel && items[sel].count) + if (!items.empty() && items.size() > sel && items[sel].count) itemDraw(player,items[sel].id); } diff --cc src/world.cpp index be8ba94,baf3080..5893bfb --- a/src/world.cpp +++ b/src/world.cpp @@@ -735,18 -555,18 +554,18 @@@ void World: singleDetect(Entity *e) { std::string killed; - unsigned int i,j; + unsigned int i; int l; - /* - * Kill any dead entities. - */ - + // kill dead entities if (e->alive && e->health <= 0) { + // die e->alive = false; e->health = 0; + + // delete the entity for (i = 0; i < entity.size(); i++) { - if (entity[i] == e){ + if (entity[i] == e) { switch (e->type) { case STRUCTURET: killed = "structure"; @@@ -1541,11 -1526,11 +1525,11 @@@ Arena::~Arena(void) deleteEntities(); } -World *Arena::exitArena(Player *p){ +World *Arena::exitArena(Player *p) { World *tmp; if (!mmob->alive && - p->loc.x + p->width / 2 > mob[0].loc.x && - p->loc.x + p->width / 2 < mob[0].loc.x + HLINE * 12) { + p->loc.x + p->width / 2 > mob[0]->loc.x && + p->loc.x + p->width / 2 < mob[0]->loc.x + HLINE * 12) { tmp = battleNest.front(); battleNest.erase(battleNest.begin());