Irregular sprite overlapping area

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Irregular sprite overlapping area

Post by rrTea »

I made a small game in a non-ZGE engine, so this made me think how would the same project work in ZGE.

The mechanic I’m not sure about is the “calculate the relevant area” mechanic. Basically what I’d like to find out is how much (in pixels, but doesn't have to be super precise) of a certain sprite is overlapping with another sprite. The shape of one of the sprites is organic and animated (10 frames or so), while the other is rectangular.

This is what it currently looks like:
Image

Is this possible to do in ZGE without using OpenGL calls?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: Irregular sprite overlapping area

Post by Kjell »

Hi rrTea,
rrTea wrote: Wed Mar 16, 2022 10:44 amIs this possible to do in ZGE without using OpenGL calls?
Sure. The only thing that is a little cumbersome is the fact that you can't access image data directly, so you need to copy the alpha channel of your image / spritesheet to a array ( using a BitmapExpression ) .. and if you want to use a spritesheet there's no way to access the spritesheet coordinate data, so you need to import / copy that to a persistent array ( this isn't a issue when using tiles ). Attached is a silly & dirty example*

Image

*Didn't feel like adding support for sprite-mirroring so i mirrored the sprite in the spritesheet itself.

K
Attachments
Snap.zgeproj
(19.76 KiB) Downloaded 172 times
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: Irregular sprite overlapping area

Post by rrTea »

I see, this way I could also adjust the precision of the detection too, that's great!

Thanks! :D
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Irregular sprite overlapping area

Post by Ats »

As always your examples are so cool, Kjell :D
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Irregular sprite overlapping area

Post by VilleK »

I agree, very cool example!
Post Reply