]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Doing shit
authordrumsetmonkey <abelleisle@roadrunner.com>
Thu, 10 Dec 2015 13:13:15 +0000 (08:13 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Thu, 10 Dec 2015 13:13:15 +0000 (08:13 -0500)
include/common.h
include/entities.h
include/world.h
main.cpp
src/entities.cpp
src/inventory.cpp
src/world.cpp

index f8bd93554f3cb781f3d0bb3fd569ab059428b5b8..80508524f13a343bf0da6b49193ba28953e85c5d 100644 (file)
@@ -54,11 +54,17 @@ typedef struct {
        vec2 end;
 } Ray;
 
+typedef struct{
+       float red;
+       float green;
+       float blue;
+} Color;
+
 /**
  * Define the game's name (displayed in the window title).
  */
 
-#define GAME_NAME              "Independent Study v.0.4 alpha"
+#define GAME_NAME              "Independent Study v.0.5 alpha - NOW WITH SOUND!"
 
 /**
  * The desired width of the game window.
index 64a251ae3f1ed276ef118bf99b2274d140d8aa75..e0c08873cfd12dbfef0dc87303f94750d0aafe3c 100644 (file)
@@ -34,6 +34,25 @@ enum MOB_SUB {
        MS_TRIGGER
 };
 
+struct Particles{
+       vec2 loc;
+       float width;
+       float height;
+       Color color;
+       Particles(float x, float y, float w, float h, Color c){
+               loc.x = (x);
+               loc.y = (y);
+               width = (w);
+               height = (h);
+               color.red = (c.red);
+               color.green = (c.green);
+               color.blue = (c.blue);
+       }
+       void draw(){
+               std::cout << "Drawing Particles\n";
+       }
+};
+
 class Entity{
 public:
        Inventory *inv;
index ccf93a840baabc64ebb57794993fb7b511b926b7..5a1627738b54d328bb1b4f1e5c938de8112ae922 100644 (file)
@@ -159,12 +159,14 @@ public:
        std::vector<Mob                 *>      mob;
        std::vector<Entity              *>      entity;
        std::vector<Object              *>      object;
+       std::vector<Particles   *>      particles;
        
        void addStructure(_TYPE t,float x,float y,World *outside,World *inside);
        void addMob(int t,float x,float y);
        void addMob(int t,float x,float y,void (*hey)(Mob *));
        void addNPC(float x,float y);
        void addObject(ITEM_ID, bool, const char *, float, float);
+       void addParticle(float x, float y, float w, float h, Color color);
        
        void update(Player *p,unsigned int delta);
        
index b28a8da31c3475536fe2a1b08b2d2d986142371a..931f6882b3dc72246f0e447e7024cf93b256b442 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -515,7 +515,6 @@ void mainLoop(void){
                debugDiv=0;
                
                fps=1000/deltaTime;
-               
        }else if(!(debugDiv%10)){
                debugY = player->loc.y;
        }
@@ -841,7 +840,8 @@ void logic(){
                        if(n->canMove) n->wander((rand() % 120 + 30));
 
                        if(player->inv->usingi && player->inv->detectCollision(vec2{n->loc.x, n->loc.y},vec2{n->loc.x+n->width,n->loc.y+n->height})){
-                               n->alive=false;
+                               n->health -= 25;
+                               currentWorld->addParticle(n->loc.x, n->loc.y, HLINE*3, HLINE*3, {255,0,0});
                        }
                        /*
                         *      Don't bother handling the NPC if another has already been handled.
index fc2c316cae96eaf0e90e91deff9a45a40fb20719..1732fb694d4903b7f0a66bfe35e3da936ef0c667 100644 (file)
@@ -319,7 +319,8 @@ const char *randomDialog[10] = {
        "Did you know this game has over 4000 lines of code? I didn\'t. I didn't even know I was in a game until now...",
        "HELP MY CAPS LOCK IS STUCK",
        "You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross.",
-       "I want to have the wallpaper in our house changed. It doesn\'t really fit the environment."
+       "I want to have the wallpaper in our house changed. It doesn\'t really fit the environment.",
+       "Frig."
 };
 
 void NPC::interact(){ //have the npc's interact back to the player
index 8d8f958e0dd45ea225bad9cbbce11b9d4a8c7434..585af471e91099d989e2a34c9ab69b16b9af3e57 100644 (file)
@@ -7,7 +7,7 @@
 extern Player *player;
 extern GLuint invUI;
 static float hangle = 0.0f;
-static bool up = true;
+static bool swing = false;
 static float xc,yc;
 static vec2 itemLoc;
 Mix_Chunk* swordSwing;
@@ -278,13 +278,13 @@ void itemDraw(Player *p,ITEM_ID id,ITEM_TYPE type){
                        if(hangle < 15){
                                hangle=15.0f;
                                p->inv->usingi = false;
-                               up = false;
+                               //swing=false;
                        }
                }else{
                        if(hangle > -15){
                                hangle=-15.0f;
                                p->inv->usingi = false;
-                               up = false;
+                               //swing=false;
                        }
                }
                break;
@@ -310,19 +310,31 @@ void itemDraw(Player *p,ITEM_ID id,ITEM_TYPE type){
 }
 
 int Inventory::useItem(void){
+       static bool up = false;
        ITEM_TYPE type = item[inv[sel].id].type;
        if(!invHover){
                switch(type){
                case SWORD:
-               if(!player->left){
-                       if(hangle==-15){up=true;Mix_PlayChannel(2,swordSwing,0);}
-                       if(up)hangle-=15;
-                       if(hangle<=-90)hangle=-14;
-               }else{
-                       if(hangle==15){up=true;Mix_PlayChannel(2,swordSwing,0);}
-                       if(up)hangle+=15;
-                       if(hangle>=90)hangle=14;
-               }
+                       if(swing){
+                               if(!player->left){
+                                       /*if(hangle==-15){up=true;Mix_PlayChannel(2,swordSwing,0);}
+                                       if(up)hangle-=.75*deltaTime;
+                                       if(hangle<=-90)hangle=-14;*/
+                               }else{
+                                       if(hangle<90&&!up)hangle+=.75*deltaTime;
+                                       if(hangle>=90&&!up)up=true;
+                                       if(up)hangle-=.75*deltaTime;
+                                       if(up&&hangle<=15){
+                                               up=false;
+                                               swing=false;
+                                               hangle=15;
+                                               return 0;
+                                       }
+                               }
+                       }else if(!swing){
+                               swing=true;
+                               Mix_PlayChannel(2,swordSwing,0);
+                       }
                        break;
                default:
                        break;
index 9674b64892164de3970d72ed010a7da230407e05..fd20904e14ae5b3ddf1e345d42d2d92ea1fe1b64 100644 (file)
@@ -600,7 +600,8 @@ LOOP2:
                        o->draw();
                        o->loc.y-=(yoff-DRAW_Y_OFFSET);
                }
-       }
+       }for(auto &o : particles){o->draw();}
+
        
        /*
         *      If we're drawing the closest/last world, handle and draw the player.
@@ -876,6 +877,10 @@ void World::addObject(ITEM_ID i, bool q, const char *p, float x, float y){
        entity.push_back(object.back());
 }
 
+void World::addParticle(float x, float y, float w, float h, Color color){
+       particles.push_back(new Particles(x,y,w,h,color));
+}
+
 /*void World::removeObject(Object i){
        object.delete[](i);
 }*/