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.

Dark GDK / Simple sprite collision doesn't work for some strange reason.

Author
Message
Wizz
14
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 19th Nov 2011 21:12 Edited at: 19th Nov 2011 21:15
I'm making a 2D game where little sqares are shot from the middle of the screen and the player controlls a pad that rotates around the center of the screen in an attempt to catch the squares. I'm having some trouble with the collision. I split it into two parts. In the first part I calculate when the squares hit the pad and if they do, the square sprites are deleted. This part works. In the second part I calculate when the squares leave a certain distance outside of the game area. (wich is a circle). This is why I used a circle function: x^2 + y^2 = radious^2.
And when the sqares leave this circle, they are deleted. This also works. Then i added a second command to the second part, wich displays a sprite when the squares leave the circle. But the sprite is displayed instantly (I am going to use this for a "game over" screen when the square leaves the circle, so you get a "game over" screen before you even start playing). I have no idea why this is happening.

here is the collision part of the code:

The squares have IDs ranging from 2-101.

This is the code where I make the squares:

I call the squares goods so good_ID is the Id of a square. I have the display set to 800x600 so x=400,y=300 is the center of the screen.
Thanks in advance!

I just love the smell of code in the morning...
Wizz
14
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 20th Nov 2011 17:27 Edited at: 20th Nov 2011 20:55
I know it's a very vague question and maybe hard to understand.
let me sum it up. It appears that when I make the sprites with dbSprite and put them in the center of the screen they somehow not in those coordinates for a short period of time and the collision function displays the "game over" sprite. Is it possible that with calling for instance dbSprite(1,400,300,1) it puts the sprite into the x=0 and y=0 position before it moves it to x=400 and y=300? if it's not that than i have no idea what else it could be.

EDIT: Sub-question (just answer this atleast) What does the program return if i write dbSpriteX(1); and a sprite with an ID of one does't exist yet?

Second EDIT: Ignore this i'm solving the problem gradually. Am going to make a new post about it that is not so vague.

I just love the smell of code in the morning...

Login to post a reply

Server time is: 2024-03-29 05:57:15
Your offset time is: 2024-03-29 05:57:15