diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2015-12-10 08:13:15 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2015-12-10 08:13:15 -0500 |
commit | b28023525c6dcf2360c8d03b405d46af4e0e1c6d (patch) | |
tree | ec35eed3f48d089da8ee4ec5ebb14c9db328ce6c | |
parent | ce169efec21d44b6c7b3133280d9088ba1c108a5 (diff) |
Doing shit
-rw-r--r-- | include/common.h | 8 | ||||
-rw-r--r-- | include/entities.h | 19 | ||||
-rw-r--r-- | include/world.h | 2 | ||||
-rw-r--r-- | main.cpp | 4 | ||||
-rw-r--r-- | src/entities.cpp | 3 | ||||
-rw-r--r-- | src/inventory.cpp | 36 | ||||
-rw-r--r-- | src/world.cpp | 7 |
7 files changed, 62 insertions, 17 deletions
diff --git a/include/common.h b/include/common.h index f8bd935..8050852 100644 --- a/include/common.h +++ b/include/common.h @@ -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. diff --git a/include/entities.h b/include/entities.h index 64a251a..e0c0887 100644 --- a/include/entities.h +++ b/include/entities.h @@ -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; diff --git a/include/world.h b/include/world.h index ccf93a8..5a16277 100644 --- a/include/world.h +++ b/include/world.h @@ -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); @@ -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. diff --git a/src/entities.cpp b/src/entities.cpp index fc2c316..1732fb6 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -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 diff --git a/src/inventory.cpp b/src/inventory.cpp index 8d8f958..585af47 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -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; diff --git a/src/world.cpp b/src/world.cpp index 9674b64..fd20904 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -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); }*/ |