(WinXP, BORLAND free command line compiler, console project)
Ok, I'm making a ladder-type thing in game. The idea is you can climb up '/' and '\'s.
I'm sorry to ask this, but I have been staring at this code for two days and I'm not getting anywhere...
Heres the problematic code, and the constants relating to it;
Code:
#include "EnemyClass.h"
#define Player '*'
#define ExitPeice 'O'
#define Blank ' '
#define Wall1 '|' //Basic straight wall.
#define Wall2 '//' //Stairs to the right.
#define Wall3 '\\' //Stairs to the left.
#define Wall4 '>' //Peice pushable right. Kills @, &, $.
#define Wall5 '<' //Peice pushable left. Kills @, &, $.
#define Wall6 '[' //Peice pushable left. For protection.
#define Wall7 ']' //Peice, pushable right. For protection
#define Wall8 '-' //A bridge peice, will break when stepped off of.
#define Wall9 '=' //Normal peice.
#define Wall10 '^' //Death if fallen onto or stepped on.
#define Up 1
#define Down 2
#define Left 3
#define Right 4
#define Esc 5
int MoveRight() {
DWORD reader;
COORD Pos;
char Saveme[1];
char Savemeto[1];
char Walllist[] = "|][<>-=^\\//";
char Enemies[3];
const char W2 = Wall2;
unsigned int x;
Enemies[0]=Enemy1;
Enemies[1]=Enemy2;
Enemies[2]=Enemy3;
Enemies[3]=Enemy4;
if(Jumping == 1)
return 0;
Pos.X=HEROX;
Pos.Y=HEROY;
if(Pos.X >= 79 || Pos.X <= 0)
return 0;
Pos.X++;
ReadConsoleOutputCharacter(hOt, &Saveme[0], 1, Pos, &reader);
Pos.Y--;
ReadConsoleOutputCharacter(hOt, &Savemeto[0], 1, Pos, &reader);
Pos.X--;
Pos.Y++;
for(x=0; x <= 3; x++)
if(Saveme[0] == Enemies[x])
Death();
if(Saveme[0] == W2 || Savemeto[0] == W2) {
for(x=0; x <= (strlen(Walllist)-2); x++)
if(Saveme[0] == Walllist[x])
return 0;
SetConsoleCursorPosition(hOt, Pos);
cout << Blank;
Pos.X++;
Pos.Y--;
SetConsoleCursorPosition(hOt, Pos);
CPlayer();
HEROX=Pos.X;
HEROY=Pos.Y;
SetConsoleCursorPosition(hOt, RSP);
return 1;
}
for(x=0; x >= strlen(Walllist); x++)
if(Saveme[0] == Walllist[x])
return 0;
SetConsoleCursorPosition(hOt, Pos);
Pos.X++;
cout << Blank;
SetConsoleCursorPosition(hOt, Pos);
CPlayer();
HEROX=Pos.X;
HEROY=Pos.Y;
SetConsoleCursorPosition(hOt, RSP);
return 1;
}
int MoveLeft() {
DWORD reader;
COORD Pos;
char Saveme[1];
char Savemeto[1];
char Walllist[] = "|][<>-=^//\\";
char Enemies[3];
const char W2 = Wall3;
unsigned int x;
Enemies[0]=Enemy1;
Enemies[1]=Enemy2;
Enemies[2]=Enemy3;
Enemies[3]=Enemy4;
if(Jumping == 1)
return 0;
Pos.X=HEROX;
Pos.Y=HEROY;
if(Pos.X >= 78 || Pos.X <= 1)
return 0;
Pos.X--;
ReadConsoleOutputCharacter(hOt, &Saveme[0], 1, Pos, &reader);
Pos.Y--;
ReadConsoleOutputCharacter(hOt, &Savemeto[0], 1, Pos, &reader);
Pos.X++;
Pos.Y++;
for(x=0; x <= 3; x++)
if(Saveme[0] == Enemies[x])
Death();
if(Saveme[0] == W2 || Savemeto[0] == W2) {
for(x=0; x <= (strlen(Walllist)-2); x++)
if(Saveme[0] == Walllist[x])
return 0;
SetConsoleCursorPosition(hOt, Pos);
cout << Blank;
Pos.X--;
Pos.Y--;
SetConsoleCursorPosition(hOt, Pos);
CPlayer();
HEROX=Pos.X;
HEROY=Pos.Y;
SetConsoleCursorPosition(hOt, RSP);
return 1;
}
for(x=0; x <= strlen(Walllist); x++)
if(Saveme[0] == Walllist[x])
return 0;
SetConsoleCursorPosition(hOt, Pos);
Pos.X--;
cout << Blank;
SetConsoleCursorPosition(hOt, Pos);
CPlayer();
HEROX=Pos.X;
HEROY=Pos.Y;
SetConsoleCursorPosition(hOt, RSP);
return 1;
}
int Check() {
int x;
x=IsArrowDown();
if(x==Right) {
MoveRight();
return 1;
}
if(x==Left) {
MoveLeft();
return 2;
}
if(x==Esc)
return 5;
return 0;
}
Thats all the resources that are needed -,-. So, as I said you can climb up the edges of '/' and '\'s. Now, you should not be able to go through walls. However, for the right side you cant climb them at all. For the left, you can climb, but you end up going through walls...
So I'm wondering, why does it let you go through walls on the left, but not right?
Thank you very much!