From 0415b7f0a9305cd43e8fd8c77a8bafd3b8016dd0 Mon Sep 17 00:00:00 2001 From: drumsetmonkey <abelleisle@roadrunner.com> Date: Mon, 30 Nov 2015 08:47:24 -0500 Subject: Working on animations --- config/items.h | 10 +++++----- include/common.h | 2 ++ include/inventory.h | 11 +++++++++-- src/Texture.cpp | 1 - src/entities.cpp | 4 ++-- src/inventory.cpp | 44 +++++++++++++++++++++++--------------------- 6 files changed, 41 insertions(+), 31 deletions(-) diff --git a/config/items.h b/config/items.h index 62db071..fc0ca96 100644 --- a/config/items.h +++ b/config/items.h @@ -1,6 +1,6 @@ ID DEBUG_ITEM - NAME "Debug\0" + NAME "Debug" TYPE TOOL WIDTH 1 HEIGHT 1 @@ -9,7 +9,7 @@ ID DEBUG_ITEM ENI ID TEST_ITEM - NAME "Dank MayMay\0" + NAME "Dank MayMay" TYPE TOOL WIDTH HLINE HEIGHT HLINE @@ -18,7 +18,7 @@ ID TEST_ITEM ENI ID PLAYER_BAG - NAME "Your Bag\0" + NAME "Your Bag" TYPE EQUIP WIDTH HLINE*5 HEIGHT HLINE*5 @@ -27,7 +27,7 @@ ID PLAYER_BAG ENI ID FLASHLIGHT - NAME "Flashlight\0" + NAME "Flashlight" TYPE TOOL WIDTH HLINE*2 HEIGHT HLINE*4 @@ -36,7 +36,7 @@ ID FLASHLIGHT ENI ID SWORD_WOOD - NAME "Wood Sword\0" + NAME "Wood Sword" TYPE SWORD WIDTH HLINE*4 HEIGHT HLINE*10 diff --git a/include/common.h b/include/common.h index 525a4cd..869c811 100644 --- a/include/common.h +++ b/include/common.h @@ -123,6 +123,8 @@ extern float handAngle; * */ + extern unsigned int loops; + //GLuint loadTexture(const char *fileName); /* diff --git a/include/inventory.h b/include/inventory.h index 2793ad7..3b4c260 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -3,6 +3,7 @@ #include <common.h> #include <string.h> +#include <boost/range/adaptor/reversed.hpp> #define DEBUG @@ -49,24 +50,30 @@ public: int maxStackSize; char* textureLoc; Texturec *tex; + GLuint text; int count; Item(ITEM_ID i, char* n, ITEM_TYPE t, float w, float h, int m, char* tl): id(i), type(t), width(w), height(h), maxStackSize(m){ count = 0; - name = (char*)calloc(strlen(n ),sizeof(char)); - textureLoc = (char*)calloc(strlen(tl),sizeof(char)); + name = (char*)calloc(strlen(n )+1,sizeof(char)); + textureLoc = (char*)calloc(strlen(tl)+1,sizeof(char)); strcpy(name,n); strcpy(textureLoc,tl); tex= new Texturec(1,textureLoc); + text = Texture::loadTexture(textureLoc); } GLuint rtex(){ return tex->image[0]; } }; +static Item item[5]= { + #include "../config/items.h" +}; + struct item_t{ int count; ITEM_ID id; diff --git a/src/Texture.cpp b/src/Texture.cpp index 82baa71..586f5fd 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -13,7 +13,6 @@ namespace Texture{ GLuint loadTexture(const char *fileName){ SDL_Surface *image; GLuint object = 0; - unsigned int i; for(unsigned int i=0;i<LoadedTextureCounter;i++){ if(!strcmp(LoadedTexture[i]->name,fileName)){ diff --git a/src/entities.cpp b/src/entities.cpp index 97b4d35..c2c560a 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -108,7 +108,7 @@ Object::Object(int id):identifier(id){ height = HLINE * 8; maxHealth = health = 1; - //tex = new Texturec(1, item[id].textureLoc); + tex = new Texturec(1, item[id].textureLoc); questObject = false; pickupDialog="\0"; @@ -122,7 +122,7 @@ Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupD height = HLINE * 8; maxHealth = health = 1; - //tex = new Texturec(1, item[id].textureLoc); + tex = new Texturec(1, item[id].textureLoc); } diff --git a/src/inventory.cpp b/src/inventory.cpp index 45d5bce..ed22fb6 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -7,10 +7,6 @@ extern Player *player; extern GLuint invUI; -static Item item[5]= { - #include "../config/items.h" -}; - void itemDraw(Player *p,ITEM_ID id); Inventory::Inventory(unsigned int s){ @@ -63,6 +59,7 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){ void Inventory::draw(void){ ui::putText(offset.x-SCREEN_WIDTH/2,480,"%d",sel); unsigned int i=0; + static unsigned int lop = 0; float y,xoff; @@ -81,7 +78,7 @@ void Inventory::draw(void){ //dfp[a] = 0; a++; }a=0; - if(invOpening){ + if(invOpening && lop % 1 == 0){ end = 0; for(auto &d : dfp){ if(a != 0){ @@ -94,18 +91,12 @@ void Inventory::draw(void){ a++; }a=0; if(end < numSlot)invOpen=true; - }else if(!invOpening){ - for(auto &d : dfp){ + }else if(!invOpening && lop % 1 == 0){ + for(auto &d : boost::adaptors::reverse(dfp)){ if(d > 0){ - if(a != 0){ - //d-=25; - if(dfp[a-1]+25<d || dfp[a-1]<=0)d-=25; - }else{ - d-=25; - } + d-=25; }else end++; - a++; - }a=0; + } if(end >= numSlot)invOpen=false; } if(invOpen){ @@ -115,14 +106,24 @@ void Inventory::draw(void){ curCoord[a].y += float((dfp[a]) * sin(angle*PI/180)); r.end = curCoord[a]; - item[inv[i].id].tex->bind(0); - glColor4f(1.0f, 1.0f, 1.0f, (float)dfp[a]/(float)range); + glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)); glBegin(GL_QUADS); - glTexCoord2i(0,1);glVertex2i(r.end.x, r.end.y); - glTexCoord2i(1,1);glVertex2i(r.end.x+45, r.end.y); - glTexCoord2i(1,0);glVertex2i(r.end.x+45, r.end.y+45); - glTexCoord2i(0,0);glVertex2i(r.end.x, r.end.y+45); + glVertex2i(r.end.x, r.end.y); + glVertex2i(r.end.x+45, r.end.y); + glVertex2i(r.end.x+45, r.end.y+45); + glVertex2i(r.end.x, r.end.y+45); glEnd(); + + if(inv[a].count > 0){ + glBindTexture(GL_TEXTURE_2D, item[inv[a].id].text); + glColor4f(1.0f, 1.0f, 1.0f, (float)dfp[a]/(float)range); + glBegin(GL_QUADS); + glTexCoord2i(0,1);glVertex2i(r.end.x, r.end.y); + glTexCoord2i(1,1);glVertex2i(r.end.x+45, r.end.y); + glTexCoord2i(1,0);glVertex2i(r.end.x+45, r.end.y+45); + glTexCoord2i(0,0);glVertex2i(r.end.x, r.end.y+45); + glEnd(); + } a++; } } @@ -159,6 +160,7 @@ void Inventory::draw(void){ } }*/ if(inv[sel].count)itemDraw(player,inv[sel].id); + lop++; } static vec2 item_coord = {0,0}; -- cgit v1.2.3 From 80bc1b24bcf6862a7fbd3223a3d6988ce4e389e0 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan <tullivan99@gmail.com> Date: Tue, 1 Dec 2015 07:29:25 -0500 Subject: memory fixes --- Changelog | 3 +++ include/entities.h | 78 +++++++++++++++++++++++++++++++++-------------------- include/inventory.h | 3 +-- include/world.h | 1 + src/Quest.cpp | 11 +++----- src/entities.cpp | 69 ++++++++++++++++++++++++----------------------- src/gameplay.cpp | 11 +++++--- src/inventory.cpp | 7 +++-- src/world.cpp | 38 ++++++++++++++++++++++---- 9 files changed, 137 insertions(+), 84 deletions(-) diff --git a/Changelog b/Changelog index c9c94d8..c09d63a 100644 --- a/Changelog +++ b/Changelog @@ -345,3 +345,6 @@ - Converted all m/calloc/free calls to new/delete - fixed hardcoded string issues - improved inventory animation + - began writing songs for game soundtrack + + ~ About 4280 lines of code + documentation written ( +7ish pages of story on gdoc) diff --git a/include/entities.h b/include/entities.h index b9881ea..0bdadb7 100644 --- a/include/entities.h +++ b/include/entities.h @@ -38,56 +38,72 @@ class Entity{ public: Inventory *inv; - float width; //width and height of the player + /* + * Movement variables + */ + + vec2 loc; + vec2 vel; + + float width; float height; - float speed; //speed of the play + + float speed; // A speed factor for X movement + + /* + * Movement flags + */ + + bool near; // Causes name to display + bool canMove; // Enables movement + bool right,left; // Direction faced by Entity + bool alive; + unsigned char ground; // Shows how the Entity is grounded (if it is) + + /* + * Health variables + */ float health; float maxHealth; - int subtype; - _TYPE type; - //example: - //type 1(NPC) - // |(subtype) - // |-> 0 Base NPC - // |-> 1 Merchant + /* + * Identification variables + */ - vec2 loc; //location and velocity of the entity - vec2 vel; - - bool near; - bool right,left, canMove; //movement variables - bool alive; //the flag for whether or not the entity is alive - unsigned char ground; //variable for testing what ground the entity is on to apply certain traits + _TYPE type; + int subtype; - char* name; - GENDER gender; - //GLuint texture[3]; //TODO: ADD TEXTURES - Texturec* tex; + char *name; + GENDER gender; + + Texturec *tex; - void spawn(float, float); void draw(void); + void spawn(float, float); + + int ticksToUse; // Used by wander() + virtual void wander(int){} - void getName(); virtual void interact(){} - int ticksToUse; //The variable for deciding how long an entity should do a certain task -private: }; class Player : public Entity { public: QuestHandler qh; + bool light = false; + Player(); void interact(); - bool light = false; }; class NPC : public Entity{ public: std::vector<int (*)(NPC *)>aiFunc; + NPC(); + void addAIFunc(int (*func)(NPC *),bool preload); void interact(); void wander(int); @@ -97,6 +113,7 @@ class Structures : public Entity{ public: void *inWorld; void *inside; + Structures(); unsigned int spawn(_TYPE, float, float); }; @@ -105,22 +122,25 @@ class Mob : public Entity{ public: double init_y; void (*hey)(); + Mob(int); Mob(int,unsigned int); void wander(int); }; class Object : public Entity{ +private: + int identifier; public: + char *pickupDialog; + bool questObject = false; + Object(ITEM_ID id, bool qo, const char *pd); + void interact(void); - bool questObject = false; - char *pickupDialog; std::thread runInteract() { return std::thread([=] { interact(); }); } -private: - int identifier; }; #endif // ENTITIES_H diff --git a/include/inventory.h b/include/inventory.h index a9a4bcb..611a6d7 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -67,14 +67,13 @@ private: unsigned int size; // Size of 'item' array item_t *inv; int os = 0; - //struct item_t *item; // An array of the items contained in this inventory. public: unsigned int sel; bool invOpen = false; bool invOpening = false; Inventory(unsigned int s); // Creates an inventory of size 's' - ~Inventory(void); // Free's 'item' + ~Inventory(void); // Free's allocated memory int addItem(ITEM_ID id,unsigned char count); // Add 'count' items with an id of 'id' to the inventory int takeItem(ITEM_ID id,unsigned char count); // Take 'count' items with an id of 'id' from the inventory diff --git a/include/world.h b/include/world.h index a2414e6..4e4c28d 100644 --- a/include/world.h +++ b/include/world.h @@ -205,6 +205,7 @@ private: World *exit; public: Arena(World *leave,Player *p); + ~Arena(void); World *exitArena(Player *p); }; diff --git a/src/Quest.cpp b/src/Quest.cpp index bfa8966..4e8522d 100644 --- a/src/Quest.cpp +++ b/src/Quest.cpp @@ -7,25 +7,22 @@ #define END }), const Quest QuestList[TOTAL_QUESTS]={ -// Quest("Test","A test quest",(struct item_t){1,TEST_ITEM}), - // Get quest list #include "../config/quest_list.txt" - }; Quest::Quest(const char *t,const char *d,struct item_t r){ - title = new char[strlen(t)+1]; //(char *)calloc(safe_strlen(t),sizeof(char)); - desc = new char[strlen(d)+1]; //(char *)calloc(safe_strlen(d),sizeof(char)); + title = new char[strlen(t)+1]; + desc = new char[strlen(d)+1]; strcpy(title,t); strcpy(desc,d); memcpy(&reward,&r,sizeof(struct item_t)); } Quest::~Quest(){ - delete[] title; //free(title); - delete[] desc; //free(desc); + delete[] title; + delete[] desc; memset(&reward,0,sizeof(struct item_t)); } diff --git a/src/entities.cpp b/src/entities.cpp index 4e582c9..f9723cf 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -10,6 +10,39 @@ extern Player *player; extern const char *itemName; +void getRandomName(Entity *e){ + int tempNum,max=0; + char buf,*bufs; + + rewind(names); + + bufs = new char[16]; //(char *)malloc(16); + + for(;!feof(names);max++){ + fgets(bufs,16,(FILE*)names); + } + + tempNum = rand() % max; + rewind(names); + + for(int i=0;i<tempNum;i++){ + fgets(bufs,16,(FILE*)names); + } + + switch(fgetc(names)){ + case 'm': e->gender = MALE; break; + case 'f': e->gender = FEMALE;break; + default : break; + } + + if((fgets(bufs,16,(FILE*)names)) != NULL){ + bufs[strlen(bufs)-1] = '\0'; + strcpy(e->name,bufs); + } + + delete[] bufs; +} + void Entity::spawn(float x, float y){ //spawns the entity you pass to it based off of coords and global entity settings loc.x = x; loc.y = y; @@ -33,8 +66,8 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o } } - name = new char[16]; //(char*)malloc(16); - getName(); + name = new char[16]; + getRandomName(this); } Player::Player(){ //sets all of the player specific traits on object creation @@ -208,38 +241,6 @@ NOPE: } } -void Entity::getName(){ - rewind(names); - char buf,*bufs = new char[16]; //(char *)malloc(16); - int tempNum,max = 0; - for(;!feof(names);max++){ - fgets(bufs,16,(FILE*)names); - } - tempNum = rand()%max; - rewind(names); - for(int i=0;i<tempNum;i++){ - fgets(bufs,16,(FILE*)names); - } - switch(fgetc(names)){ - case 'm': - gender = MALE; - //std::puts("Male"); - break; - case 'f': - gender = FEMALE; - //std::puts("Female"); - break; - default: - break; - } - if((fgets(bufs,16,(FILE*)names)) != NULL){ - //std::puts(bufs); - bufs[strlen(bufs)-1] = '\0'; - strcpy(name,bufs); - } - delete[] bufs; //free(bufs); -} - void Player::interact(){ //the function that will cause the player to search for things to interact with } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 2fd7424..eadd668 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -91,6 +91,9 @@ void CUTSCENEEE(void){ float playerSpawnHillFunc(float x){ return (float)(pow(2,(-x+200)/5) + 80); } + +void destroyEverything(void); + void initEverything(void){ unsigned int i; @@ -153,9 +156,11 @@ void initEverything(void){ currentWorld->addObject(SWORD_WOOD, 650,200); currentWorld->addObject(FLASHLIGHT, true, "This looks important, do you want to pick it up?",700,200); */ - /* - * Link all the entities that were just created to the initial world, and setup a test AI function. - */ currentWorld->npc[0]->addAIFunc(giveTestQuest,false); + atexit(destroyEverything); +} + +void destroyEverything(void){ + //delete currentWorld; } diff --git a/src/inventory.cpp b/src/inventory.cpp index cd01c11..32929df 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -25,8 +25,8 @@ Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const maxStackSize = m; count = 0; - name = new char[strlen(n)+1]; //(char*)calloc(strlen(n ),sizeof(char)); - textureLoc = new char[strlen(tl)+1]; //(char*)calloc(strlen(tl),sizeof(char)); + name = new char[strlen(n)+1]; + textureLoc = new char[strlen(tl)+1]; strcpy(name,n); strcpy(textureLoc,tl); @@ -37,14 +37,13 @@ Item::Item(ITEM_ID i, const char *n, ITEM_TYPE t, float w, float h, int m, const Inventory::Inventory(unsigned int s){ sel=0; size=s; - inv = new struct item_t[size]; //(struct item_t *)calloc(size,sizeof(struct item_t)); + inv = new struct item_t[size]; memset(inv,0,size*sizeof(struct item_t)); tossd=false; } Inventory::~Inventory(void){ delete[] inv; - //free(item); } void Inventory::setSelection(unsigned int s){ diff --git a/src/world.cpp b/src/world.cpp index c977c7f..36f0f69 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -71,6 +71,18 @@ World::World(void){ memset(star,0,100*sizeof(vec2)); } +World::~World(void){ + delete bgTex; + delete[] star; + delete[] line; + + delete &mob; + delete &npc; + delete &build; + delete &object; + delete &entity; +} + void World::generate(unsigned int width){ // Generates the world and sets all variables contained in the World class. unsigned int i; float inc; @@ -196,10 +208,6 @@ void World::generateFunc(unsigned int width,float(*func)(float)){ } } -World::~World(void){ - delete[] line; -} - void World::update(Player *p,unsigned int delta){ p->loc.y+= p->vel.y *delta; p->loc.x+=(p->vel.x*p->speed)*delta; @@ -836,7 +844,15 @@ IndoorWorld::IndoorWorld(void){ } IndoorWorld::~IndoorWorld(void){ - delete[] line; //free(line); + delete bgTex; + delete[] star; + delete[] line; + + delete &mob; + delete &npc; + delete &build; + delete &object; + delete &entity; } void IndoorWorld::generate(unsigned int width){ // Generates a flat area of width 'width' @@ -897,6 +913,18 @@ Arena::Arena(World *leave,Player *p){ pxy = p->loc; } +Arena::~Arena(void){ + delete bgTex; + delete[] star; + delete[] line; + + delete &mob; + delete &npc; + delete &build; + delete &object; + delete &entity; +} + World *Arena::exitArena(Player *p){ npc[0]->loc.x = door.x; npc[0]->loc.y = door.y; -- cgit v1.2.3 From e02aaafad3ecef8752b538a2421c5e36fe4809c2 Mon Sep 17 00:00:00 2001 From: drumsetmonkey <abelleisle@roadrunner.com> Date: Tue, 1 Dec 2015 08:20:31 -0500 Subject: Fixed gameloop timestep and updated animations --- include/common.h | 4 ++-- main.cpp | 16 +--------------- src/Texture.cpp | 2 +- src/inventory.cpp | 12 ++++++------ src/world.cpp | 2 +- 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/include/common.h b/include/common.h index 50ba316..52daf4b 100644 --- a/include/common.h +++ b/include/common.h @@ -61,8 +61,8 @@ typedef struct { #define GAME_NAME "Independent Study v.0.4 alpha" -#define SCREEN_WIDTH 800 -#define SCREEN_HEIGHT 600 +#define SCREEN_WIDTH 1280 +#define SCREEN_HEIGHT 720 //#define FULLSCREEN diff --git a/main.cpp b/main.cpp index 5ac85ba..26c44f8 100644 --- a/main.cpp +++ b/main.cpp @@ -483,7 +483,6 @@ void mainLoop(void){ currentTime=millis(); prevPrevTime=currentTime; } - /* * Update timing values. This is crucial to calling logic and updating the window (basically * the entire game). @@ -496,8 +495,7 @@ void mainLoop(void){ /* * Run the logic handler if MSEC_PER_TICK milliseconds have passed. */ - - if(prevPrevTime + MSEC_PER_TICK >= currentTime){ + if(prevPrevTime + MSEC_PER_TICK <= currentTime){ logic(); prevPrevTime = currentTime; } @@ -511,7 +509,6 @@ void mainLoop(void){ /* * Update debug variables if necessary */ - if(++debugDiv==20){ debugDiv=0; @@ -522,7 +519,6 @@ void mainLoop(void){ } render(); // Call the render loop - } extern bool fadeEnable; @@ -773,7 +769,6 @@ void render(){ /* * Here we draw a black overlay if it's been requested. */ - if(fadeIntensity){ glColor4ub(0,0,0,fadeIntensity); glRectf(offset.x-SCREEN_WIDTH /2, @@ -784,7 +779,6 @@ void render(){ ui::importantText("The screen is black."); } }else if(ui::fontSize != 16) ui::setFontSize(16); - /************************** **** END RENDERING **** **************************/ @@ -805,7 +799,6 @@ void render(){ } void logic(){ - /* * NPCSelected is used to insure that only one NPC is made interactable with the mouse * if, for example, multiple entities are occupying one space. @@ -816,14 +809,12 @@ void logic(){ /* * Handle user input (keyboard & mouse). */ - ui::handleEvents(); /* * Run the world's detect function. This handles the physics of the player and any entities * that exist in this world. */ - currentWorld->detect(player); if(player->loc.y<.02)gameRunning=false; @@ -833,7 +824,6 @@ void logic(){ * click detection is done as well for NPC/player interaction. * */ - if((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) && !ui::dialogBoxExists)player->inv->useItem(); for(auto &n : currentWorld->npc){ @@ -907,7 +897,6 @@ void logic(){ }else n->near=false; } } - for(auto &m : currentWorld->mob){ if(m->alive){ @@ -929,7 +918,6 @@ void logic(){ } } } - unsigned int i = 0; for(auto &o : currentWorld->object){ if(o->alive){ @@ -960,7 +948,6 @@ void logic(){ /* * Switch between day and night (SUNNY and DARK) if necessary. */ - if(!(tickCount%DAY_CYCLE)||!tickCount){ if(weather==SUNNY){ weather=DARK; @@ -978,7 +965,6 @@ void logic(){ /* * Transition to and from black if necessary. */ - if(fadeEnable){ if(fadeIntensity < 160)fadeIntensity+=5; else if(fadeIntensity < 255)fadeIntensity+=1; diff --git a/src/Texture.cpp b/src/Texture.cpp index d723eda..de1af14 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -75,7 +75,7 @@ Texturec::Texturec(uint amt, ...){ void Texturec::bind(unsigned int bn){ texState = bn; - glBindTexture(GL_TEXTURE_2D, image[texState]); + glBindTexture(GL_TEXTURE_2D, (unsigned int)image[(int)texState]); } void Texturec::bindNext(){ diff --git a/src/inventory.cpp b/src/inventory.cpp index ff180b0..28612ae 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -98,23 +98,23 @@ void Inventory::draw(void){ //dfp[a] = 0; a++; }a=0; - if(invOpening && lop % 1 == 0){ + if(invOpening){ end = 0; for(auto &d : dfp){ if(a != 0){ - if(dfp[a-1]>25)d+=25; + if(dfp[a-1]>50)d+=1.65*deltaTime; }else{ - d += 25; + d += 1.65*deltaTime; } if(d >= range) d = range; a++; }a=0; if(end < numSlot)invOpen=true; - }else if(!invOpening && lop % 1 == 0){ - for(auto &d : boost::adaptors::reverse(dfp)){ + }else if(!invOpening){ + for(auto &d : dfp){ if(d > 0){ - d-=25; + d-=1.65*deltaTime; }else end++; } if(end >= numSlot)invOpen=false; diff --git a/src/world.cpp b/src/world.cpp index 36f0f69..281cbad 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -662,7 +662,7 @@ void World::singleDetect(Entity *e){ }else{ - if(e->vel.y > -2)e->vel.y-=.001 * deltaTime; + if(e->vel.y > -2)e->vel.y-=.003 * deltaTime; } -- cgit v1.2.3 From ba8bca00461fb47b14fa9fba7d4c85bb78d8c7e8 Mon Sep 17 00:00:00 2001 From: drumsetmonkey <abelleisle@roadrunner.com> Date: Tue, 1 Dec 2015 08:33:58 -0500 Subject: Updated event handling speed --- include/ui.h | 1 - main.cpp | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ui.h b/include/ui.h index c3c8940..51b5c19 100644 --- a/include/ui.h +++ b/include/ui.h @@ -76,7 +76,6 @@ namespace ui { /* * Handle keyboard/mouse events. */ - void handleEvents(void); /* diff --git a/main.cpp b/main.cpp index 26c44f8..f1ede46 100644 --- a/main.cpp +++ b/main.cpp @@ -495,6 +495,7 @@ void mainLoop(void){ /* * Run the logic handler if MSEC_PER_TICK milliseconds have passed. */ + ui::handleEvents(); if(prevPrevTime + MSEC_PER_TICK <= currentTime){ logic(); prevPrevTime = currentTime; @@ -809,7 +810,7 @@ void logic(){ /* * Handle user input (keyboard & mouse). */ - ui::handleEvents(); + //ui::handleEvents(); /* * Run the world's detect function. This handles the physics of the player and any entities -- cgit v1.2.3