There are two ways of doing so. The first is exact, using sparky's collision commands to collide on a custom made level from a modelling program. The second, and probably easier way, is using a grid system.
Let's say you want to make a 10x10 level. Initialize your grid with a 10x10 array:
Note that 0 is also an index.
Next step is adding your level data into this array. How about we have 3 different bricks? we'll make one stone, one dirt, and the last one cheese. Why cheese? I like cheese :3 So define that before you start creating your level:
none=0
stone=1
dirt=2
cheese=3
Alright, now let's create the level. You can either make it manually, or code a simple level editor to do this process for you. For now we do it manually.
Level:
b=brick
d=dirt
c=cheese
y axis
9 _|_|_|_|_|_|_|_|_|_
8 _|c|c|_|_|_|_|_|_|_
7 _|_|_|_|_|_|_|_|_|_
6 _|_|_|_|_|_|_|d|d|_
5 _|_|_|_|_|_|_|_|_|_
4 _|_|_|_|_|_|_|_|_|_
3 _|_|_|_|_|_|_|_|_|_
2 _|_|_|_|b|_|_|_|_|_
1 _|_|_|_|b|_|_|b|_|_
0 b|b|b|b|b|b|b|b|b|b
0 1 2 3 4 5 6 7 8 9 x axis
OK, so we first set the ground:
for x=0 to 9
level(x,0)=brick
next x
Next the big wall, positioned at 4,0:
level(4,1)=brick
level(4,2)=brick
And last, the little wall:
Alright, now we make some cheese and some dirt in the sky (don't ask me why
)
level(1,8)=cheese
level(2,8)=cheese
level(7,6)=dirt
level(8,6)=dirt
And now you have a 2D grid level saved into just one array. To load the level from the array, you can use this:
rem load images
load image "brick.bmp",brick
load image "dirt.bmp",dirt
load image "cheese.bmp",cheese
rem scan through array and create bricks
for x=0 to 9
for y=0 to 9
if level(x,y)>0
make object cube 1,10
position object 1,x*10,y*10,0
texture object 1,level(x,y)
endif
next y
next x
And that's it! For collision I recommend looking up on sliding collision, since they are only simple cubes.
TheComet