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! / Silly 2D issues

Author
Message
John12321
21
Years of Service
User Offline
Joined: 15th Dec 2004
Location:
Posted: 16th Dec 2004 00:54
I have only recently obtained DBPro (3 days ago) and im having trouble with a couple of silly issues.
I can't seem to track the bottom right corner of a Sprite. I have tried using
xright = x + Sprite Width(1)
but it doesnt work at all.
Could someone tell me a nice way to keep track of the BR corner.

Something I was wondring about, which I have seen mentioned on this forum is working with memory rather than using Sprites. This sounds intriguing, so could someone give me a quick rundown of what this would entail.

Thanks in advance for any and all advice
John12321
21
Years of Service
User Offline
Joined: 15th Dec 2004
Location:
Posted: 16th Dec 2004 02:47
C'mon someone please help
the_winch
23
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 16th Dec 2004 04:21
Use xright = sprite x(1) + sprite width(1)

example


Quote: "this is not a quote"
John12321
21
Years of Service
User Offline
Joined: 15th Dec 2004
Location:
Posted: 16th Dec 2004 05:49
This is gonna sound really stupid, but i can't get co-ordinate based collision detection to work.
What i am trying to do is set out a pair of x and a pair of y values, which the x and y values of the sprite cannot be between.
The code below has worked for boundary walls, but for walls within my scene it will not work, The sprite simply passes straight through the wall. I have tried making the walls into sprites and using the if sprite hit command, but this caused the program to run VERY slowly.
Could anyone suggest a better way in which i could implement this feature, or even just to get this way to work. Thanks in advance for any advice.
Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 29th Dec 2004 06:20
I know this one's old, but nobody seems to have replied.

It's all math. If x1 y1 are the coordinates of the top left corner of object 1 and x2 y2 are object 2, then:

IF x1 > x2-sizex AND x1 < x2+sizex AND y1 > y2-sizey AND y1 < y2+sizey THEN collision

where sizex and sizey are the dimensions of the objects. If the above condition returns TRUE then the objects are colliding.

This only works for perfectly square objects that are the same size. If they're not square then it'll still work, but it won't be pixel perfect detection. For most purposes, it's good enough. If they're different sizes you'll have to play with the +'s and -'s in the algorithm to get it right.

Login to post a reply

Server time is: 2026-06-11 13:13:55
Your offset time is: 2026-06-11 13:13:55