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 / Trouble with dbSpriteCollision (I think)

Author
Message
jontepd
15
Years of Service
User Offline
Joined: 24th Feb 2009
Location: Sweden
Posted: 24th Nov 2009 11:10
Alright so I have encountered a problem in my asteroids game. In the function where I check if the asteroids are colliding with the laser shots I get a weird error message.



I've tried commenting out blocks of code until I found what is causing the problem and it seems that the dbSpriteCollision function is what gives me the error message.



Thanks in advance for any help
Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 25th Nov 2009 20:28 Edited at: 25th Nov 2009 20:36
You have a block commented out in your upload.. is that were the error is supposedly at?

if so, What is the declaration of the array size[]?

The error you are getting is usually a result of accessing an array beyond it's maximum index, you are using i to index it so does your array have les than 99 indexs?

Also if it only has 99 indexes, subtract 1 from i everytime you index it because you increment i up to 99 when the maximum index of an array containing 99 entries is 98 ( 0-98 )

If you upload a full source I could probably tell you exactly where the issue is but I don't understand what the tmp variable is used for.

hope this helps..

[edit] i think tmp is the id of the laser's sprite?

another thing is I do not see code deleteing the laser sprite if it doesn't collide, is that dealt with else were? you also have sz = 2 / 1 / 0 in their, i assume this is the size of the asteroids? if so, wher do you assign the size to the size array? I know that isn't what you asked but these are some things that alert me because I don't have the full source...

EYE R T3H +ick +ack +oe mester
jontepd
15
Years of Service
User Offline
Joined: 24th Feb 2009
Location: Sweden
Posted: 25th Nov 2009 22:35
The size of the array is 100. Yes, the tmp is the id of the laser sprites and the sz variable is the size of the asteroids. The laser sprites are deleted in another function. I can post you the entire source code tomorrow as soon as I get home.

Thanks for taking time to help me
jontepd
15
Years of Service
User Offline
Joined: 24th Feb 2009
Location: Sweden
Posted: 26th Nov 2009 17:00
As far as I know the problem is in the asteroids.cpp file, in the laserCollision function. From commenting out blocks of code it seems to be the dbSpriteCollision function that is causing something to go wrong..

I have also attached the entire project if you would like to download it and try it out for yourself.

Main.cpp:


Spaceship.h:


Spaceship.cpp:


Asteroid.h:


Asteroid.cpp:


Level.h:


LevelUp.h:


Lose.h:

Attachments

Login to view attachments
Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 26th Nov 2009 21:32 Edited at: 26th Nov 2009 21:47
grr lol I prefer zips XD but thanks I'll take a look

[EDIT]
I only get the error when clicking the red x during debug, I compiled in release mode and ran the exe and the game worked great. I played like 23 times on max volume and annoyed the heck out of everyone but it was fun good job 8-D sorry I cant solve the issue but like I said, the game runs perfectly fine.

I would however, pay close attention to the astroids after they are shot. It takes a couple seconds before the sprites of the smaller asteroids get pasted to the screen.

also, a way to replay the game without restarting the exe every time would be nice 8-P

Proud member of: DarkGDK.us
jontepd
15
Years of Service
User Offline
Joined: 24th Feb 2009
Location: Sweden
Posted: 27th Nov 2009 08:37
Hah, that worked!

Thanks a lot for your help
Paynterboi TicTacToe
16
Years of Service
User Offline
Joined: 23rd Dec 2007
Location: That one place
Posted: 28th Nov 2009 04:09 Edited at: 28th Nov 2009 04:10
Glad I could help.

Proud member of: DarkGDK.us

Login to post a reply

Server time is: 2024-11-24 17:31:02
Your offset time is: 2024-11-24 17:31:02