Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Sprite Collision - with non-transparent areas only

Author
Message
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 3rd Oct 2003 13:00
Can anyone please tell me how to detect sprite collision with only the non transparent areas of a sprite and ignore the transparent areas.

I have started a project that requires the whole of the screen to be a sprite but I only want collision detection with the outer edge and the bit in the middle (see screenshot below).

I tried SPRITE COLLISION but there is constant contact regardless of whether the 'spaceship' sprite is over background or 'rock'. So, instead I tried POINT to detect the four corners around the spaceship and with that I get a very strange result! There is black detected everywhere! The whole screen is black! The only exception to this is the water which I added as a BOX.

I would prefer to use SPRITE COLLISION, so, if anyone can help me out I would very much appreciate it.

Thank you.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 3rd Oct 2003 16:07
I think your the same guy who was asking before.

Anyhoo, I looked into it and could'nt for the life of me get it working - it works perfectly in DBClassic, yet DBPro struggles, probably because sprites are now 3D objects as opposed to 2D images.

I think you best bet is to substitute the sprite collision for a super fast point command using memblocks. You load your background image, then make a memblock from it and a function that can return the pixel colour of a specified coordinate. The POINT command, even when used with locked pixels is still pretty slow, not really fast enough for a whole collision system.

If I have time, I'll try and make a little demo - but what type of game is it, the last demo I promised has a little boat and a course to drive around, I could just get that working. The thing is that it might be better if I use a sprite mask array to get better collision detection, but there's no point if it'd be useless for yourself.


Van-B

My cats breath smells of cat food.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 3rd Oct 2003 19:37
Thanks VanB - Yes it was me before.

I have no idea about memblocks, so if you could knock up a 'little demo' that would be great!

OK - you want to know what kind of game it is. Think 'Lunar Lander' with guns and missiles, Two players on a split screen attacking each other. Maybe adding more than two players later and possibly online.

But the main grunt of the program is two ships with guns and gravity.

Thanks for your help.

http://www.freewebs.com/scragglesoft/
haggisman
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 3rd Oct 2003 21:23
Heres another method you might want to take a look at, in the zip:-

http://www.haggisman.plus.com/collision-test.zip

You should find two DBpro programs, one is a simple example of fudged collision . It works by checking for intersections of the two sprites edges, which means it also can work for rotated sprites and eventually scaled ones as well (when i get round to it).

The other program generates the collision file for the sprites, it works by in effect laying lines along the edge of the sprite between the transparent part and the opaque part. Unfortunately with the ease of automation it is less accurate and more wastefull than laying lines by hand. I guess it needs some optimisation...

Defying the convention of an upright avatar since 1985
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Oct 2003 16:13
... Codebase ...

Login to post a reply

Server time is: 2024-05-05 13:46:04
Your offset time is: 2024-05-05 13:46:04