aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui.cpp45
-rw-r--r--src/world.cpp40
2 files changed, 60 insertions, 25 deletions
diff --git a/src/ui.cpp b/src/ui.cpp
index e5a2f44..5d6c2ab 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -122,15 +122,18 @@ namespace ui {
}
float putString(const float x,const float y,const char *s){
unsigned int i=0,j;
- float xo=x,yo=y;
+ float xo=x,yo=y,pw=0;
do{
if(s[i]=='\n'){
yo-=fontSize*1.05;
xo=x;
}else if(s[i]==' '){
xo+=fontSize/2;
+ }else if(s[i]=='\b'){
+ xo-=pw;
}else{
- xo+=putChar(xo,yo,s[i])+fontSize*.1;
+ pw=putChar(xo,yo,s[i])+fontSize*.1;
+ xo+=pw;
}
}while(s[i++]);
return xo;
@@ -237,17 +240,29 @@ namespace ui {
player->ground=false;
}
}
+ World *tmp;
if(SDL_KEY==SDLK_i){
- player->vel.y=.2;
- player->loc.y+=HLINE*7;
- player->ground=false;
+ tmp=currentWorld;
currentWorld=currentWorld->goWorldBack(player); // Go back a layer if possible
+ if(tmp!=currentWorld){
+ currentWorld->detect(player);
+ player->vel.y=.2;
+ player->loc.y+=HLINE*5;
+ player->ground=false;
+ }
}
if(SDL_KEY==SDLK_k){
- player->vel.y=.2;
- player->loc.y+=HLINE*10;
- player->ground=false;
+ tmp=currentWorld;
currentWorld=currentWorld->goWorldFront(player); // Go forward a layer if possible
+ if(tmp!=currentWorld){
+ player->loc.y=0;
+ currentWorld->behind->detect(player);
+ player->vel.y=.2;
+ player->ground=false;
+ }
+ }
+ if(SDL_KEY==SDLK_c){
+ dialogBox("","You pressed `c`, but nothing happened.");
}
if(SDL_KEY==SDLK_LSHIFT)player->speed = 3; // Sprint
if(SDL_KEY==SDLK_LCTRL)player->speed = .5;
@@ -271,12 +286,12 @@ namespace ui {
}
unsigned int i;
- //if(!dialogBoxExists&&AIpreaddr.size()){ // Flush preloaded AI functions if necessary
- //for(i=0;i<AIpreaddr.size();i++){
- //AIpreaddr.front()->addAIFunc(AIpreload.front(),false);
- //AIpreaddr.erase(AIpreaddr.begin());
- //AIpreload.erase(AIpreload.begin());
- //}
- //}
+ if(!dialogBoxExists&&AIpreaddr.size()){ // Flush preloaded AI functions if necessary
+ for(i=0;i<AIpreaddr.size();i++){
+ AIpreaddr.front()->addAIFunc(AIpreload.front(),false);
+ AIpreaddr.erase(AIpreaddr.begin());
+ AIpreload.erase(AIpreload.begin());
+ }
+ }
}
}
diff --git a/src/world.cpp b/src/world.cpp
index 97ec5ac..599b1ef 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -240,15 +240,26 @@ LOOP2:
* Draw the layer up until the grass portion, which is done later.
*/
+ bool hey=false;
glBegin(GL_QUADS);
for(i=is;i<ie-GEN_INC;i++){
- cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset
- safeSetColor(cline[i].color+shade,cline[i].color-50+shade,cline[i].color-100+shade); // Set the shaded dirt color
+ cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset
+ if(!cline[i].y){
+ cline[i].y+=50;
+ hey=true;
+ safeSetColor(cline[i].color-100+shade,cline[i].color-150+shade,cline[i].color-200+shade);
+ }else{
+ safeSetColor(cline[i].color+shade,cline[i].color-50+shade,cline[i].color-100+shade); // Set the shaded dirt color
+ }
glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT);
glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT);
glVertex2i(cx_start+i*HLINE+HLINE,0);
glVertex2i(cx_start+i*HLINE ,0);
- cline[i].y-=(yoff-DRAW_Y_OFFSET); // Restore the line's y value
+ cline[i].y-=(yoff-DRAW_Y_OFFSET); // Restore the line's y value
+ if(hey){
+ hey=false;
+ cline[i].y=0;
+ }
}
glEnd();
@@ -277,6 +288,10 @@ LOOP2:
cline[i].gs=false;
else cline[i].gs=true;
}
+ }else{
+ for(i=0;i<lineCount-GEN_INC;i++){
+ cline[i].gs=true;
+ }
}
/*
@@ -289,12 +304,17 @@ LOOP2:
* Draw non-structure entities.
*/
- if(current==this){
- for(i=0;i<entity.size();i++){
- if(entity[i]->inWorld==this && entity[i]->type != STRUCTURET)
- entity[i]->draw();
- }
+ for(i=0;i<entity.size();i++){
+ if(entity[i]->inWorld==this && entity[i]->type != STRUCTURET)
+ entity[i]->draw();
}
+
+ }else{
+
+ /*for(i=0;i<lineCount-GEN_INC;i++){
+ cline[i].gs=true;
+ }*/
+
}
/*
@@ -581,8 +601,8 @@ void World::addHole(unsigned int start,unsigned int end){
}
}
-int World::getStart(void){
- return -x_start;
+int World::getTheWidth(void){
+ return x_start*2;
}
IndoorWorld::IndoorWorld(void){