I am wondering if there is a way to check for collisions between two java AWT Graphics objects.
Norm Radder wrote:
I have taken out some misc code to attempt to shorten the post
Could you fix the code so that it compiles and executes for testing?
Where are the locations of the two objects stored?
Norm Radder wrote:Can you post code that demonstrates the problem. The code from github does not show any collisions when it executes without any interaction from the user.
Carey Brown wrote:Would this work?
Norm Radder wrote:The code needs lots of debugging to find all the bugs before worrying about the collision logic.
For example,
the enemy body does not reverse when touching all 4 boundaries.
Current code does not use the enemyX and enemyY values for displaying its location.
And more
When I execute the code, I do not see any collisions between the two moving bodies.
What do I need to do to make the moving bodies collide?
Can you change the code so that the two bodies collide very soon after the program starts?
How are you debugging the code to see what the x,y values are for both of the moving bodies so you can see what the values are when a collision is missed? I suggest adding some print statements that print the x,y values for each moving body.
Norm Radder wrote:There are no comments in the code saying what directions are valid for the enemy body. Is it only 'U' and D?
Also there are no comments regarding what value of x the enemy should have. The code appears to use the center column.
What about my other requests for the code?
When I execute the code, I do not see any collisions between the two moving bodies.
What do I need to do to make the moving bodies collide?
Can you change the code so that the two bodies collide very soon after the program starts?
How are you debugging the code to see what the x,y values are for both of the moving bodies so you can see what the values are when a collision is missed? I suggest adding some print statements that print the x,y values for each moving body.
How do you get a collision?my collisions are not working
Norm Radder wrote:
How do you get a collision?my collisions are not working
When I test the program, I would like to see a collision almost immediately after the program starts.
Currently when I execute the program the two bodies do not collide. One just runs off the screen.
Can you change the code so that the two bodies start near each other and have paths that cross so that there is a collision very soon after the program starts?
How does the code use the enemyX array? I don't see that it is used when the body is drawn.
I replaced ...
The collision never happens.the program should stop and say "Game over" when ...
Norm Radder wrote:
I replaced ...
Then the code that tests for collisions needs to know and use that so it does not use enemyX.
The collision never happens.the program should stop and say "Game over" when ...
What does a tester need to do to make a collision happen? I do not get a collision when I execute the code.
Consider Paul's rocket mass heater. |