Need Help With Platformer


Burbruee

Member
Joined
Sep 28, 2006
Messages
302
Location
Skåne, Sweden.
Website
Visit site
Hello,

Last night I started work on (sort of) a remake of the old Amiga P.D game Platman in Fenix.

I'm still new to Fenix and programming, and I used a platform example written in spanish by shaggylish to start building from. Although my Spanish isn't great, I think I understand all the comments and variable names.
So anyway, the solution I came up with for changing from one room to the other was by using the hardness map and painting a different color over the so called exit, then another color on the other side to be able to travel back and forth between two rooms.

It works, but might not be the best way since I use one color for each door and can be hard to keep track on. Also you COULD run out of colors, but I doubt it would happen since I'm doing 16-bits. ;)

Anyway, moving from one room to the other either by moving left or right works fine. But there are cases where you need to enter a room by falling into it (I'm remaking all of the original levels) and that's where I'm having problems. Although I paint a line in a color like I would when changing rooms horizontally, it won't detect it when moving vertically. Most likely the condition where I put the if part is wrong, which is why I request a little help to figure this one out.


Here's the part that works (changing rooms horizontally)

CODE

IF (vel_x > 0)
FOR(incremento=0;incremento<vel_x;incremento++)
color = map_get_pixel(fpg_niveles,mapa_dureza,(x+10),(y-1));
IF (color == rgb(255,0,0))
BREAK;
estado_x = PARADO;
vel_x = 0;
END;

IF (color == rgb(0,0,255))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 9, 0, 0, 0);
mapa_dureza = 10;
x = 15;
y = 116;
END;
IF (color == rgb(0,0,240))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 11, 0, 0, 0);
mapa_dureza = 12;
x = 15;
y = 448;
END;
x++;
END;
ELSE
FOR(incremento=0;incremento>vel_x;incremento--)
color = map_get_pixel(fpg_niveles,mapa_dureza,(x-10),(y-1));
IF (color == rgb(255,0,0))
BREAK;
estado_x = PARADO;
vel_x = 0;
END

IF (color == rgb(0,255,0))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 7, 0, 0, 0);
mapa_dureza = 8;
x = 622;
y = 118;
END;
IF (color == rgb(0,240,0))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 9, 0, 0, 0);
mapa_dureza = 10;
x = 623;
y = 432;
END;
x--;
END
END

The fpg_niveles is the fpg where I have all the graphics for the levels/rooms. Two of each, one normal, one hardness map.
So generally, the method I use for the illusion of going from one room to another is to do a new start_scroll and give it a new value for the background graphic to use (the new room) then I change mapa_dureza as well (this is the hardness map, and also a value from the fpg file), lastly I alter the x and y values.

Now, for the vertical movement:
CODE

//Tecla y gravedad se inicializa
IF(key(_x) AND estado_y <> SALTANDO)
gravedad = -limite_gravedad;
estado_y = SALTANDO;
play_wav(snd_salto, 0);
END
//Gravedad va cambiando en cada frame
IF (gravedad < limite_gravedad)
gravedad++;
END
/*Se averigua si está tocando el suelo cuando esté bajando
sino, nunca dejaría de tocar el suelo*/

color = map_get_pixel(fpg_niveles,mapa_dureza,x,y);
IF (color == rgb(255,0,0) AND gravedad>0)
gravedad = 0;
estado_y = PARADO;
ELSE
estado_y = SALTANDO;
END

IF(gravedad>0)
FOR(incremento=1;incremento<gravedad;incremento++)
color = map_get_pixel(fpg_niveles,mapa_dureza,x,y);
IF (color == rgb(255,0,0))
BREAK;
END;
y++;
END
ELSE
y+=gravedad;
END


I haven't translated the spanish variables, yet. But most of them are easy to figure out, such as gravedad = gravity, limited by limite_gravedad. This is defined earlier in the player process and controls how high the character can jump. The constants PARADO, SALTANDO and also ANDANDO has to do with the character animation and whether he is standing or jumping etc.

Either way, with the horizontal stuff I could just add my simple code to the right (incremento++ FOR part) or left (incremento-- FOR part)
This doesn't work so easy for the vertical movement, I've tried to put my code in different places but he just keeps falling forever and does not change to the new room.

I was hoping I could get some help figuring this one out as I don't know what needs to be done.
Thanks.
 
Burbruee said:
...
So anyway, the solution I came up with for changing from one room to the other was by using the hardness map and painting a different color over the so called exit, then another color on the other side to be able to travel back and forth between two rooms.
...
I am not sure if I really understand what you want to do and I admit knowing nothing about Fenix, but I presume you have a map of the screens so why not just keep info on where to every side of every screen leads? I mean like it was made in old text adventure games, you have a room number and also other four room numbers assigned to it (and then just detect when the player leaves the screen in any direction). Assuming you either have only one exit in every direction at most or they lead to the same room at correcponding places.
Another approach could be using special tiles that sign the room exit, but you would still need the info on where to go then.
If my hints are totally beyond what you asked, just ignore me ;)
 
