Log In  

Cart #woyfozida-0 | 2022-08-23 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#116186 2022-08-23 21:43 ( Edited 2022-08-23 21:44)

I forgot to change the 'btnp' to 'btn' before publishing this but theres still collision issues.

P#116188 2022-08-23 21:45
2

This is a problem that comes up a lot. The method you're using for collision detection only works for grid-aligned movement. If you switch to smooth movement, then your check for collisions only applies to the top-left corner of your character.

The quickest change to your code to fix it would be to change this line

        if(can_move(newx,newy)) then

to this

    if(can_move(newx,newy) and
       can_move(newx+.875,newy) and
       can_move(newx,newy+.875) and
       can_move(newx+.875,newy+.875)) then

To explain, .875 is 1 pixel less than a full tile, as measured in tiles. As such, the other 3 calls to can_move check the other 3 corners of your character.

P#116189 2022-08-23 22:44

[Please log in to post a comment]