Say your player was object 1.
The idea is, whenever you move the player, you check if it's in the wall. If it is, then you quickly move the player back again before the next 'sync' command.
A quick, playable example:
Quote: "sync on
sync rate 70
make object plain 2,20.0,20.0
rotate object 2,0,0,0
make object cube 1,10.0
`Don't spawn the cube stuck in the middle of the obstacle
move object 1,-100.0:move camera -130.0
set global collision on
color object 1,rgb(255,0,0)
color object 2,rgb(0,255,0)
do
if upkey()=1
move object 1,1.0:move camera 1.0
if object collision(1,0)>0 then move object 1,-1.0:move camera -1.0
endif
if downkey()=1
move object 1,-1.0:move camera -1.0
if object collision(1,0)>0 then move object 1,1.0:move camera 1.0
endif
sync
loop
"
Note how you can't move the red cube through the green thing, and it just stops.
The bit of the code that you need is the part that checks if object 1 collides with anything (having the 2nd param set to 0 makes it return the number of the object it's colliding with or 0 if nothing). If the object is touching the green object, then the red object is quickly moved back.
The use of sync on stops the user from seeing this 'flickering' effect, as you only update the screen when you want, which just happens to be *not* when you are moving the cube.
[Edit] Oh yeah, and don't forget to turn collision on... 'Set Global Collision On' is kind of cheating, because you normally turn collision on individually for each object. That way you can control accuracy, etc. [/edit]
16-colour PNGs pwn.
