As you start off in screen one of my zeldaish game, and you move to screen 2, and then back to screen one for any reason, the game suddenly ends...D:
heres the game:
zipped game
(requires the SDL.dll included)
just walk through the opening on the right then back to the left, the program ends...
heres the specific code I think may have something to do with it...but im not sure:
..........
..........
//avatar position X/Y
int avX, avY;
//map stats
const int NumScrWide=5;
const int NumScrHigh=5;
..........
..........
int main(int args, char *argv[]){
screen(1000, 500, 0, "Tileset Simulation");
int x = w / 2, y = h-20 ;
int avatarX=x;
int avatarY=h/2;
//screen selector
int screen=1;
while(!done()){
.....
avX=getAvatarX(avatarX,avatarY);
avY=getAvatarY(avatarX,avatarY);
avatarX=avX;
avatarY=avY;
.....
screenTester(screen,avatarX,avatarY);
drawAvatar(avX,avY);
.....
.....
.....
}
heres the actual screens at least the parts I think are maybe the problem:
else if(screen==1){
grass();
//left wall
drawNoPassRect(avX,avY,enemyX,enemyY,0,0,5,h-1,RGB_Red);
for(int i=0;i<=h;i+=10){
drawRect(0,i,5,i+2,RGB_Black);
}
//top wall
drawNoPassRect(avX,avY,enemyX,enemyY,0,0,w-1,5,RGB_Red);
for(int i=0;i<=w;i+=10){
drawRect(i,0,i+2,5,RGB_Black);
}
//right wall
drawNoPassRect(avX,avY,enemyX,enemyY,w-5,0,w-1,h-100,RGB_Red);
drawNoPassRect(avX,avY,enemyX,enemyY,w-5,h-50,w-1,h-1,RGB_Red);
for(int i=0;i<=h-100;i+=10){
drawRect(w-5,i,w-1,i+2,RGB_Black);
}
for(int i=h-50;i<=h-1;i+=10){
drawRect(w-5,i,w-1,i+2,RGB_Black);
}
//bottom trees
//left
for(int i=w/2-65;i>=0;i-=50){
drawDisk(i,h-15,30,RGB_Darkgreen);
}
for(int i=w/2-65;i>=0;i-=50){
drawDisk(i,h-15,20,RGB_Olive);
}
for(int i=w/2-65;i>=0;i-=50){
drawDisk(i,h-15,10,RGB_Darkgreen);
}
//right
for(int i=w/2+65;i<=w;i+=50){
drawDisk(i,h-15,30,RGB_Darkgreen);
}
for(int i=w/2+65;i<=w;i+=50){
drawDisk(i,h-15,20,RGB_Olive);
}
for(int i=w/2+65;i<=w;i+=50){
drawDisk(i,h-15,10,RGB_Darkgreen);
}
//border control
drawNoPassRect(avX,avY,enemyX,enemyY,0,h-40,w/2-45,h);
drawNoPassRect(avX,avY,enemyX,enemyY,w/2+45,h-40,w,h);
//draw boulder and check if near
if(drawNoPassRect(avX,avY,enemyX,enemyY,w-95,50,w-50,75,RGB_Gray)==true){nearBoulderLvl[1]=true;}
else {nearBoulderLvl[1]=false;}
//boulder menu
if(nearBoulderLvl[1]==true)
{
menuMakerObjects(keyLvl[1],"Look under boulder?","You found a key!","numKeys",numKeys);
}
//draw house and
//check if near house
if(drawHouse(avX,avY,50,50)==true)
{
nearHouseLvl[1]=true;
}else{nearHouseLvl[1]=false;}
//house menu
if(nearHouseLvl[1]==true)
{
menuMakerDoors("Enter the house?",screen,-1,1,"You need the key!",avX,avY);
}
}
else if(screen==2){
.....
.....
createEnemy(1,"rabbit",600,200,EnemyX[1],EnemyY[1],numKeys);
}
and heres the actual changing of the screens:
//actual level changing
if(avX>w){
avX=1;
screen++;
}
else if(avX<0){
avX=w;
screen--;
}
else if(avY>h){
avY=1;
screen+=NumScrWide;
}
else if(avY<0){
avY=h;
screen-=NumScrHigh;
}
//
The last two code blocks are both a part of ScreenTester(...)
sorry if I cant be more clear on the question...