well, a very wierd problem
hi i'm new in these forums,
and i have a very wierd problem in my very first java game-applet.
well, it is a shooting game(i dont really like shooting games but they are easier to program)
and the problem occurs not when compiling nor activating, but when your bullet approches an enemy spacecraft.....
till now it worked 100%. i had a little spaceship that it's y was constant and the x varies by the mouse, you could shoot by left clicking, and they were enemies(though they werent affected by your shots..)
the enemies were contained in a Point array, that contained their coordinates.(by the way it was a single-class program, and i know i'm not getting the best of object oriented programming)
to detect collision between the enemies and your bullet(only one bullet can be active at the same time)
i created a new int method used to calculate the distance between two points by using Pythagoras' technique(written in the tutorial "java by example" section 5 page 8 i think)
...by the way, my JCreator didnt listed that method in that list on the left, very odd.
now the main problem is that when you shoot an enemy, one of the following will happen :
1.the enemy will be destroyed as i programmed it to.
2.the enemy will be destroyed only if i'll shoot it a pixel or two left to its center(almost always on the leftmost enemy)
3.the enemy could not be killed
4.when i hit the side of the enemy(especially on its right side), the enemy beside it destroyed istead of itself....
i used the same distance calculation for ALL of the enemies(i used a for loop), and i know my numbers are correct(the maximum distance of collision).
you might think that this problem was something that i made up, but i SWEAR it true....
:( can you help????
and i also attached the full code(commented) in a txt file.
n.b. i'm using JDK 1.4 on winxp home edition
nick:confused: :confused: :confused: