]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Fixed extra entity, added mouse square, added quests class
authordrumsetmonkey <abelleisle@roadrunner.com>
Tue, 29 Sep 2015 12:08:08 +0000 (08:08 -0400)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Tue, 29 Sep 2015 12:08:08 +0000 (08:08 -0400)
include/common.h
src/entities.cpp
src/main.cpp
src/ui.cpp

index 1210adbaf42fbf48b9c30c313b25f930b81571c7..00c1a77a3631ba1d3db761520d9e02ebf6770597 100644 (file)
@@ -19,7 +19,7 @@ enum _TYPE {STRUCTURET = -1, PLAYERT = 0, NPCT = 1}; //these are the main types
 #define SCREEN_HEIGHT 720
 //#define FULLSCREEN
 
-#define HLINE 3                                                                                //base unit of the world
+#define HLINE 3                                                                //base unit of the world
 
 #define initRand(s) srand(s)
 #define getRand()      rand()
index a7737b3ebd33fc2f8af18245b96d3e8434ee2413..1058b1b34d0a988c7454d6c9f589c99474bb5270 100644 (file)
@@ -84,12 +84,14 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure
                height = 16 * HLINE;
 
                int tempN = (getRand() % 5 + 1); //amount of villagers that will spawn
+               //int tempN=200;
                for(int i=0;i<tempN;i++){
                        entity.push_back(new NPC()); //create a new entity of NPC type
                        npc.push_back(NPC()); //create new NPC
                        entity[entity.size()] = &npc[npc.size()-1]; //set the new entity to have the same traits as an NPC
                        entity[entity.size()-1]->spawn(loc.x + (float)(i - 5),100); //sets the position of the villager around the village
                }
+               entity.pop_back();      
                return entity.size();
        }
 }
index 2dc511281d3e47d25c2b1895a20991c080293b13..5c4fb77bd04155f8aa3cef218bce3c2605585c1b 100644 (file)
@@ -128,7 +128,7 @@ int main(int argc, char *argv[]){
                }
 
                player->loc.y+=player->vel.y*deltaTime;
-               player->loc.x+=player->vel.x*deltaTime;
+               player->loc.x+=(player->vel.x*player->speed)*deltaTime;
                render();
        }
        
@@ -188,6 +188,11 @@ void render(){
        /**************************
        ****  CLOSE THE LOOP   ****
        **************************/
+       int mx = ui::mouse.x, my=ui::mouse.y;
+       my = 720 - my;
+       mx -= (SCREEN_WIDTH/2);
+       glRectf(mx + player->loc.x, my, mx + player->loc.x + HLINE * 1, my + HLINE * 1);
+
 
        glPopMatrix();                                                                  //take the matrix(s) off the stack to pass them to the renderer
        SDL_GL_SwapWindow(window);                                              //give the stack to SDL to render it
@@ -199,7 +204,6 @@ void logic(){
        for(int i=0;i<=entity.size();i++){
                if(entity[i]->alive&&entity[i]->type == NPCT){
                        entity[i]->wander((rand()%120 + 30), &entity[i]->vel);
-                       //std::cout<<"works"<<i<<std::endl;
                }
        }
 }
index ababe3efb37a8b775381a08fcf847fa142b40d59..ff484212dd94ea9a7c5c46be00b793b27f132ac2 100644 (file)
@@ -165,6 +165,7 @@ namespace ui {
                                if(SDL_KEY==SDLK_i)currentWorld=currentWorld->goWorldBack(player);      // Go back a layer if possible
                                if(SDL_KEY==SDLK_k)currentWorld=currentWorld->goWorldFront(player);     // Go forward a layer if possible
                                if(SDL_KEY==SDLK_F3)debug^=true;
+                               if(SDL_KEY==SDLK_LSHIFT)player->speed = 3;
                                
                                // TEMPORARY UNTIL MOUSE
                                if(SDL_KEY==SDLK_t){
@@ -181,6 +182,8 @@ namespace ui {
                        case SDL_KEYUP:
                                if(SDL_KEY==SDLK_a)player->vel.x=0;     // Stop the player if movement keys are released
                                if(SDL_KEY==SDLK_d)player->vel.x=0;
+                               if(SDL_KEY==SDLK_LSHIFT)player->speed = 1;
+
                                break;
                        default:
                                break;