]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Fixed some bugs
authordrumsetmonkey <abelleisle@roadrunner.com>
Sun, 24 Apr 2016 01:55:31 +0000 (21:55 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Sun, 24 Apr 2016 01:55:31 +0000 (21:55 -0400)
12 files changed:
1  2 
Makefile
include/common.hpp
include/entities.hpp
include/ui.hpp
include/ui_menu.hpp
include/world.hpp
main.cpp
src/entities.cpp
src/inventory.cpp
src/ui.cpp
src/world.cpp
xml/playerSpawnHill1.xml

diff --cc Makefile
index eb38b521db5cd5f588af35017b4bf24339a74496,dd1267f6aef05a5adb7d0b344fdcbf4f6c6c423f..4370fb1bdccfa4edb72f0ae69518ed2eaec82db2
+++ 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
  
Simple merge
Simple merge
diff --cc include/ui.hpp
index 3aaeb0016dc210cbf679c5c08898e370e2a4ddfd,5ddf165a9828282be18936e821c5c51b693cb197..144a87e3d1151b55917d8e6a8d884bfc2de77b47
  
  #include <config.hpp>
  #include <world.hpp>
  #include <ui_menu.hpp>
+ #include <ui_action.hpp>
  
  #include <ft2build.h>
 +#include FT_FREETYPE_H
 +
  #include <SDL2/SDL_opengl.h>
  #include <thread>
 -#include FT_FREETYPE_H
  
  #define SDL_KEY e.key.keysym.sym
  
Simple merge
index 36258497bbd2ad8c56cf7d5ca8f2918f8585a88e,dcd047b7a7cce7c4f55dc9b9275b2d43b6212ede..9a1d7010814d2715f4392f599ac230aecbd2126c
@@@ -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<Structures *> build;
  
        Village(const char *meme, World *w);
 -      ~Village(void){}
 +      ~Village(void) {}
  };
  
  /**
diff --cc main.cpp
index 2aa1e28491c6507f7779bb22bad5504b75a152fb,3037c77a045e5f8077f49a09da3f1f662b04bf77..8e078180aacdb305c6337d947172e10579785a18
+++ 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.
   */
Simple merge
index 224ee121cc75f2143538859a88bbc4eedb04d637,84f88711408dddfa5ea80675d46c0f193bacbd36..c6b28d93bacf4a588d9e17d548d6927c6a6e6ef1
@@@ -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;
                                }
                        }
                }
-               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));
                        }
                        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/ui.cpp
Simple merge
diff --cc src/world.cpp
index be8ba944202b3e78f6cab3728f22f06297edbb17,baf3080c58e57cda15533aae1809eed29bc83b40..5893bfb7e42f79b217584d4b18c6be68cb842484
@@@ -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());
  
Simple merge