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! / Collision Collision Collision

Author
Message
Code Stealer
20
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 24th Feb 2004 11:15
Oh, how much pain can there be in one program? Im using a sprite which is 60x60, but not all of the space is being used(check out http://homepage.ntlworld.com/curtisfell/uber/ for the sprites) as Ive used black, which gets displayed as invisible, colour 0, the alpha channel. However, it seems that there is no difference between sprite hit and sprite collision. How do I make sprite collision pixel perfect?

GIve me more power!
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Feb 2004 11:26
DBPro has cr**py sprite collision. It uses the whole box. DB Classic has perfect sprite collision. There may be a DLL for DBPro to fix the collision problem. I didn't mention it earlier because you said that you were going to use array collision.

Pincho.

Code Stealer
20
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 24th Feb 2004 11:34
Doh! Where can I go to find out about this "DLL" of which you speak...WHat is a dll?

Anyway, why call it "pro"if it doesnt do proper sprite collisions? How rubbish is that? Im very anoyed, in fact I feel cheated. Im gonna write to the manufacturer...

GIve me more power!
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Feb 2004 11:55 Edited at: 24th Feb 2004 11:55
It is annoying. If you type collision in the search box on here you will find all sorts of solutions. Maybe something will help you. The search box is right at the bottom of the page.

UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 24th Feb 2004 18:37
DLL = Dynamic Link Library

The search continues.

Current project - A space game
Code Stealer
20
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 24th Feb 2004 20:19
Well, Ok I found this piece of code, but being new to this Im not sure how Im supposed to intergrate it into a program ive written. For example, I want to check a collision between sprite 323 and 501, what do I do?

Sorry to be so stupid!

GIve me more power!
Code Stealer
20
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 24th Feb 2004 20:19
function SpritePixelCollision(sprite1 as integer, sprite2 as integer)
local Sprite1Base as dword
local Sprite2Base as dword
local Sprite1Addr as dword
local Sprite2Addr as dword
local V as dword

if sprite collision (sprite1, sprite2) > 0

make memblock from image 255,sprite image(sprite1)
make memblock from image 256,sprite image(sprite2)

Sprite1Base=get memblock ptr(255)
Sprite2Base=get memblock ptr(256)

XPos1=sprite x(sprite1)-sprite offset x(sprite1)
YPos1=sprite y(sprite1)-sprite offset y(sprite2)
Width1=*Sprite1Base
inc Sprite1Base, 4
Height1=*Sprite1Base
inc Sprite1Base, 11

XPos2=sprite x(sprite2)-sprite offset x(sprite2)
YPos2=sprite y(sprite2)-sprite offset y(sprite2)
Width2=*Sprite2Base
inc Sprite2Base, 4
Height2=*Sprite2Base
inc Sprite2Base, 11

if XPos2 > XPos1
XStart1=XPos2-XPos1
XStart2=0
XOverlapSize=(Width1-XStart1)-1
if XOverlapSize >= Width2 then XOverlapSize=Width2-1
else
XStart2=XPos1-XPos2
XStart1=0
XOverlapSize=(Width2-XStart2)-1
if XOverlapSize >= Width1 then XOverlapSize=Width1-1
endif

if YPos2 > YPos1
YStart1=YPos2-YPos1
YStart2=0
YOverlapSize=(Height1-YStart1)-1
if YOverlapSize >= Height2 then YOverlapSize=Height2-1
else
YStart2=YPos1-YPos2
YStart1=0
YOverlapSize=(Height2-YStart2)-1
if YOverlapSize >= Height1 then YOperlapSize=Height1-1
endif

XStart1=XStart1*4
XStart2=XStart2*4
Width1=Width1*4
Width2=Width2*4
for YOffset=YOverlapSize to 0 step -1
Sprite1Addr=Sprite1Base + ((YOffset+YStart1)*Width1) + XStart1
Sprite2Addr=Sprite2Base + ((YOffset+YStart2)*Width2) + XStart2
for XOffset=XOverlapSize to 0 step -1
v=*Sprite1Addr
if (v && 0xff000000) <> 0
v=*Sprite2Addr
if (v && 0xff000000) <> 0
delete memblock 255
delete memblock 256
exitfunction 1
endif
endif
inc Sprite1Addr, 4
inc Sprite2Addr, 4
next XOffset
next YOffset

delete memblock 255
delete memblock 256
endif
endFunction 0

GIve me more power!
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Feb 2004 21:14
Just stick it at the bottom of your program, and this checks for a more accurate collision......I think.....



If SpritePixelCollision(323,501)=1

Whatever you want to do about it.

Endif

Cros Jovil
20
Years of Service
User Offline
Joined: 27th Jan 2004
Location:
Posted: 25th Feb 2004 00:06
mayhap you guys can use sprite hit it calculates collision for only the non transparent pixels it seems to work but i'm not sure if it is in dbpro I learned it in 700 page beginner book thingy
Code Stealer
20
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 25th Feb 2004 00:35
Ill try what you say pincho

As for Cros, thats DBClassic, not DBpro. They changed it.

GIve me more power!
Code Stealer
20
Years of Service
User Offline
Joined: 12th Feb 2004
Location:
Posted: 25th Feb 2004 00:57
I tried it, but I couldnt get it to return a value of 1, so I must be making an error somehwere...

GIve me more power!

Login to post a reply

Server time is: 2024-05-18 02:27:30
Your offset time is: 2024-05-18 02:27:30