the levels is the four dimensional array
and the wall_temp is only one string which cointains max 10 characters.
The array levels is a big map with walls
levels[20][50][50][4];
means levels[floors][map_x][map_y][wall_side];
I put a "001" at the levels[1][1][1][1]; to test my element
I mean I put on all levels on the floor 1 at map_x 1 and at map_y 1 one wall side with value=1
This means , I put one wall in these coordinates.
I thing I solve my problem with this way.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
//---In preview code I had my wall_temp[10]=""; variable empty-------
//---With strcpy I put the 001 from floor 1 of map_x and map_y 1 and side 1
strcpy(wall_temp,levels[party.level][party.x][party.y-1][1]);
//----I am checking if my front square is not empty not "000"------------
if (levels[party.level][party.x][party.y-1][1]!="000")
{
//---- I checking if my front square is equal with my front square
//--- In fact I want check if my front square if equal with wall_temp variable
//if (levels[party.level][party.x][party.y-1][1]==wall_temp)
if (levels[party.level][party.x][party.y-1][1]==levels[party.level][party.x][party.y-1][1])
{
//---I put the "W" in one new variable wall_w and I store it to wall_string variable
strcpy(wall_string,wall_w);
//---Then I adding (appended my front square)
strcat(wall_string,levels[party.level][party.x][party.y-1][1]);
//---And I adding the string "_04" appended at the end of string
strcat(wall_string, "_04");
//--- So I have the wall_string variable as "W001_04" this is my element of graphics sprite which I load from my data file an put it on my screen
graphic = load_datafile_object("Bricks.dat",wall_string);
draw_sprite((BITMAP*)active_page,(BITMAP*)graphic->dat,62,30);
}
}
|
Is there any way to put the 001 to wall_temp without this big code
1 2
|
strcpy(wall_temp,levels[party.level][party.x][party.y-1][1]);
|
Something like this:
or without strcpy
1 2
|
wall_temp=levels[party.level][party.x][party.y-1][1];
|
In fact my datafile contains a lots of wall kinds grahics as
W001_04
W001_05
W002_04
if my front wall is 001 I put wall kind 001 if the wall is one square in front of me I add _04 at the end in the front wall is not front but front and one square to the left I put _03 at the end.
Each Kind of walls 001 , 002 etc , have positions on the screen from _01 to _23.
This is the engine how my game renders my Dungeon Crawler walls in the labyrinth.
Thank you for very fast answer. :)