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 on another sprite.

Author
Message
Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 6th May 2006 21:48 Edited at: 6th May 2006 21:48
Hi, I'm making a side scroller in DBP. I have the basics done already.(jumping,gravity,friction,shooting,...) I need help with player sprite colliding with another sprite. The catch is, I want it to collide with the visible part of the sprite and not the black part that was taken out. Any ideas?
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 7th May 2006 03:18
Use sprite hit rather than sprite collision.
Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 8th May 2006 06:42
I tried that already but it doesn't seem to work.
Any other ideas?
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th May 2006 19:14
Search the Code Snippets. Pixel perfect collision has been implemented by somebody (possibly Cash Curtis).


Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 10th May 2006 05:50
I'm looking at all the different pixel perfect collision but I can't find one that works with DBPRO. I'll see if I can find something that will work.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 10th May 2006 07:12 Edited at: 10th May 2006 07:16
I found a couple in the code base:

One is Ian m's, that should work with sprites that haven't been scaled or rotated. It's from 2003 and it looks fairly reasonable

http://www.thegamecreators.com/?m=codebase_view&i=e62787ebd353c421a4c465dc15201870

There was also one that said Nearly_Pixel_Perfect_Collision regardless of rotation or scaling; though I don't have the time to go through the code right now. by Graham jones

http://www.thegamecreators.com/?m=codebase_view&i=a782de0e5d9531c9442b9509feac3329

They may be of some help to you.
Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 10th May 2006 23:06
I found the first sprite collision code before but I scale the sprites so I can't use it. Maybe I can change it a little more to fit my code. I also looked into the second one and you have to make .col files with its sprite collision creater. I might use that one if I can't get the first one to work. So complicated to get a simple collision. Thanks a lot for helping, I'll continue to look to see if I can find good sprite collision code.
Mickm
20
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Kingston, ON
Posted: 11th May 2006 23:13
I created a small example of some sprite collision stuff using two PNG files.

I have included the source to download and also just posted the code.

http://www.gamestack.org
Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 12th May 2006 22:43 Edited at: 12th May 2006 22:53
I want to have collision for the player sprite when it hits another sprite without counting the black/invisible part. Here's a pic of the collision level.

The player should only have collision with platforms and not the black/invisible part. Does anyone know how to do this? DB Classic was way easier then this is turing out to be.

Here's a pic of the game im working on. You can climb the ladder and have collision on the platforms. All the objects are different sprites. Its the only way I know how to do collision so far. The background textures are from METAL SLUG. I was thinking about a remake or something like it. The only difference from it is that you move with the arrow keys and aim with the mouse.
Mickm
20
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Kingston, ON
Posted: 12th May 2006 22:51
I am not sure of the best way but the easiest way would be to use the SPRITE HIT command.

It would end up being a lot of IF statments but it will get the job done.


See my code in the post above to use it.

http://www.gamestack.org
Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 12th May 2006 23:10
Thats about the same way I do the collision code now. DB Pro causes the collision to be on when the player sprite hits the black part. I don't want that to happen.
Mickm
20
Years of Service
User Offline
Joined: 22nd Apr 2006
Location: Kingston, ON
Posted: 12th May 2006 23:50
Can you post the image file and the player? (just flat images)
Ill see if i can make some code to do that.

http://www.gamestack.org
Labyrnth
20
Years of Service
User Offline
Joined: 23rd Dec 2005
Location:
Posted: 13th May 2006 04:05
Joker that looks hot can we see a larger image of the game in action please?
Im real new to DBPro but i sure like looking and hoping my stuff will be looking awsome one day like that

Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 13th May 2006 19:43
This is a closer screen of the player shooting. The top platform allows the player to stay on top of it. The bottom platform makes the player bounce down if he hits it. The ladder allows the player to climb it with the jump button (up key).
Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 14th May 2006 21:51 Edited at: 15th May 2006 22:44
Quote: "Can you post the image file and the player? (just flat images)
Ill see if i can make some code to do that."


Can't you use any two pictures. All I would need is the format of the picture file that works. I'm using .bmp format right now but some people say that dds files work for sprites. I don't have photoshop so I'll have to wait to get them back from my friend to see if they work. The screenshot was sized way to small from photobucket. I'll see if I can make it bigger.
Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 16th May 2006 07:03
The dds file format didn't work. I'm thinking about just having a blocky collision until I can figure something out. Update if you guys find a good working sprite collision for DBP.
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 16th May 2006 19:05
As you've noticed, Dbpro doesn't support pixel perfect collision. So you'll have to either roll your own math collision engine (best option), or chase down a function set that will compare two images at pixel level. There's bound to be some in the code perform

Psycho Joker
20
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 23rd May 2006 01:13
Has anyone looked into line collision with sprites?
tippy1000
20
Years of Service
User Offline
Joined: 19th May 2006
Location:
Posted: 25th May 2006 05:44
What about making the black the transparent color? And then color the backdrop black or something like that, would that work?

Ed
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th May 2006 16:16
No - DBPro collision is limited to simple 'is this rectangle overlapping that rectangle' type collision. It has nothing to do with what you can see of the sprite, and if you include a large invisible border around your sprite, it will still be included in the collision test.

As you can see above, I assisted in writing a pixel-to-pixel collision routine, that handled offsets, but not scaling or rotation. Others have included rotation, and scaling, but the more comprehensive you make your collision routine, the slower it gets.

Anyway, none of this looks like it is needed for Psycho Jokers world - just use a tile-based world instead of a big sprite containing your platform. The code is liable to be far simpler than writing a proper pixel-perfect collision system.

For free Plug-ins and source code http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2026-07-04 13:25:26
Your offset time is: 2026-07-04 13:25:26