Last edited by a moderator:
WhiteFalcon said:
Burbruee said:
...
So anyway, the solution I came up with for changing from one room to the other was by using the hardness map and painting a different color over the so called exit, then another color on the other side to be able to travel back and forth between two rooms.
...
I am not sure if I really understand what you want to do and I admit knowing nothing about Fenix, but I presume you have a map of the screens so why not just keep info on where to every side of every screen leads? I mean like it was made in old text adventure games, you have a room number and also other four room numbers assigned to it (and then just detect when the player leaves the screen in any direction). Assuming you either have only one exit in every direction at most or they lead to the same room at correcponding places.
Another approach could be using special tiles that sign the room exit, but you would still need the info on where to go then.
If my hints are totally beyond what you asked, just ignore me ;)

Like this, you can enter a room from the left to the right:
shot9216zf7.png

shot3197ei5.png


And you can also travel back to the previous room:

shot4870ar1.png


I'm using hardness maps to detect where there is an exit:
l003bni9.png

(there's a green line at the bottom left exit)

But I can't figure out how to do the same thing when falling down into another room: (just ends up not changing rooms and falling forever)
shot7586cu9.png


I hope that explains my problem better.
 
Last edited by a moderator:
I see your point, you use pixel collision for determining when the player is leaving a screen and in which direction. I cannot see the reason why it should not work with vertical transitions. But your images look like you really could use a tilemap (if you are not using it already). I will try to explain what seems to be a "cleaner" approach to that.
Provided the player can leave the screen only at specific places, i.e. all other sides are blocked by non-passable tiles, you would simply have a large array (map) with each cell representing a room and when the player leaves a screen (overlaps any of the screen boundaries - there should be no need for colored lines to determine that), you just find out which direction it was and change the screen according to the map. If your screens are not build from tiles then it is a different matter probably. I have only experience with tile-based platformers so that might be why I insist on using tiles :)

If this is more Fenix-related than I think, hopefully someone with knowledge of Fenix will reply.
 
It sounds as though your pixel detetion routine while falling is actually missing the hardness map. You could make the sprite do multiple pixel checks - both less than and more than the current Y value (x,y-1 x,y x,y+1 etc.) You could use something like this
CODE

// THIS IS NOT FENIX CODE, BUT SHOULD BE EASILY ADAPTABLE

b=0

For n=PlayerY-4 to PlayerY+4
b=ReadPixel (image, PlayerX, n)
Next

If b=(specific colour) Then fall_into_next_room=1



I would definitely go with a map array (as mentioned above) if the tiles are all square/rectangular - with no slopes etc. It's both cleaner and quicker than pixel checking.

However, as long as you're not testing too many pixels at a time, then it should be OK and fast enough.

BUT - bare in mind that if you intend to distribute your game as a pc executable, that certain graphics cards use slightly different values for colours, so accuracy may be affected. Obviously all GP2Xs will give the same values.

