From b28023525c6dcf2360c8d03b405d46af4e0e1c6d Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Thu, 10 Dec 2015 08:13:15 -0500 Subject: Doing shit --- include/entities.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/entities.h') 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; -- cgit v1.2.3 From c5050b17d16670c6151d5c135c3b01d66b7530f9 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Mon, 14 Dec 2015 08:25:15 -0500 Subject: Added particles --- assets/fountain1.png | Bin 0 -> 524 bytes assets/house2.png | Bin 0 -> 747 bytes include/entities.h | 36 +++++++++++++++++++++--- include/world.h | 5 ++-- main.cpp | 24 +++++++++++----- src/entities.cpp | 24 ++++++++++++++-- src/gameplay.cpp | 6 +++- src/inventory.cpp | 12 +++++--- src/ui.cpp | 2 +- src/world.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++------ 10 files changed, 155 insertions(+), 31 deletions(-) create mode 100644 assets/fountain1.png create mode 100644 assets/house2.png (limited to 'include/entities.h') diff --git a/assets/fountain1.png b/assets/fountain1.png new file mode 100644 index 0000000..46f7c44 Binary files /dev/null and b/assets/fountain1.png differ diff --git a/assets/house2.png b/assets/house2.png new file mode 100644 index 0000000..7404cd9 Binary files /dev/null and b/assets/house2.png differ diff --git a/include/entities.h b/include/entities.h index e0c0887..dbaf9f5 100644 --- a/include/entities.h +++ b/include/entities.h @@ -34,22 +34,48 @@ enum MOB_SUB { MS_TRIGGER }; -struct Particles{ +enum BUILD_SUB{ + TOWN_HALL = 1, + HOUSE, + HOUSE2, + HOUSE3, + HOUSE4, + FOUNTAIN +}; + +class Particles{ +public: vec2 loc; float width; float height; + float velx; + float vely; Color color; - Particles(float x, float y, float w, float h, Color c){ + int duration; + bool canMove; + Particles(float x, float y, float w, float h, float vx, float vy, Color c, int d){ loc.x = (x); loc.y = (y); width = (w); height = (h); + velx = vx; + vely = vy; color.red = (c.red); color.green = (c.green); color.blue = (c.blue); + duration = d; } + ~Particles(){} void draw(){ - std::cout << "Drawing Particles\n"; + glColor3f(color.red,color.green,color.blue); + glRectf(loc.x,loc.y,loc.x+width,loc.y+height); + } + bool kill(float delta){ + duration -= delta; + if(duration <= 0){ + return true; + } + else return false; } }; @@ -77,6 +103,7 @@ public: bool canMove; // Enables movement bool right,left; // Direction faced by Entity bool alive; + bool hit; unsigned char ground; // Shows how the Entity is grounded (if it is) /* @@ -137,11 +164,12 @@ class Structures : public Entity{ public: void *inWorld; void *inside; + BUILD_SUB bsubtype; Structures(); ~Structures(); - unsigned int spawn(_TYPE, float, float); + unsigned int spawn(_TYPE, BUILD_SUB, float, float); }; class Mob : public Entity{ diff --git a/include/world.h b/include/world.h index 5a16277..dbaaf2c 100644 --- a/include/world.h +++ b/include/world.h @@ -161,12 +161,13 @@ public: std::vector object; std::vector particles; - void addStructure(_TYPE t,float x,float y,World *outside,World *inside); + void addStructure(_TYPE t,BUILD_SUB sub,float x,float y,World *outside,World *inside); + void addVillage(int bCount, int npcMin, int npcMax,_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 addParticle(float, float, float, float, float, float, Color color, int); void update(Player *p,unsigned int delta); diff --git a/main.cpp b/main.cpp index 931f688..50f5c75 100644 --- a/main.cpp +++ b/main.cpp @@ -838,10 +838,16 @@ 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})){ + if(!player->inv->usingi) n->hit = false; + if(player->inv->usingi && !n->hit && player->inv->detectCollision(vec2{n->loc.x, n->loc.y},vec2{n->loc.x+n->width,n->loc.y+n->height})){ n->health -= 25; - currentWorld->addParticle(n->loc.x, n->loc.y, HLINE*3, HLINE*3, {255,0,0}); + n->hit = true; + for(int r = 0; r < (rand()%5);r++) + currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000); + if(n->health <= 0){ + for(int r = 0; r < (rand()%30)+15;r++) + currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%10)*.01-.05), {(rand()%75)+10/100.0f,0,0}, 10000); + } } /* * Don't bother handling the NPC if another has already been handled. @@ -866,9 +872,7 @@ void logic(){ * considered legal. In other words, require the player to be close to * the NPC in order to interact with it. * - * This uses the Pythagorean theorem to check for NPCs within a certain - * radius (40 HLINEs) of the player's coordinates. - * + * This uses the Pythagorean theorem to check for NPCs within a certain * */ if(pow((n->loc.x - player->loc.x),2) + pow((n->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){ @@ -928,7 +932,7 @@ void logic(){ if(ui::mouse.x >= o->loc.x && ui::mouse.x <= o->loc.x + o->width && ui::mouse.y >= o->loc.y && - ui::mouse.y <= o->loc.y + o->width ){ + ui::mouse.y <= o->loc.y + o->height ){ if(pow((o->loc.x - player->loc.x),2) + pow((o->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){ /* @@ -948,6 +952,12 @@ void logic(){ } } } + for(auto &b : currentWorld->build){ + if(b->bsubtype == FOUNTAIN){ + for(int r = 0; r < (rand()%20)+10;r++) + currentWorld->addParticle(rand()%HLINE*3 + b->loc.x + b->width/2,b->loc.y + b->height, HLINE,HLINE, rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,((4+rand()%6)*.05), {0,0,1.0f}, 2500); + } + } /* * Switch between day and night (SUNNY and DARK) if necessary. diff --git a/src/entities.cpp b/src/entities.cpp index a04b638..1fefa9a 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -10,6 +10,8 @@ extern Player *player; extern const char *itemName; +extern + void getRandomName(Entity *e){ int tempNum,max=0; char *bufs; @@ -57,6 +59,7 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o near = false; canMove = true; ground = false; + hit = false; ticksToUse = 0; @@ -116,12 +119,12 @@ NPC::~NPC(){ } Structures::Structures(){ //sets the structure type - health = maxHealth = 1; + health = maxHealth = 25; alive = false; near = false; - tex = new Texturec(1,"assets/house1.png"); + tex = new Texturec(3,"assets/house1.png", "assets/house2.png", "assets/fountain1.png"); inWorld = NULL; name = NULL; @@ -211,6 +214,7 @@ void Entity::draw(void){ //draws the entities static int texState = 0; static bool up = true; if(loops % (int)((float)4/(float)speed) == 0){ + //currentWorld->addParticle(loc.x,loc.y-HLINE,HLINE,HLINE,0,0,{0.0f,.17f,0.0f},1000); if(up){ if(++texState==2)up=false; tex->bindNext(); @@ -241,6 +245,19 @@ void Entity::draw(void){ //draws the entities break; } break; + case STRUCTURET: + for(auto &strt : currentWorld->build){ + if(this == strt){ + if(strt->bsubtype == HOUSE){ + tex->bind(0); + }else if(strt->bsubtype == HOUSE2){ + tex->bind(1); + }else if(strt->bsubtype == FOUNTAIN){ + tex->bind(2); + } + } + } + break; default: tex->bind(0); break; @@ -369,7 +386,7 @@ void Object::interact(void){ * point to have non-normal traits so it could be invisible or invincible... */ -unsigned int Structures::spawn(_TYPE t, float x, float y){ +unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){ loc.x = x; loc.y = y; type = t; @@ -378,6 +395,7 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ width = 50 * HLINE; height = 40 * HLINE; + bsubtype = sub; /* * tempN is the amount of entities that will be spawned in the village. Currently the village diff --git a/src/gameplay.cpp b/src/gameplay.cpp index b9aa328..54ef432 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -127,7 +127,11 @@ void initEverything(void){ playerSpawnHill->addMob(MS_TRIGGER,player->loc.x,0,story); - playerSpawnHill->addStructure(STRUCTURET,(rand()%120*HLINE),100,test,iw); + playerSpawnHill->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,test,iw); + playerSpawnHill->addStructure(STRUCTURET,FOUNTAIN,(rand()%120*HLINE)+100*HLINE,100,test,iw); + //playerSpawnHill->addStructure(STRUCTURET,HOUSE2,(rand()%120*HLINE)+300*HLINE,100,test,iw); + + //playerSpawnHill->addVillage(5,1,4,STRUCTURET,rand()%500+120,(float)200,playerSpawnHill,iw); playerSpawnHill->addMob(MS_TRIGGER,-1300,0,CUTSCENEEE); playerSpawnHill->addObject(SWORD_WOOD, false, "", 480,200); diff --git a/src/inventory.cpp b/src/inventory.cpp index 585af47..5ae97b4 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -26,7 +26,7 @@ void initInventorySprites(void){ } swordSwing = Mix_LoadWAV("assets/sounds/shortSwing.wav"); - Mix_Volume(2,75); + Mix_Volume(2,100); } char *getItemTexturePath(ITEM_ID id){ @@ -317,10 +317,14 @@ int Inventory::useItem(void){ case SWORD: if(swing){ if(!player->left){ - /*if(hangle==-15){up=true;Mix_PlayChannel(2,swordSwing,0);} + if(hangle==-15){up=true;Mix_PlayChannel(2,swordSwing,0);} if(up)hangle-=.75*deltaTime; - if(hangle<=-90)hangle=-14;*/ + if(hangle<=-90)hangle=-14; }else{ + if(hangle==15){up=true;Mix_PlayChannel(2,swordSwing,0);} + if(up)hangle+=.75*deltaTime; + if(hangle>=90)hangle=14; + /* if(hangle<90&&!up)hangle+=.75*deltaTime; if(hangle>=90&&!up)up=true; if(up)hangle-=.75*deltaTime; @@ -329,7 +333,7 @@ int Inventory::useItem(void){ swing=false; hangle=15; return 0; - } + }*/ } }else if(!swing){ swing=true; diff --git a/src/ui.cpp b/src/ui.cpp index ff5a84a..013d1ae 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -682,7 +682,7 @@ DONE: } break; case SDLK_LSHIFT: - player->speed = debug ? 4.0f : 3.0f; + player->speed = debug ? 4.0f : 1.75f; break; case SDLK_LCTRL: player->speed = .5; diff --git a/src/world.cpp b/src/world.cpp index 7a47c97..8994f6c 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -108,7 +108,14 @@ void World::deleteEntities(void){ delete object.back(); object.pop_back(); } - while(!entity.empty()) entity.pop_back(); + while(!entity.empty()){ + entity.pop_back(); + } + + while(!particles.empty()){ + delete particles.back(); + particles.pop_back(); + }//particles.clear(); } World::~World(void){ @@ -294,6 +301,28 @@ void World::update(Player *p,unsigned int delta){ else if(e->vel.x > 0)e->left = false; } } + uint oh = 0; + for(auto &pa : particles){ + if(pa->kill(deltaTime)){ + delete pa; + particles.erase(particles.begin()+oh); + }else if(pa->canMove){ + pa->loc.y += pa->vely * deltaTime; + pa->loc.x += pa->velx * deltaTime; + + for(auto &b : build){ + if(b->bsubtype==FOUNTAIN){ + if(pa->loc.x >= b->loc.x && pa->loc.x <= b->loc.x+b->width){ + if(pa->loc.y <= b->loc.y + b->height*.25){ + delete pa; + particles.erase(particles.begin()+oh); + } + } + } + } + } + oh++; + }oh=0; if(ui::dialogImportant){ Mix_FadeOutMusic(2000); @@ -523,7 +552,7 @@ LOOP2: //b->loc.y+=(yoff-DRAW_Y_OFFSET); b->draw(); //b->loc.y-=(yoff-DRAW_Y_OFFSET); - std::cout<loc.x<<" "<loc.y<loc.x<<" "<loc.y<draw();} for(auto &n : current->npc){ n->loc.y+=(yoff-DRAW_Y_OFFSET); n->draw(); @@ -621,7 +650,7 @@ LOOP2: o->draw(); o->loc.y-=(yoff-DRAW_Y_OFFSET); } - }for(auto &o : particles){o->draw();} + } /* @@ -851,23 +880,52 @@ void World::detect(Player *p){ */ LOOOOP: + static int what = 0; for(auto &e : hey->entity) hey->singleDetect(e); + for(auto &part : particles){ + int l; + unsigned int i; + l=(part->loc.x + part->width / 2 - x_start) / HLINE; + if(l < 0) l=0; + i = l; + if(i > lineCount-1) i=lineCount-1; + if(part->loc.y < line[i].y){ + part->loc.y = line[i].y; + part->vely = 0; + part->velx = 0; + part->canMove = false; + }else{ + if(part->vely > -2)part->vely-=.003 * deltaTime; + } + what++; + }what=0; if(hey->infront){ hey = hey->infront; goto LOOOOP; } } - -void World::addStructure(_TYPE t,float x,float y,World *outside,World *inside){ +void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *outside,World *inside){ build.push_back(new Structures()); - build.back()->spawn(t,x,y); + build.back()->spawn(t,sub,x,y); build.back()->inWorld=outside; build.back()->inside=(void *)inside; entity.push_back(build.back()); } +void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside,World *inside){ + std::cout << npcMin << ", " << npcMax << std::endl; + int xwasd; + for(int i = 0; i < bCount; i++){ + xwasd = (rand()%(int)x+1000*HLINE); + HERE: + for(auto &bu : build){ + if(xwasd > bu->loc.x && xwasd < bu->loc.x+bu->width)goto HERE; + } + addStructure(t,HOUSE,xwasd,y,outside,inside); + } +} void World::addMob(int t,float x,float y){ mob.push_back(new Mob(t)); mob.back()->spawn(x,y); @@ -897,8 +955,9 @@ 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::addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d){ + particles.push_back(new Particles(x,y,w,h,vx,vy,color,d)); + particles.back()->canMove = true; } /*void World::removeObject(Object i){ -- cgit v1.2.3 From 477e6cdde57a428b41e814943233d8b01f0db6bf Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 14 Dec 2015 08:41:31 -0500 Subject: arenas --- Changelog | 12 ++++++++ assets/sounds/frig.wav | Bin 0 -> 332726 bytes include/entities.h | 3 +- include/ui.h | 1 + include/world.h | 4 ++- main.cpp | 20 +++++++------ src/entities.cpp | 6 ++++ src/gameplay.cpp | 10 ++++++- src/ui.cpp | 75 ++++++++++++++++++++++++++++++++++++++++--------- src/world.cpp | 36 ++++++++++++++---------- 10 files changed, 127 insertions(+), 40 deletions(-) create mode 100644 assets/sounds/frig.wav (limited to 'include/entities.h') diff --git a/Changelog b/Changelog index 44e0bfc..c894c5c 100644 --- a/Changelog +++ b/Changelog @@ -408,3 +408,15 @@ - imrpoved BGM handling - continued work on particles, made a fountain - added sanic + + ~ Broke 5000 lines of code/doc, now with some file Doxygen'd + +12/14/2015: +=========== + + - Re-implemented Arena + added door mob for exit + added white flash + sound transition + - fixed fading bugs + - continued fixing general game bugs + - fixed structure spawn issues diff --git a/assets/sounds/frig.wav b/assets/sounds/frig.wav new file mode 100644 index 0000000..86d64e9 Binary files /dev/null and b/assets/sounds/frig.wav differ diff --git a/include/entities.h b/include/entities.h index dd3adab..30947f5 100644 --- a/include/entities.h +++ b/include/entities.h @@ -31,7 +31,8 @@ enum GENDER{ enum MOB_SUB { MS_RABBIT = 1, MS_BIRD, - MS_TRIGGER + MS_TRIGGER, + MS_DOOR }; class Entity{ diff --git a/include/ui.h b/include/ui.h index 2fe3b0a..5d17c47 100644 --- a/include/ui.h +++ b/include/ui.h @@ -87,6 +87,7 @@ namespace ui { void toggleBlack(void); void toggleBlackFast(void); void toggleWhite(void); + void toggleWhiteFast(void); void waitForCover(void); } diff --git a/include/world.h b/include/world.h index 1e78cd0..777f5b8 100644 --- a/include/world.h +++ b/include/world.h @@ -231,6 +231,9 @@ public: World *goWorldRight(Player *p); World *goWorldBack(Player *p); World *goWorldFront(Player *p); + + bool isWorldLeft(void); + bool isWorldRight(void); /* * Called to enter/exit a structure. @@ -277,7 +280,6 @@ public: class Arena : public World { private: vec2 pxy; - vec2 door; World *exit; public: Arena(World *leave,Player *p); diff --git a/main.cpp b/main.cpp index 4e45189..b31c7e0 100644 --- a/main.cpp +++ b/main.cpp @@ -212,7 +212,7 @@ extern WEATHER weather; extern bool fadeEnable; extern bool fadeWhite; extern bool fadeFast; -extern unsigned int fadeIntensity; +extern int fadeIntensity; /******************************************************************************* * MAIN ************************************************************************ @@ -717,9 +717,9 @@ void render(){ if(fadeIntensity){ if(fadeWhite) - glColor4ub(255,255,255,fadeIntensity); + safeSetColorA(255,255,255,fadeIntensity); else - glColor4ub(0,0,0,fadeIntensity); + safeSetColorA(0,0,0,fadeIntensity); glRectf(offset.x-SCREEN_WIDTH /2, offset.y-SCREEN_HEIGHT/2, offset.x+SCREEN_WIDTH /2, @@ -916,6 +916,8 @@ void logic(){ case MS_TRIGGER: m->wander(0); break; + case MS_DOOR: + break; default: std::cout<<"Unhandled mob of subtype "<subtype<<"."< 150)fadeIntensity-=fadeFast?15:5; - else if(fadeIntensity > 0) fadeIntensity-=fadeFast?30:10; + if(fadeIntensity > 150)fadeIntensity-=fadeFast?20:5; + else if(fadeIntensity > 0) fadeIntensity-=fadeFast?40:10; + else fadeIntensity = 0; } /* diff --git a/src/entities.cpp b/src/entities.cpp index 5c00cc7..15f120a 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -151,6 +151,10 @@ Mob::Mob(int sub){ width = HLINE * 20; height = 2000; tex = new Texturec(0); + case MS_DOOR: + width = HLINE * 10; + height = HLINE * 16; + tex = new Texturec(1,"assets/door.png"); break; } @@ -236,6 +240,7 @@ void Entity::draw(void){ //draws the entities goto NOPE; break; case MS_BIRD: + case MS_DOOR: default: tex->bind(0); break; @@ -437,6 +442,7 @@ void Mob::wander(int timeRun){ hey(this); } break; + case MS_DOOR: default: break; } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 74414d7..6d8fb0b 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -48,9 +48,17 @@ void worldSpawnHill1_hillBlock(Mob *callee){ callee->alive = true; } +static Arena *a; void worldSpawnHill2_infoSprint(Mob *callee){ - ui::dialogBox("B-) ",NULL,true,"Press \'Shift\' to run!"); callee->alive = false; + a = new Arena(currentWorld,player); + a->setBackground(BG_FOREST); + a->setBGM("assets/music/embark.wav"); + ui::toggleWhiteFast(); + ui::waitForCover(); + currentWorld = a; + ui::toggleWhiteFast(); + //ui::dialogBox("B-) ",NULL,true,"Press \'Shift\' to run!"); } void worldSpawnHill3_itemGet(Mob *callee){ diff --git a/src/ui.cpp b/src/ui.cpp index 26b30c4..11bc195 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -65,6 +65,7 @@ bool fadeFast = false; unsigned int fadeIntensity = 0; bool inBattle = false; +Mix_Chunk *battleStart; namespace ui { @@ -460,7 +461,8 @@ namespace ui { void waitForCover(void){ do{ mainLoop(); - }while(fadeIntensity != 255); + }while(fadeIntensity < 255); + fadeIntensity = 255; } void importantText(const char *text,...){ va_list textArgs; @@ -598,6 +600,7 @@ DONE: static vec2 premouse={0,0}; static int heyOhLetsGo = 0; World *tmp; + vec2 oldpos,tmppos; SDL_Event e; mouse.x=premouse.x+offset.x-(SCREEN_WIDTH/2); @@ -628,9 +631,9 @@ DONE: gameRunning = false; return; }else if(SDL_KEY == SDLK_SPACE){ - if(dialogBoxExists) + /*if(dialogBoxExists) dialogAdvance(); - else if(player->ground){ + else */if(player->ground){ player->vel.y=.4; player->loc.y+=HLINE*2; player->ground=false; @@ -640,35 +643,65 @@ DONE: tmp = currentWorld; switch(SDL_KEY){ case SDLK_a: + if(fadeEnable)break; player->vel.x=-.15; player->left = true; player->right = false; left = true; right = false; - currentWorld=currentWorld->goWorldLeft(player); - if(tmp!=currentWorld) - dialogBoxExists = false; + if(currentWorld->isWorldLeft()){ + memcpy(&oldpos,&player->loc,sizeof(vec2)); + tmp = currentWorld->goWorldLeft(player); + if(currentWorld != tmp){ + memcpy(&tmppos,&player->loc,sizeof(vec2)); + memcpy(&player->loc,&oldpos,sizeof(vec2)); + toggleBlackFast(); + waitForCover(); + memcpy(&player->loc,&tmppos,sizeof(vec2)); + currentWorld = tmp; + toggleBlackFast(); + dialogBoxExists = false; + } + } break; case SDLK_d: + if(fadeEnable)break; player->vel.x=.15; player->right = true; player->left = false; left = false; right = true; - currentWorld=currentWorld->goWorldRight(player); - if(tmp!=currentWorld) - dialogBoxExists = false; + if(currentWorld->isWorldRight()){ + memcpy(&oldpos,&player->loc,sizeof(vec2)); + tmp = currentWorld->goWorldRight(player); + if(currentWorld != tmp){ + memcpy(&tmppos,&player->loc,sizeof(vec2)); + memcpy(&player->loc,&oldpos,sizeof(vec2)); + toggleBlackFast(); + waitForCover(); + memcpy(&player->loc,&tmppos,sizeof(vec2)); + currentWorld = tmp; + toggleBlackFast(); + dialogBoxExists = false; + } + } break; case SDLK_s: - if(player->ground == 2){ + /*if(player->ground == 2){ player->ground=false; player->loc.y-=HLINE*1.5; - } + }*/ break; case SDLK_w: - if(inBattle) - currentWorld=((Arena *)currentWorld)->exitArena(player); - else currentWorld=currentWorld->goInsideStructure(player); + if(inBattle){ + tmp = currentWorld; + currentWorld = ((Arena *)currentWorld)->exitArena(player); + if(tmp != currentWorld){ + //delete &tmp; + toggleBlackFast(); + } + }else + currentWorld=currentWorld->goInsideStructure(player); break; case SDLK_i: currentWorld=currentWorld->goWorldBack(player); // Go back a layer if possible @@ -718,6 +751,13 @@ DONE: default: break; } + if(tmp != currentWorld){ + std::swap(tmp,currentWorld); + toggleBlackFast(); + waitForCover(); + std::swap(tmp,currentWorld); + toggleBlackFast(); + } } break; /* @@ -795,4 +835,11 @@ DONE: fadeWhite = true; fadeFast = false; } + void toggleWhiteFast(void){ + fadeEnable ^= true; + fadeWhite = true; + fadeFast = true; + battleStart = Mix_LoadWAV("assets/sounds/frig.wav"); + Mix_PlayChannel(1,battleStart,0); + } } diff --git a/src/world.cpp b/src/world.cpp index 3f35e21..7b578d3 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -351,7 +351,7 @@ LLLOOP: current=current->infront; goto LLLOOP; } - cx_start = current->x_start; + cx_start = current->x_start * 1.5; width = (-x_start) << 1; glEnable(GL_TEXTURE_2D); @@ -437,6 +437,9 @@ LLLOOP: glDisable(GL_TEXTURE_2D); + glColor3ub(0,0,0); + glRectf(cx_start,GEN_MIN,-cx_start,0); + /* * World drawing is done recursively, meaning that this function jumps * back as many 'layers' as it can and then draws, eventually coming @@ -941,6 +944,14 @@ World *World::goWorldFront(Player *p){ return this; } +bool World::isWorldLeft(void){ + return toLeft ? true : false; +} + +bool World::isWorldRight(void){ + return toRight ? true : false; +} + std::vectorthing; World *World::goInsideStructure(Player *p){ if(!thing.size()){ @@ -1078,18 +1089,13 @@ extern bool inBattle; Arena::Arena(World *leave,Player *p){ generate(300); - //door.y = line[299].y; - //door.x = 100; - exit = leave; - - /*npc.push_back(new NPC()); - entity.push_back(npc.back()); - entity.back()->spawn(door.x,door.y); - entity.back()->width = HLINE * 12; - entity.back()->height = HLINE * 16;*/ - + addMob(MS_DOOR,100,100); inBattle = true; + exit = leave; pxy = p->loc; + + star = new vec2[100]; + memset(star,0,100 * sizeof(vec2)); } Arena::~Arena(void){ @@ -1101,11 +1107,11 @@ Arena::~Arena(void){ } World *Arena::exitArena(Player *p){ - npc[0]->loc.x = door.x; - npc[0]->loc.y = door.y; - if(p->loc.x + p->width / 2 > door.x && - p->loc.x + p->width / 2 < door.x + HLINE * 12 ){ + if(p->loc.x + p->width / 2 > mob[0]->loc.x && + p->loc.x + p->width / 2 < mob[0]->loc.x + HLINE * 12 ){ inBattle = false; + ui::toggleBlackFast(); + ui::waitForCover(); p->loc = pxy; return exit; }else{ -- cgit v1.2.3