I almost done with my program, but I found a big problem again:
I put out the elements of the game with the following code:
- Code: Select all
int i,j,xplace,yplace;
char level1[20][30] =
{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,1,0,0,0,0,0,1,0,0,0,0,0,1},
{0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,1,0,1},
{0,0,0,0,0,1,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,1,0,1},
{0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1},
{0,0,0,0,0,1,0,1,0,1,0,1,1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1},
{0,0,0,0,0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0},
{1,1,1,1,1,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,1,0,1,0,0,0,0},
{1,2,1,1,0,3,0,0,4,1,0,1,1,0,0,1,1,0,0,0,4,0,0,1,0,1,0,0,0,0},
{1,0,1,1,0,1,1,1,0,1,0,0,1,1,0,1,1,0,1,1,1,1,0,1,0,1,1,0,0,0},
{1,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,1,0,0,0},
{1,1,1,1,1,1,0,1,0,0,1,0,1,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0},
{0,0,0,0,0,1,0,1,1,0,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,0},
{0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,4,1,0,0,0},
{1,1,1,1,1,1,0,1,1,0,1,1,0,0,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0},
{1,0,0,0,0,0,0,1,1,0,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
{1,0,1,1,1,1,0,1,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1},
};
//
xplace=0;
yplace=0;
walls=0;
for(j = 0; j < 20; j++)
{
for(i=0; i < 30; i++)
{
switch (level1[j][i])
{
case 1: CreateActor("wall", "wall", "no parent", "no path",xplace,yplace,true);
placeofwall[walls][0]=xplace;
placeofwall[walls][1]=yplace;
walls+=1;
break;
case 2: CreateActor("teleport", "teleport", "no parent", "no path",xplace,yplace,true); break;
case 3: CreateActor("ghost", "ghost0", "no parent", "no path",xplace,yplace,true); break;
case 4: CreateActor("dot", "dot", "no parent", "no path",xplace,yplace,true); break;
};
xplace+=wall.width;
};
xplace=0;
yplace+=wall.height;
};
Everything are on their place, so everything OK. But when I try to place other things on the coordinates of the walls, these things will be on totally different places, however I have saved their coordinates into
placeofwall arrays. To see it, I placing these things with the following code:
- Code: Select all
for (i=0;i<walls;i+=1)
{
CreateActor("dot", "dot", "no parent", "no path",placeofwall[i][0],placeofwall[i][1],true);
}
But it is not good; the dots appears on wrong coordinates! What is the problem and how can I solve this?