I should also add that tile based games are both quicker to create (once you've got a good editor), and save masses of memory than games that use pre-rendered imagery for levels and hardness files. The data from tiles can be used for multiple reasons - not just for player location/platforms etc.
 
iprice said:
I would definitely go with a map array (as mentioned above) if the tiles are all square/rectangular - with no slopes etc. It's both cleaner and quicker than pixel checking.
And you can even combine both methods. I once started programming a Dizzy Remake for the GP32 with a tile engine and pixel-perfect collision detection (slopes etc.) and it worked like a charm and fast and that on the old GP32.
 
Last edited by a moderator:
Make the line on your hardness map bigger. When going vertically your character will be going too fast, and miss the collision by going straight past.
 
iprice said:
I would definitely go with a map array (as mentioned above) if the tiles are all square/rectangular - with no slopes etc. It's both cleaner and quicker than pixel checking.

I should also add that tile based games are both quicker to create (once you've got a good editor), and save masses of memory than games that use pre-rendered imagery for levels and hardness files. The data from tiles can be used for multiple reasons - not just for player location/platforms etc.
Sorry for the late reply, but I found this really interesting. But I've never used map arrays or tiles in a game before.

I found this video on youtube: http://www.youtube.com/watch?v=nmAQX9iQSho
It's SDL, but you can see that he uses an array to create his map.
I want to learn how I can do that, I don't know how. ^^

Help? :)
 
Last edited by a moderator:
Sorry for the double, but I need your help with making a tile-based platformer..
I want to start simple, so no level editor for now, levels will be hardcoded by using arrays in the sourcecode.

Take a look at my _very_ simple code here. :p

CODE
PROGRAM TROLLET_IV;
GLOBAL
int i, j, map;
int TILE_SIZE = 16;
int level1[20][15] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
BEGIN;

set_title("TROLLET IV: UNDERTITLE TO BE DECIDED");
set_mode(320,240,8,256);
map = new_map(16,16,8);
map_clear(0, map, rgb(255,0,0));

for(i=0; i<20; i++)
for(j=0; j<15; j++)
if(level1[j] == 1) put(0,map, i*TILE_SIZE, j*TILE_SIZE); end;
end;
end;

loop
if(key(_esc)) exit("",0); end;
frame;
end;

END;


Who can help me spot the error in my way of thinking? Because it does not look as I expected it to look. ^^

fenixprobls5.png


Thanks, and please answer, it would mean a lot.
 
It looks like the X and Y are being read the wrong way around.

Try reversing your X (I) and Y (J)placement of the tiles so that it's

For J=
For I=

Order of the X & Y tiledrawing function is important.


[EDIT] YEP, that's exactly it. I've just used your data in BlitzMax and got EXACTLY the same map as you. Switching the X and Y creates the map as you'd expect.
map01.PNG


map02.PNG
 
iprice said:
It looks like the X and Y are being read the wrong way around.

Try reversing your X (I) and Y (J)placement of the tiles so that it's

For J=
For I=

Order of the X & Y tiledrawing function is important.
[EDIT] YEP, that's exactly it. I've just used your data in BlitzMax and got EXACTLY the same map as you. Switching the X and Y creates the map as you'd expect.
http://www.iprice.remakes.org/stuff/map01.PNG

http://www.iprice.remakes.org/stuff/map02.PNG


Thanks!
Good thing we got the same problem at first, but something is still not right for me even after reversing the order..

I changed the for to this: (also named the variables x & y so it's easier to follow)
CODE
for(y=0; y<15; y++)
for(x=0; x<20; x++)
if(level1[y][x] == 1) put(0,map, x*TILE_SIZE, y*TILE_SIZE); end;
end;
end;

But it now looks like this:
fenixprob2ng4.jpg


I even found this valuable information (look at the very bottom code snippet, it's for C/C++ [SDL], but should be exactly the same for Fenix)
http://www.parallelrealities.co.uk/tutoria.../tutorial11.php
It looks to me like I'm doing the same thing, so it's a bit of a mystery for me at the moment.
I've even tried changing the x and y's at different places out of desperation, it creates different patterns..
Everything but the right one. :p

Could you share a bit more detail please?

Thanks again.
 
Last edited by a moderator:
I didn't get the same problem first at all - I knew what the problem was and wanted to replicate your example to prove my theory was correct. It was.


I know exactly what is happening here - you are trying to draw the screen taller than it is wide because you've reversed ALL X and Y variables.

The level map should still use "level1[x][y]"



Here is my Blitzmax code, which doesn't differ dramatically to yours, but does what it's supposed to do.
CODE

' Set up screen 640x480 pixels
Graphics 640,480

' Data for map
DefData 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
DefData 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

' Set the map array maximum dimensions
Global map[20,15]

' Read the data into the array
For y=0 To 14
For x=0 To 19
ReadData map[x,y]
Next
Next

' Loop until ESC pressed
While Not KeyHit(KEY_ESCAPE)

' Draw map
For y=0 To 14
For x=0 To 19
If map[x,y]=1 Then DrawRect x*16,y*16,16,16
Next
Next

' Show screen
Flip

' Clear the backbuffer screen
Cls

Wend

End
 
Okay, I looked at your code, but apart from the Blitz-specific code and that you used another for loop to read the data into the array I couldn't spot many differences.

Here's my current code:
CODE

PROGRAM TROLLET_IV;
CONST
SCREEN_X = 320;
SCREEN_Y = 240;
SCREEN_BPP = 8;
TILE_SIZE = 16;
GLOBAL
map;
int level1[20][15] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;
BEGIN;
set_title( "TROLLET IV: UNDERTITLE TO BE DECIDED" );
set_mode( SCREEN_X, SCREEN_Y, SCREEN_BPP );
map = new_map( TILE_SIZE, TILE_SIZE, SCREEN_BPP );
map_clear( 0, map, rgb( 255, 255, 255 ));

for( y=0; y<15; y++ )
for( x=0; x<20; x++ )
if( level1[x][y] == 1 ) put(0, map, x * TILE_SIZE, y * TILE_SIZE ); end;
end;
end;

loop
if( key( _esc )) exit( "", 0 ); end;
frame;
end;
END;


And now if I run it it looks exactly the same as in my first post again, or your replication of my problem.
 
OK retry reversing the X and Y in the Level1 array, but instead of using x<20 use 15 and vice versa with Y.

CODE

for( y=0; y<20; y++ )
for( x=0; x<15; x++ )



See how that displays.



BTW which version of Fenix are you running and which IDE/ - I've tried compiling and running your code in Fenix 0.92 and FBMX, but just get error mesasges and the compiler option keeps switching to Bennu. Obviously I've not set something up correctly. Any advice on setting it up, so that I can then help you properly.
 
iprice said:
OK retry reversing the X and Y in the Level1 array, but instead of using x<20 use 15 and vice versa with Y.

CODE

for( y=0; y<20; y++ )
for( x=0; x<15; x++ )
See how that displays.

Tried that, it looks like this:

fenixprob3yz0.jpg


(changed it to 640x480, so you can see things better)
 
Last edited by a moderator:
iprice said:
BTW which version of Fenix are you running and which IDE/ - I've tried compiling and running your code in Fenix 0.92 and FBMX, but just get error mesasges and the compiler option keeps switching to Bennu. Obviously I've not set something up correctly. Any advice on setting it up, so that I can then help you properly.
Oh, I missed your edit.. Well, here goes.
I'm not currently using any IDE, for some reason FBMX has stopped working completely since I installed Visual C++ Express on my Vista installation..
If I remember correct, download and extract Fenix 0.92a somewhere. (seems like you already did this)
In FBMX, go to preferences and choose the right path for Fenix, you can leave it at Bennu I think, it will work anyway. But change to the next tab and uncheck ALL boxes except debug (-d) and it should work.

FBMX is a little buggy, so every time you start it, you need to go to preferences and click OK. (You don't actually need to change anything, just go in there and click OK)

I use Fenix 0.92 with Notepad++ and commandline currently since my FBMX no longer works..
 
Last edited by a moderator:
You're so right about FBMX being buggy - sometimes it works then other times it doesn't!!! Terrible.

I have discovered that it is to with how you have set up the multi-dimensional array - if you change one value to a number other than 0 or 1 (say 4) you will see that "4" will appear more than once in your display if you use a WRITE command to display the value of that array, rather than a PUT command. This is obviously wrong.

I'm not sure you can declare a mutli-dimensional array the way you are trying to.

CODE

PROGRAM TROLLET_IV;
GLOBAL
int i, j, map;
int TILE_SIZE = 16;

int level1[20][15];

BEGIN;

level1[0][0]=1;
level1[19][0]=2;
level1[0][14]=3;
level1[19][14]=4;

set_title("TROLLET IV: UNDERTITLE TO BE DECIDED");
set_mode(640,480,8,256);
map = new_map(16,16,8);
for(y=0; y<15; y++)
for(x=0; x<20; x++)
write (0,x*16,y*16,0,level1[x][y]);
end;
end;

loop
if(key(_esc)) exit("",0); end;
frame;
end;

END;



You will see in my code that the corners are shown correctly (from 1 to 4 from top left) when run, hence the map displaying code is working correctly - hence it's the way the data is loaded into the array.

And a second test -
CODE

PROGRAM TROLLET_IV;
GLOBAL
int n, map;
int TILE_SIZE = 16;

int level1[20][15];

BEGIN;

for(y=0; y<15; y++)
for(x=0; x<20; x++)
level1[x][y]=n;
n++;
end;
end;

set_title("TROLLET IV: UNDERTITLE TO BE DECIDED");
set_mode(640,480,8,256);
map = new_map(16,16,8);
for(y=0; y<15; y++)
for(x=0; x<20; x++)
write (0,x*48,y*16,0,level1[x][y]);

end;
end;

loop
if(key(_esc)) exit("",0); end;
frame;
end;

END;



This counts up from 0, displaying each number on the display.

You are going to have to load your data into the array either one at a time - (like I did with the four corners), or use an external file to hold the data and read it all in.
 
Sorry for the double post, but here is the solution -
CODE

PROGRAM TROLLET_IV;
GLOBAL
int n, map;
int TILE_SIZE = 16;

int lvl[20][15];

int level1[]=1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1;


BEGIN;

for(y=0; y<15; y++)
for(x=0; x<20; x++)
lvl[x][y]=level1[n];
n++;
end;
end;

set_title("TROLLET IV: UNDERTITLE TO BE DECIDED");
set_mode(640,480,8,256);
map = new_map(16,16,8);
for(y=0; y<15; y++)
for(x=0; x<20; x++)
write (0,x*16,y*16,0,lvl[x][y]);

end;
end;

loop
if(key(_esc)) exit("",0); end;
frame;
end;

END;



Use a single dimensioned array to hold the original data and then use a loop to convert it into a 2D array.
 
Back
Top