How can I change the way java.awt.Graphics draws my object? -


i'm creating game , have class player, class enemy, , class bullet. design of engine, logical draw graphics calling for (shape s : shapes { g.fill(s) } shapes existing list<shapes> of every object in game. works fine, bullet colored differently player, , player enemies. how can modify player, bullet, , enemy classes awt.graphics knows color draw them as?

edit: acceptable answer maybe involve finding way sort through shapes , separate class, although seems counter intuitive complete list existing.

you need use oop example

 interface shapes{   public color getcolor() ;  }  class player implements shapes{       public color getcolor() {         return color.red;      }  }  class enemy implements shapes{       public color getcolor() {         return color.green;      }  }  //  paint   (shape s : shapes} { g.fill(s.getcolor())}; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -