Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Angled Collision Issues
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DemonZ




PostPosted: Tue Nov 21, 2006 1:14 am   Post subject: Angled Collision Issues

Ok I am working on my 1 player part of my program, which is the user commanding a tank while enemy tanks try to cross to the bottom side of the screen, now I got all of that working exceptionally well, but the collision seems faulty nd I dont understand why, im using the correct formula, but for some reason it calculates the space in which the collision happens somewhere else, making the tank shells go through the enemy tanks sometimes without destroying them, so far im only concerned with the collision and another issue, and the other issue seems simple but not, there is a boolean variable that I have called 'player1ishooting' which is true if the fire button is pressed, and will go false if it is not, my problem: once the bullet has been fired, after it reaches a certain distance, the boolean will turn false and the bullet will die out or disappear, but, if you hold the fire button continously, after the bullet hits a tank in the collsion area (if it does even) it will calculate the damage and the tank will disappear, but the bullet will continue to travel even after the bullet hit the tank causing a collision and the variable that checks if firing or not, is switched to false. If anyone can help me resolve these issues (I think I might know what is causing the firing problem) it would be a huge help. Here is the file, the controls are arrow keys to move and NUM 0 or insert to fire.


P1 Game Problem.zip
 Description:

Download
 Filename:  P1 Game Problem.zip
 Filesize:  381.8 KB
 Downloaded:  54 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
DemonZ




PostPosted: Wed Nov 22, 2006 11:50 pm   Post subject: (No subject)

sorry never mind I strangly found the solution to my problem, what a waste.... Sad Sad
NikG




PostPosted: Thu Nov 23, 2006 11:53 am   Post subject: (No subject)

Why not let everyone know how you solved this in case anyone ever has the same issue?
DemonZ




PostPosted: Thu Nov 23, 2006 8:26 pm   Post subject: (No subject)

ok for people who are curious to know because im sure there are people who were having problems with this before or may be experiencing it, this is my solution to correct myself. What happened is that my enemyx2 was not updating, therefore could not accumulate collision, so I changed enemyx2 into a new value
code:

enemyx2 := enemyx + picheight % pic.height of picture
enemyy2 := enemyy + picwidth

this way the enemyx2 and enemyy2 will constantly update with enemyx and enemyy, then I changed the collision detection to something like this.
code:

elsif P1Bx > enemyx (i) and P1Bx < enemyx2 (i) and P1By > enemyy (i) and P1By < enemyy2 (i) then % If the shell hits a tank

so now im using rectangular collision detection for the tanks which constantly update their coordinates, making the collision very accurate.


I think the next time I run into a problem ill do what my teacher says "Research and EXPERIMENT!" sorry for making a seemingly wasteful topic to discuss everybody.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: