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.

Newcomers DBPro Corner / 2D Sprite Collision Problem in DBPRO

Author
Message
Kenzenray
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: India
Posted: 1st Jan 2003 14:59
First of all thanks for viewing my request.

I am aspiring programmer. I am using Trial versions of DB v1.06, v1.13, DBPRO.

When I make sprites out of images and use the Sprite Hit() function,
- In DarkBasic, the event occurs when the sprite's borders collide.
- But, in DBPRO, the event occurs when the unseen borders touch (i.e. the transparent black area, which encompasses the sprite when using `GET IMAGE'), the even occurs. Thus the sprite doesn't actually collide, but the HIT occurs when they come near to each other. How to overcome this ?

Any assistance will be helpful.
Thankyou.
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 1st Jan 2003 18:06
Hmm, I dont have pro, but I figure its just another bug. There is a more advanced way to overcome this.

First, start with your object that can be collided with (just for the heck of it, Ill use a warp pipe in Mario games)

You should find the objects coordinates first. Then you need to map out the coordinates which you DO NOT want your other sprite to be able to cross. You may have to try it a few times, just incase the command does things from the center of the sprite (eg- you may not have the coordinates RIGHT at the edge of the pipe)

Well anyways, find the coordinates like x1, y1, x2, y2. Then, you have your player. You need to first find the players coordinates and if the players coordinates are < or > the x1 y1 etc variables, then store the objects coordinates in an array, and position the character at those coordinates, until the characters position is not affected by x1, y1, x2, y2 values.

I know this probably sounds a little confusing (like it has to most people Ive said it too) but I just wanted to give you some material to build on. Again, this is the long way, and the bug that I mentioned earlier (is it a bug?) may be fixed in later patches of pro.

I hope this helps you,
Regards,
RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Jan 2003 15:27
Collision occurs in DBPro whenever the images overlap, even though the overlap may be transparent colours.

I'd use the standard collision commands to detect the collision, but then add extra checks to to a distance check.

For instance, if sprite 1 has an distance from it's centre of 10 pixels, and sprite 2 has a distance from it's centre of 20 pixels, they will collide when there coordinates are less than 30 pixels apart.

It's not perfect, but it's all I can offer

Login to post a reply

Server time is: 2024-04-13 17:51:12
Your offset time is: 2024-04-13 17:51:12