diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2015-12-09 08:30:04 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2015-12-09 08:30:04 -0500 |
commit | 1d3ba18c99850996f0ba85d99e269270d42056bf (patch) | |
tree | b6dbbab2730f1567167d34a19e020cb2af5e0d1d | |
parent | 996a2b90c40b078dabc9a435156a836b9693d0b1 (diff) | |
parent | 380137ca06c2c74806c1838cb10ef3a17dda8406 (diff) |
Did Shit
-rw-r--r-- | include/ui.h | 3 | ||||
-rw-r--r-- | main.cpp | 21 | ||||
-rw-r--r-- | src/ui.cpp | 86 | ||||
-rw-r--r-- | src/world.cpp | 7 |
4 files changed, 76 insertions, 41 deletions
diff --git a/include/ui.h b/include/ui.h index f2c0114..a5a2ec0 100644 --- a/include/ui.h +++ b/include/ui.h @@ -85,6 +85,9 @@ namespace ui { */ void toggleBlack(void); + void toggleBlackFast(void); + void toggleWhite(void); + void waitForCover(void); } @@ -210,6 +210,8 @@ unsigned int millis(void){ extern WEATHER weather; extern bool fadeEnable; +extern bool fadeWhite; +extern bool fadeFast; extern unsigned int fadeIntensity; /******************************************************************************* @@ -405,7 +407,7 @@ int main(/*int argc, char *argv[]*/){ names = fopen("assets/names_en-us", "r+"); crickets=Mix_LoadWAV("assets/sounds/crickets.wav"); - Mix_Volume(3,25); + //Mix_Volume(2,25); /* * Create all the worlds, entities, mobs, and the player. This function is defined in @@ -714,7 +716,10 @@ void render(){ */ if(fadeIntensity){ - glColor4ub(0,0,0,fadeIntensity); + if(fadeWhite) + glColor4ub(255,255,255,fadeIntensity); + else + glColor4ub(0,0,0,fadeIntensity); glRectf(offset.x-SCREEN_WIDTH /2, offset.y-SCREEN_HEIGHT/2, offset.x+SCREEN_WIDTH /2, @@ -955,10 +960,10 @@ void logic(){ if(!(tickCount%DAY_CYCLE)||!tickCount){ if(weather==SUNNY){ weather=DARK; - Mix_PlayChannel(3,crickets,0); + Mix_PlayChannel(2,crickets,0); }else{ weather=SUNNY; - Mix_Pause(3); + Mix_Pause(2); } } @@ -972,11 +977,11 @@ void logic(){ * Transition to and from black if necessary. */ if(fadeEnable){ - if(fadeIntensity < 160)fadeIntensity+=10; - else if(fadeIntensity < 255)fadeIntensity+=5; + if(fadeIntensity < 150)fadeIntensity+=fadeFast?30:10; + else if(fadeIntensity < 255)fadeIntensity+=fadeFast?15:5; }else{ - if(fadeIntensity > 150)fadeIntensity-=5; - else if(fadeIntensity > 0) fadeIntensity-=10; + if(fadeIntensity > 150)fadeIntensity-=fadeFast?15:5; + else if(fadeIntensity > 0) fadeIntensity-=fadeFast?30:10; } /* @@ -61,6 +61,8 @@ extern void mainLoop(void); */ bool fadeEnable = false; +bool fadeWhite = false; +bool fadeFast = false; unsigned int fadeIntensity = 0; bool inBattle = false; @@ -452,6 +454,11 @@ namespace ui { mainLoop(); }while(ui::dialogBoxExists); } + void waitForCover(void){ + do{ + mainLoop(); + }while(fadeIntensity != 255); + } void importantText(const char *text,...){ va_list textArgs; @@ -559,11 +566,34 @@ namespace ui { } } } + void dialogAdvance(void){ + unsigned char i; + if(!typeOutDone){ + typeOutDone = true; + return; + } + + for(i=0;i<dialogOptCount;i++){ + if(mouse.x > dialogOptLoc[i][0] && + mouse.x < dialogOptLoc[i][2] && + mouse.y > dialogOptLoc[i][1] && + mouse.y < dialogOptLoc[i][1] + 16 ){ // fontSize + dialogOptChosen = i + 1; + goto DONE; + } + } +DONE: + if(dialogImportant){ + dialogImportant = false; + setFontSize(16); + toggleBlack(); + } + dialogBoxExists = false; + } void handleEvents(void){ static bool left=true,right=false; static vec2 premouse={0,0}; static int heyOhLetsGo = 0; - unsigned char i; World *tmp; SDL_Event e; @@ -581,28 +611,7 @@ namespace ui { break; case SDL_MOUSEBUTTONDOWN: if((e.button.button&SDL_BUTTON_RIGHT)&&dialogBoxExists){ - - if(!typeOutDone){ - typeOutDone = true; - break; - } - - for(i=0;i<dialogOptCount;i++){ - if(mouse.x > dialogOptLoc[i][0] && - mouse.x < dialogOptLoc[i][2] && - mouse.y > dialogOptLoc[i][1] && - mouse.y < dialogOptLoc[i][1] + 16 ){ // fontSize - dialogOptChosen = i + 1; - goto DONE; - } - } -DONE: - if(dialogImportant){ - dialogImportant = false; - setFontSize(16); - toggleBlack(); - } - dialogBoxExists = false; + dialogAdvance(); } break; /* @@ -611,12 +620,18 @@ DONE: case SDL_KEYDOWN: if(SDL_KEY == SDLK_ESCAPE){ gameRunning = false; + return; + }else if(SDL_KEY == SDLK_SPACE){ + if(dialogBoxExists) + dialogAdvance(); + else if(player->ground){ + player->vel.y=.4; + player->loc.y+=HLINE*2; + player->ground=false; + } break; }else if(!dialogBoxExists){//&&!fadeEnable){ switch(SDL_KEY){ - case SDLK_ESCAPE: - gameRunning=false; - break; case SDLK_a: player->vel.x=-.15; player->left = true; @@ -644,13 +659,6 @@ DONE: currentWorld=((Arena *)currentWorld)->exitArena(player); else currentWorld=currentWorld->goInsideStructure(player); break; - case SDLK_SPACE: - if(player->ground){ - player->vel.y=.4; - player->loc.y+=HLINE*2; - player->ground=false; - } - break; case SDLK_i: tmp=currentWorld; currentWorld=currentWorld->goWorldBack(player); // Go back a layer if possible @@ -756,5 +764,17 @@ DONE: void toggleBlack(void){ fadeEnable ^= true; + fadeWhite = false; + fadeFast = false; + } + void toggleBlackFast(void){ + fadeEnable ^= true; + fadeWhite = false; + fadeFast = true; + } + void toggleWhite(void){ + fadeEnable ^= true; + fadeWhite = true; + fadeFast = false; } } diff --git a/src/world.cpp b/src/world.cpp index f751287..cb5f3ec 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -1,4 +1,5 @@ #include <world.h> +#include <ui.h> #define getWidth(w) ((w->lineCount-GEN_INC)*HLINE) // Calculates the width of world 'w' @@ -923,6 +924,9 @@ World *World::goInsideStructure(Player *p){ if(p->loc.x > b->loc.x && p->loc.x + p->width < b->loc.x + b->width ){ thing.push_back(this); + ui::toggleBlackFast(); + ui::waitForCover(); + ui::toggleBlackFast(); return (World *)b->inside; } } @@ -932,6 +936,9 @@ World *World::goInsideStructure(Player *p){ World *tmp = (World *)thing.back(); p->loc.x = b->loc.x + (b->width / 2) - (p->width / 2); thing.erase(thing.end()-1); + ui::toggleBlackFast(); + ui::waitForCover(); + ui::toggleBlackFast(); return tmp; } } |