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 and priority

Author
Message
Fuzzzy Piggy
20
Years of Service
User Offline
Joined: 2nd Mar 2006
Location:
Posted: 14th Mar 2006 07:00
I've only been using DBP for about a week and a bit so please excuse any mistakes in this post!

OK, Im writing a simple kids game like the old sticker books. You have a static background and you have some stickers you can pickup any single instance of a sticker and place it anywhere in the background, simple enough.

OK, so the back is loaded the sprites are loaded. I switch off the mouse and I put a sprite in the place of the mouse pointer a big fat blue arrow, so the kids can see it. Now I have basically got a sprite hit for zero against the "mouse pointer" sprite so I know which sprite/sticker is being picked up and moved.

Here's the problem. The first sprite loaded is 1, 2nd is 2, etc. When I detect that sprite/sticker 1 is "touching" the pointer, I can click it and drag it around over all the other sprites no problem.

When I detect sprite number 2 (the second loaded sprite and assigned num 2), it can be moved over all other sprites OK, except over number sprite 1, at which point sprite number 1 seems to take priority and gets picked up! Now the same things happens if I pick up sprite number 3, 2 will take priority over three get picked up, if you "bash" number 2 into sprite 1 again, still holding 2, 1 gets picked up! So it appears the lower the loaded and assigned number, the higher the priority. If you pickup number 4 sprite, forget it, all other get priority.

I have tried to force priority on a sprite in my pickup code, but no effect. Code should be below.

Anyone have time to point me in the right direction? It's such a simple prog but this has been bugging me for about 7 hours now!

(Sorry about all that but I wanted to make it all clear)
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 14th Mar 2006 20:42
Please show your code in a "code box", such as this:



Because the source thing won't work from time to time.
Fuzzzy Piggy
20
Years of Service
User Offline
Joined: 2nd Mar 2006
Location:
Posted: 14th Mar 2006 20:56
Oops sorry. I have pplayed with it a bit longer and found that the order in which the sprite is loaded, seems to determine the priority , but according to the docs all sprites are loaded with the same priority, unless I;m talking out of my fundament!


Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th Mar 2006 00:44
The order in which you make the sprite is the priority in DB Classic. DB Pro has a command to change the order of priority.

However. You can cheat. You can make a brand new sprite every time you click on an image, and hide the old sprite image. So then you will always have the top sprite. Then paste the sprite, and delete the sprite.

However...However...

It is not totally a sprite priority problem. It is a collision routine problem as well. Just ignore your collision routine whilst you are dragging a sprite around the screen.

Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 15th Mar 2006 01:33 Edited at: 15th Mar 2006 01:34
Try the following...
where it says "CurrWorkSpr = sprite hit (30,0)" change it to
Fuzzzy Piggy
20
Years of Service
User Offline
Joined: 2nd Mar 2006
Location:
Posted: 15th Mar 2006 06:05
Jeez, the you guys are f***ing ace!

I;m still trying to get my head around thinking in DB time, ie getting your mind into the the fact that the looping is going on all the time and stuff is always happening!

Thank you very, very much indeed for the pointers and code snippet.

Login to post a reply

Server time is: 2026-07-01 21:22:22
Your offset time is: 2026-07-01 21:22:22