[gameprogrammer] need help with bullets....
- From: Anom <adeanom@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Thu, 14 Apr 2005 15:30:14 +0700
hi there all of you,
right now i'm try to develop my side scrolling spaceship game in java. and i
got a little bit of trouble with the bullet shot by an enemy to the player.
the problem is, the speed of the bullets shot by an enemy are very fast if
the player position is far, but if the position is close to the enemy then
the bullet speed is ver very low...
here's what my code looks like....
/** shoot the player... */
vectorX = player.getX() - ufos[i].getX();
vectorY = player.getY() - ufos[i].getY();
if((ufos[i].getGunCoolTime() == 0)) {
for(int j = 0; j < shots.length; j++) {
if((shots[j] == null)) {
shots[j] = ufos[i].shoot(vectorX, vectorY);
shootSound.play();
break;
}
}
} else {
ufos[i].subsGunCoolTime();
}
and on the method for shoot is just merely create a new Shot instance.
Here's my method of moving the bullet shot by an enemy :
xPos += vectorX / BULLET_SPEED;
yPos += vectorY / BULLET_SPEED;
maybe you'll ask me why am i dividing the vector with BULLET_SPEED, because
if i'm not do that, than i merely can't see the bullet shots by the enemy
because of the high speed.
i hope i have submitted the right amount of information for anyone here to
help me.
TiA
--
Ade Anom A
[http://www.a3rex.info]
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: need help with bullets....
- From: Olof Bjarnason
- [gameprogrammer] Re: need help with bullets....
- From: Dominic McDonnell
Other related posts:
- » [gameprogrammer] need help with bullets....
- » [gameprogrammer] Re: need help with bullets....
- » [gameprogrammer] Re: need help with bullets....
- » [gameprogrammer] Re: need help with bullets....
- » [gameprogrammer] Re: need help with bullets....
- » [gameprogrammer] Re: need help with bullets....
- [gameprogrammer] Re: need help with bullets....
- From: Olof Bjarnason
- [gameprogrammer] Re: need help with bullets....
- From: Dominic McDonnell