user3611818
user3611818

Reputation: 247

putting multiple objects into a arraylist and draw them

I have just learned to use arraylist so be nice :P .

I wonder how i can put a few objects (like a circle or a square) into the arraylist and draw them out on a jpanel so all of them stay. I know how to draw one thing but i'm trying to make a game and would like to have multiple things drawn at the same time.

All answers appreciated!

Upvotes: 0

Views: 841

Answers (1)

yossico
yossico

Reputation: 3521

I dont femiliar with JPanel and swing but a bsic algorithm will be:

  1. add all the wanted objects to arraylist (or an other data stracture)
  2. Start Loop
  3. for every item on the data stracture - item.Draw
  4. update all locations
  5. return to loop start

Upvotes: 2

Related Questions