Log In  


Cart #pidhuniku-1 | 2025-02-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

I can’t figure this one out…

I’m trying to make a simple game where the player picks up strawberries in a set amount of time. I used Rnd() and mset() to randomize where the strawberries are on the map everytime, but I can’t figure out how to make the player interact with them. I can make the strawberries add to a counter, but don’t know how to swap the tiles to the version of the sprite without the red dot that represents the strawberries.

I know I’m doing something wrong but don’t know what. I’ve tried using collisions and flags, and mget and mset, but still no luck.

How can I solve this?



1

You are almost there.
Your collide function checks a single pixel inside the payer sprite, ditch is a bit small for a hit box, but it works, and the number of fruits collected is properly incremented.
What is missing right after the increment is the mset statement that puts the tile in the collected state.


Thanks a lot! Finally figured it out. You are awesome.


1

No problem. Just a remark about your mset :
Flr(fboy.x+5)/8 is the same as (fboy.x+5)/8
What you meant was flr((fboy.x+5)/8)
Or (fboy.x+5)\8 if you use integer division.
The reason it works despite the mistake is because mset silently discards the fractional part of its parameters.
In general, when a native pico8 function expects an integer parameter , the fractional part is discarded.



[Please log in to post a comment]