Log In  


Slashed Res

This is something I'm actively working on.
I am trying to make a shmup or just a graphics library that I can use for other projects.

the movement is what you'd expect and (❎)(🅾️) go between the different quarters of a sprite.

Cart #quarts-0 | 2024-10-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

This code snippet is the method I made to quarter sprites.

--show a quarter of a sprite
--only works for the first row (lazy)
function qspr(sn,qn,x,y)
    local a=0
    if(qn>2) a=4 
    sspr(sn*8 + ((qn+1)%2 * 4),a,4,4,x,y)
end

This is the placeholder/guide sprite that I used to show what quarter you're on
[8x8]

I've been struggling with collision but one of my ideas is to use the flags as a bit value.
Because each 8x8 sprite for the background could have 2^4 possible combinations of quarters.

If anyone has a better idea I would be very grateful cause I don't wanna have to use binary if I can help it.



Is there a game related reason to cut your 8x8 sprites in 4 ON/OFF hit boxes ? If not, you can use sprites of different sizes. To check for collision, 1st check if there's an overlap between the bounding boxes. If there is, loop over the rectangle pixel area of the two sprites for the box overlap, and if there's two opaque pixels at the same place, you have collision. It's a bit CPU expensive, but the setup is simple, and the hit boxes are automatically defined by the sprites pixels. You can arrange your sprite sheet so that different sprites share the same empty corners.
There's one other problem with this method : collision are tested once per frame. It is possible for a fast bullet to go through an enemy without hitting. This can be mitigated by adapting your sprites : for example, if a bullet has fast horizontal speed, it will work better if it is horizontally elongated.



[Please log in to post a comment]