jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes how to create bullet in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to create bullet in java" Watch "how to create bullet in java" New topic

how to create bullet in java

sudde gameeef

Joined: Mar 21, 2013
Posts: 19
i create a player and i want him to shoot bullet. i understand the logic but i need some help with it. my bullet will just be rect in paint method.

create bullet class
store in arraylist
print in paint method

in bullet class i set the variables:

this is the code where i need help. how to print bullets from arraylist.
Tony Docherty

Joined: Aug 07, 2007
Posts: 2839
So what exactly is your problem?
One thing I have noticed is you haven't shown any code to move the x,y position of the bullet every n milliseconds. BTW to do this your bullet class will need to know what direction the bullet is traveling in unless you can only fire in one direction. You may also want to record velocity and/or distance traveled unless your bullets go forever at the same speed.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46412
Never use == true and == false.
Why is the List inside the Bullet class? Do bullets hold information about other bullets in real life? I think that List belongs inside a different class, maybe Magazine or Bandolier.
I agree. Here's the link: http://aspose.com/file-tools
subject: how to create bullet in java
jQuery in Action, 3rd edition