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.

DarkBASIC Professional Discussion / why do sprites pile up in the corners?

Author
Message
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 25th May 2011 17:19 Edited at: 27th May 2011 11:32
EDIT FIXED!!
i changed the integers to floats and voila everythings fine.


in some of my games i have noticed an anoying "piling" effect when i move sprite outside the screen. especially in the upper and left sides of the screens. It looks like the sprites are "reluctant" to cross the border. also this occurs when i do not use the move sprite command at all! (i only re sprite it in the new coordinates) this is really anoying as it totally destroys my towerdefence game as the towers start to stack on each other if i scroll the map a litle please help!

i use d3d and matrix1 dlls although i only use one command from matrix1, draw sprites manual. could that be it?
EDIT
it is not the matrix1 commands
EDIT

after testing some more it seems that the effect only occurs when the sprite is "moving" slowly. can it be a rounding problem?
if i slowly move all of the sprites towards the upper left corner they will all end up being exactly in the same position (0,0) and will not move unless i increase the speed!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th May 2011 17:44
We'd need to see some code.

There's no reason why it should do that, no reason why it can't be fixed - so post up a little code and we'll see what's up.

Just a quickie though - How are you working out the new sprite location? - based on an angle and speed?, or a vector?. The main reason I ask is that it sounds weird that sprites are attracted to 0,0 - you aren't using curvevalue for positioning are you?

Health, Ammo, and bacon and eggs!
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 25th May 2011 17:50
A screen shot and some sample code would be helpful.. At a guess, it sounds a bit like the screen isn't being cleared, which would cause multiple 'slodges' of the sprites (and anything else) to appear as if they're being drawn, when they're not over something.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th May 2011 20:20 Edited at: 25th May 2011 20:21
It sounds like you've answered your own question. If you "move all of the sprites towards the upper left corner they will all end up being exactly in the same position (0,0)" then it's doing exactly what you told it to do. Don't move them all to 0,0 and they won't accumulate there.

It could be partly because of MOVE SPRITE. A sprite that has not been rotated moves straight up so if the non-rotated sprite is just off the screen to the left it'll always move up with MOVE SPRITE... and if you have it stop moving at 0 it'll be just off the screen at 0.

noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 25th May 2011 21:34 Edited at: 25th May 2011 21:44
i dont use move sprite.
i re position the objects based on how far the mouse is from the center of the screen. like this kind off


that was the simplified version.
heres some real code :
sw = screen width
sh = screen height
mx = mousex()
my = mousey()



images :
the first one is before they got into the corner the second one is in the corner the third is showing them all pretty stacked and in the last one most of them are right on each other
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th May 2011 22:29
Ahh, you need some ship on ship collision. Maybe the built in sprite collision is enough, as they are boxes anyway. I suggest looking into that, and some 2D box collision techniques.

Health, Ammo, and bacon and eggs!
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 25th May 2011 22:31 Edited at: 25th May 2011 22:32
to get the spaceships to your mouse?
Shouldn't it be more like:


what's your screen width even got to do there?

[edit]
with your current code, your ships will all want to move in the same direction (parallel to each other). I'm guessing what happens is that your mouse is in the top-left part of your screen, so all the ships move to the top left, and you have it set up so their position can't be less than 0, so the edges of the screen funnel 'em all into the corner. Could that be accurate?


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 26th May 2011 22:04
they are supposed to move paralel to each other not to go to the mouse but to the dirextion of it. like a scrolling camera. i dont think i should need any colllision as they should all move with the same speed in the same direction but thanks
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 26th May 2011 22:04
and just to clarify this stacking only occurs while they are ON the border not while getting there
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 26th May 2011 22:08
so they're all moving to the same point ?

noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 26th May 2011 22:22 Edited at: 26th May 2011 22:23
well yes and no
yes in the corner they do but not while they are elsvwhere and in the corner they shouldnt

no in the same direction

the code moves the sprites in the direction of the mouse with a speed depending on how far the mouse is from the midle of the screen
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 27th May 2011 10:34
Right... so they reach an edge of the screen, you limit their position to the edge of the screen, and then they pile up into the corner?


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 27th May 2011 11:28 Edited at: 27th May 2011 11:29
no i dont limit anything. they should just pass over the edge but instead they seem reluctant to do so

ok here is a working code that demonstrates the problem. no media required.



edit

you see it will pass over the border if the cammovex# value is large enough but not othervise
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 27th May 2011 11:31
Ok i found a solution. weirdly as i changed all the integers to floats the problem dissapeared. so it was some sort of rounding problem?
the code above has the problem if anyone wants to check it out

Login to post a reply

Server time is: 2026-07-11 04:24:30
Your offset time is: 2026-07-11 04:24:30