Log In  


Hey, I'm making a small game.

I need to get the flag value of a sprite I'm drawing and moving in the _draw function.
I need to know when the player hits the sprite. But I can't use mget() to get sprite number of it, because the sprite is not part of the map..

Any ideas how to go about it?
Right now I'm just using pget() to register it by color, but that solution is not super stable with so few colors ;)

Hope someone can help.



This is an idea I just got, might not work, but worth giving it a try.
Considering a sprite is 8x8 :

-> get the top left pixel of the sprite
-> iterate through all colors
-> then iterate through the spritesheet to compare colors


In pico-8, the only built-in functionality of a "sprite" is you can draw it with spr(). Any flags, or a location, or velocity, or hit detection etc. has to be created/tracked from scratch.

Most people make a a table for enemies, or bullets, or the player, and assign various variables to it.

enemies={}
function spawnenemy()
 add(enemies, {sprite=5,x=20,y=20,flag=1})
end

Go to pico-8.txt (same as the manual link up top here) and check out the "Example Cartridges" section - Jelpi does a decent job of tracking multiple types of objects. (player, pickups, and enemies (all actors) and seperate sparkle particles)


Also... If what you are wanting to do is check for a collision you'll need to do that by comparing x/y positions of the two Sprite objects (eg player and enemy).

Sorry if I'm stating the obvious but I thought it worth mentioning just in case.


Right, did you actually wanted to ask how to detect collision between two sprites?


Good idea s0r00t. Might try it out later :)

But yeah, basically I just wanted to do collision, and since there was the awesome mget() I was just wandering if there was the same for sprites.
I will try and look into how it's done in Jelpi then :) Thanks for the help!



[Please log in to post a comment]