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! / Noob needs 2d Collision Help

Years of Service
User Offline
Joined: 26th Mar 2011
Location: United Kingdom
Posted: 26th Mar 2011 20:55
Hey guys I'm all new to the programming world and have been studying basic programming at college I have developed a basic 2d asteroids game but can not get a collision and death splash screen to work what id to happen is the asteroid and ship collide and the death screen appears here is my code any help would be appreciated.

My code:

Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 27th Mar 2011 02:51
Hi, welcome to the forums. The only thing I can suggest is using the 'sprite collision' command instead of 'sprite hit' command.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 29th Mar 2011 05:20 Edited at: 29th Mar 2011 20:15
In the handleCheckForCollision function, you are using SpriteNo in your for / next loop. Within that function, if there is a collision, you jump to the handleendgame function, which also uses SpriteNo in the for / next loop. I don't consider jumping out of a loop in a function to another function a good programming practice, especially when the for / next loops share the same name.

Why don't you check for collisions against the ship using 0, so it will report all collisions, and then check to see if the collision is one you are looking for? Example:

EDIT: Wondering if the OP will show up......

Years of Service
User Offline
Joined: 8th Jun 2010
Location: Serbia
Posted: 9th Jun 2011 18:43
Unhelpful Titles

Please do not simply write "Noob Question", "I am a newb", "One Noobie Question", "A question", "Please help", "This isn't working" or anything similar as the title of your post. We have a search facility, and meaningless titles do not help others find answers to their questions. It will also help you to get quicker responses if people have an idea of your thread content

Login to post a reply

Server time is: 2023-06-02 16:45:35
Your offset time is: 2023-06-02 16:45:35