Results 1 to 9 of 9
Thread: Collision in j2me
- 06-24-2011, 01:56 PM #1
Collision in j2me
why collision not happen in this code-
if (((AppleX >= OctoXpos) && (AppleX <= OctoXpos + imgBell.getWidth()))
|| ((AppleX + imgApple.getWidth() <= OctoXpos) && (AppleX + imgApple.getWidth() >= OctoXpos + imgBell.getWidth()))
&& ((AppleY >= OctoYpos) && (AppleY <= OctoYpos + imgBell.getHeight()))
|| ((OctoYpos + imgBell.getHeight() <= AppleY) && (OctoYpos + imgBell.getHeight() >= AppleY + imgApple.getHeight()))) {
}
- 06-24-2011, 02:22 PM #2
Try debugging the code by printing out the values of the variables and the results of the all the sub conditions.
Give the code values that are collusions and values that are not and compare the results to see why the code does not work when there is a collusion.
- 06-24-2011, 02:28 PM #3
I have done this but no result found.condition is correct or not?
- 06-24-2011, 02:33 PM #4
Then you must have missed some of the combinations of conditions.
Make a table of all the conditions with all their values and make sure you send all the values to your code.
Run all the values thru your conditions and record the results.
When the results are wrong, look at the logic and see which tests are wrong.
If you are having problems, write a program that executes the code and passes it various combinations of values and post it with a driver that sends the code values that should be a collusion and values the are not a condition.
- 06-24-2011, 03:30 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Build a wall around Donald Trump; I'll pay for it.
- 06-24-2011, 04:35 PM #6
imgbell.getWidth() point to -> OctoWidth.
And imgApple.getWidth() point to -> AppleWidth. and i m trying to collision b/w Apple and Octopus.
- 06-24-2011, 04:39 PM #7
Here is how I suggest you find the problem with your code:
Make a simple method that executes your if test and returns true or false.
Then pass that method values that are not collisions and values that are collisions.
Then break the if with all its conditions up into separate sub conditions and print out the results of each sub condition.
Then look at the output to see which sub test is wrong.
- 06-24-2011, 04:54 PM #8
i also do this with boolean but no result.but thanks for support.i will check again. :)
- 06-24-2011, 04:58 PM #9
Similar Threads
-
2D - Collision messed up
By überfuzz in forum New To JavaReplies: 0Last Post: 06-22-2011, 10:20 PM -
Collision in GUI 2d Game help
By heysayjump in forum New To JavaReplies: 7Last Post: 03-14-2011, 03:01 AM -
Really Need help with some collision detection
By Harwad in forum New To JavaReplies: 1Last Post: 01-23-2011, 01:38 AM -
Collision
By shadycharacter in forum New To JavaReplies: 0Last Post: 04-13-2010, 10:58 PM -
Sending J2ME application by blue tooth (by J2ME application). Very URGENT!!!
By maruffaiz in forum CLDC and MIDPReplies: 0Last Post: 04-22-2009, 02:30 PM
Bookmarks