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
Post a Comment