• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

how to create bullet in java

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

logic:
create bullet class
store in arraylist
print in paint method

in bullet class i set the variables:
Bullet.java









this is the code where i need help. how to print bullets from arraylist.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 80652
476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic