Log In  

Cart #rabbits_first_game-0 | 2024-02-06 | Code ▽ | Embed ▽ | No License
2


This is the first game made by rabbit, my german friend.

P#141233 2024-02-06 21:23

1

Cute. There's a lot that could be added to it, like collision with the screen borders or scrolling, but the most interesting that can be learned from this example is implicit assumption bugs that is one of the hardest to fix source of bugs :

There seems to be a 1 pixel collision problem when you try to collect the item from the top or from the left :

But the collision code seems OK, and so is the code that placed the item on the map.
So where in the functions is the problem ? Nowhere, but the function that generates the object coordinates assumes that coordinates are handled as numbers with fractional parts, and the collision function and the pico8 spr() function assume that we are working with integers (spr simply ignores the fractional parts)

Here, the solution that requires the less work is to rewrite the function that gives new item coordinates so that it returns only integers that will work nicely with the rest of the function ecosystem.

function get_zuf_pos()
    return flr(rnd(121))
end
P#141248 2024-02-07 10:26 ( Edited 2024-02-07 10:33)

[Please log in to post a comment]