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! / Yet another wierd collision problem :(

Author
Message
Suicidal Sledder
20
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 17th Jan 2007 22:44 Edited at: 17th Jan 2007 22:46


Making a space invaders clone-ish and objects 101-105 are my bullets and object 3 is the enemy spaceship. In the IF statement I have my explosions/etc... Sometimes the lasers just go right through the enemy ships and it doesnt detect collision. I would think it was a problem in the code somewhere but it only happens like 3-4 times out of ten. It's really wierd. Any help would be cools. Thanks.

"See?!?! Port IS left and starboard is RIGHT!!" - Hobbes
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th Jan 2007 09:01
I'm guessing your bullet sprites are moving too fast, so sometimes never touch the enemy.

I would store the previous Y location of the bullet, and use the whole path as the collision source. Not sure how you'd do this with sprite collision, maybe have a dummy sprite that you scale and position for each bullet, one that will let you stretch the bullet out so it's the same length as the distance it has travelled.

''Stick that in your text and scroll it!.''
Suicidal Sledder
20
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 19th Jan 2007 00:07
I thought the same thing at first so I made a simple pause sub and can pause it and see quite clearly that the sprite are overlapping. Plus I'm only moving the sprites at 3-4 pixels per sync and the sprites are more than 10 pixels tall. I have nooo idea whats causing this... Any more help would be great. thanks

"See?!?! Port IS left and starboard is RIGHT!!" - Hobbes
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jan 2007 02:38
It's better to show the entire code so we can test it ourselves to find the problem.
Suicidal Sledder
20
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 19th Jan 2007 06:39 Edited at: 19th Jan 2007 06:40
well the ENTIRE code is rather lengthy (over 400 lines) and quite media heavy... Heres the code in context:



Dont give me crap about arrays and crap... I didnt think of using those until I was quite in depth to the project. (cuz I'm a noob and dont take advantage of arrays... actually... i do but i'm just a noob and forgot about them ) in any event...

the sprites 200-202 are the explosions that corrispond to each of the 3 enemy ships. I hide them after frame 15 so they only explode once and then disappear... That sort of brings me to another question. Sometimes, when I shoot a ship, It detects collision (plays sound, moves ship, adds score,etc...) but the explosion sprite doesnt show up. It happens rarely but enough to be noticable if u play the game enough.

Thanks for the 'elp

"See?!?! Port IS left and starboard is RIGHT!!" - Hobbes
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th Jan 2007 14:41
I'd look for a replacement collision system. There's a pixel perfect example somewhere, but really I think the problem is in DBPro's sprite collision check, you'd be far better off with something a bit more powerfull. Hell, you could make a better collision system with box collision than DBPro's sprite collision.

''Stick that in your text and scroll it!.''

Login to post a reply

Server time is: 2025-05-14 23:01:50
Your offset time is: 2025-05-14 23:01:50