the best way to do this would be to change the tile, not use like 50 sprites.
You can also delay this to make the tile update midway or after the animation of the juice falling. It’ll make the 2 events feel more seamless and like the juice actually did fall on the tile.
As a rule of thumb, try to use as few sprites as possible because they are very laggy.
Let me clarify. First one pixel was not intended, but it was the only way I could get the juice to have different lengths. So 16 pixels for each tile covers in juice. Second I tried to use the to bottom of sprite location but images work differently when it comes To tile map location. third If I made a custom tile, like the example I would have to make the game ask what floor tile is beneath the character and there are tons of different ones. Then the juice would all look the same. That’s why I wanted to use images to make a Unique stain on the tile every time.
What I need:
A less laggy solution to making the juice have different lengths. Preferably one sprite.
II need a different unique stain on the tile.
It should cover different tile around it too.
You don’t have to do the coding, I just need a solution for these problems.
You can put a sprite below the player, when the juice spills, and then set the image to a random value from an array! Then it can look different almost every time!
(Sorry for the late reply, I never got any notification.) well, yes but no? I can make it a random length using the pick a random block, but that would make the entire image, the length that the pick a random block chose.
I’m late, but I think the best solution would be this (a modified version of @BitBot ‘s solution):
Create an array with a bunch of juice sprites that are all the same size
Pick a random sprite to use each time
Use the sprite scaling extension to scale the sprite in the horizontal direction, so it can have a new length
Place that sprite on the tile map location below the player or enemy
If the sprite’s placement is off, change the position (ex. If the sprite is in the center of the tile rather than the edge, add 8 pixels to its x and y positions each time it’s placed to fix it)
Additionally, I’d suggest you make the sprite images the size of the largest splatter and then scale them down to new sizes so that the resolution is better.
now that i think about it, though, this approach does have a problem which is that it’s going to flood your tilemap’s tileset… tilemaps have a max number of tiles (256) and with this approach the maximum number of unique splatter problems would be something like 2^12 (4096). of course you’re probably unlikely to actually hit that limit, but still not great.
it would probably be better to just draw the splatter on top of the tiles in a render on z-index block but to do that every frame i’d probably need to change the copyPartialImage function to be more efficient by using the native blit function instead of going over each pixel individually.
or actually, it would make sense to just store the splatter as an image on the tile and then just draw that. i’ll make another version of the project with that approach when i have a sec
if you intend to run this game on hardware, then this is very inefficient memory wise but doesn’t have the tilemap troubles of the earlier example. if you’re just running the game on the computer then memory doesn’t matter
Well in case anyone else wants an alternative juice system: (Press A to juice)
There’s a function to spawn the juice so if you want to change how it splatters or add new splatter shapes you can! Since this is just a list of sprites it’s laggier than drawing the juice directly to the screen, but It’s good for temporary juice because you could remove the oldest ones using the ‘array of sprites of kind juice’ block if you want to put in a juice limit.
in situations like this I would just draw to z screen still because you can just have an array of all the juice locations and another array with a lifetime value or something. you could remove splatters if the lifetime is too high in the array