aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog12
-rw-r--r--assets/sounds/frig.wavbin0 -> 332726 bytes
-rw-r--r--include/entities.h3
-rw-r--r--include/ui.h1
-rw-r--r--include/world.h4
-rw-r--r--main.cpp20
-rw-r--r--src/entities.cpp6
-rw-r--r--src/gameplay.cpp10
-rw-r--r--src/ui.cpp75
-rw-r--r--src/world.cpp36
10 files changed, 127 insertions, 40 deletions
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
--- /dev/null
+++ b/assets/sounds/frig.wav
Binary files 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 "<<m->subtype<<"."<<std::endl;
break;
@@ -955,7 +957,6 @@ void logic(){
if(!(tickCount%DAY_CYCLE)||!tickCount){
if(weather==SUNNY){
weather=DARK;
- Mix_PlayChannel(2,crickets,0);
}else{
weather=SUNNY;
Mix_Pause(2);
@@ -971,12 +972,15 @@ void logic(){
/*
* Transition to and from black if necessary.
*/
+
if(fadeEnable){
- if(fadeIntensity < 150)fadeIntensity+=fadeFast?30:10;
- else if(fadeIntensity < 255)fadeIntensity+=fadeFast?15:5;
+ if(fadeIntensity < 150)fadeIntensity+=fadeFast?40:10;
+ else if(fadeIntensity < 255)fadeIntensity+=fadeFast?20:5;
+ else fadeIntensity = 255;
}else{
- if(fadeIntensity > 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::vector<void *>thing;
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{