aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-12-09 08:30:04 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-12-09 08:30:04 -0500
commit1d3ba18c99850996f0ba85d99e269270d42056bf (patch)
treeb6dbbab2730f1567167d34a19e020cb2af5e0d1d /src
parent996a2b90c40b078dabc9a435156a836b9693d0b1 (diff)
parent380137ca06c2c74806c1838cb10ef3a17dda8406 (diff)
Did Shit
Diffstat (limited to 'src')
-rw-r--r--src/ui.cpp86
-rw-r--r--src/world.cpp7
2 files changed, 60 insertions, 33 deletions
diff --git a/src/ui.cpp b/src/ui.cpp
index b0ed64c..d13b2e8 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -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;
}
}