aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-12-14 08:43:28 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-12-14 08:43:28 -0500
commit840cf5f0d3fc60aceb95385010eac02ae6c95dcc (patch)
tree0b7eb237737289ad9b3f9bffc1478875d0d71abf /src
parent3f70fa248e411178f33075f4b90f112eced37f14 (diff)
parent477e6cdde57a428b41e814943233d8b01f0db6bf (diff)
Merge branch 'master' of http://github.com/tcsullivan/gamedev
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp6
-rw-r--r--src/gameplay.cpp10
-rw-r--r--src/ui.cpp75
-rw-r--r--src/world.cpp36
4 files changed, 97 insertions, 30 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 9d0ea9b..24c0d01 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -154,6 +154,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;
}
@@ -240,6 +244,7 @@ void Entity::draw(void){ //draws the entities
goto NOPE;
break;
case MS_BIRD:
+ case MS_DOOR:
default:
tex->bind(0);
break;
@@ -456,6 +461,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 59320af..f922b03 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 c1c306e..6909cf7 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -380,7 +380,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);
@@ -466,6 +466,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
@@ -1005,6 +1008,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::vector<void *>thing;
World *World::goInsideStructure(Player *p){
if(!thing.size()){
@@ -1142,18 +1153,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){
@@ -1165,11 +1171,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{