FANDOM


I am now assuming that you have read Part 1 of this tutorial. If not, you can find it at http://petitcomputer.wikia.com/wiki/How_to_make_a_simple_collision_(part_1)

But for all of you who did...

Where we left off, we made it so you could build the backround. But actually, you built the collision detection in Part 1! We just have to do the collision detectors!

So. First, we'll make your character. First, we'll put the X and Y coords.

X=20:Y=20

Then we start the loop.

@LOOP
OLDX=X:OLDY=Y

This is for in case we have your character touch a background.

B=BUTTON()
IF B AND 1 THEN Y=Y+1
IF B AND 2 THEN Y=Y-1
IF B AND 4 THEN X=X-1
IF B AND 8 THEN X=X+1

This is for movement. Now for the collision DETECTORS:

IF MAP(FLOOR(X+2)/8,FLOOR(Y/8)) THEN X=OLDX
IF MAP(FLOOR(X/8),FLOOR(Y+2)/8) THEN Y=OLDY
IF MAP(FLOOR(X-2)/8,FLOOR(Y/8)) THEN X=OLDX
IF MAP(FLOOR(X/8),FLOOR(Y-2)/8) THEN Y=OLDY

This will read all 4 sides of the character. And now, we draw your character.

GCLS
GCIRCLE X,Y,2 (IF 2 DOESN'T WORK RIGHT, TRY 4)
WAIT 1
GOTO @LOOP

Creditz: Edit

Randomous- for his COLITEST, which really helped

Me- for making this tutorial

You- For reading

THANK YOU!

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.