• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I use a class such as this one to improve game structure and code reuse ?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

How do I use a class such as this one, for each entity of a game?
I have the standard game loop and Player class and so forth but the overal game infrastructure is of poor quality. Can you please help me understand how to do so. THankyou


 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally speaking, you are doing this backwards.

You don't write a program by saying "How do I use this technology to make my program better/work". That's like saying "how do I use a socket wrench to improve my car?"

A socket wrench MAY help you improve your car...but if your biggest problem with your car is that the tires are flat, the socket wrench is NOT going to help you.

 
Ranch Hand
Posts: 140
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's what I would do:

I would make an "Animatable" interface, and have two methods, update() and draw(Graphics2D g2). Make each of your basic objects implement this interface. Then your game loop can have a single array of ALL your animatable objects, and call their update methods and then their draw methods as part of the game loop cycle.
 
reply
    Bookmark Topic Watch Topic
  • New Topic