Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How should i best implement this?

 
David McGratton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

This first post contains no code, just what i want to do and asking the best way to do this. I am familiar with swing however i havent used it much.
Future posts will be my code to be approved or critised.

It involves using timers within a game.

1) An item (eg loaf_of_bread) is on the screen
2) Player picks up item, item disappears , a timer is started eg 30 seconds.
3) After 30 seconds, the timer is destroyed and the item is remade and displayed.

My thoughts are, to create an "itemManager" class containing an array of "item". The player picking up the item calls "addItemToManager(variables go here)".
The item is added to itemManager array which initiates a timer which is used to regenerate the item on the screen, based on the variables.

I am after the most effecient method to do this.

Thankyou for reading the post,

Kindest Regards.
 
Paul Clapham
Sheriff
Posts: 21152
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then the best thing would be for you to list all the methods you have identified so far, and to evaluate each of them in terms of whatever "efficiency" means to you. You could post them here if you would like discussion about that process.
 
David McGratton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

This is what i have so far for me to be advised on.







Kindest Regards
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you need a timer in Swing, javax.swing.Timer is usually the way to go.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic