0

I am creating a simple game, and I would like to give my player different skins (textures). However I am struggling to do so. Every object in my game uses render(Graphics g) but for textures the easiest way I could find was using a bufferedImage. Now the way I would do it now, would require render(Graphics2D g2d) so I am not quite sure how to do that since the abstract is also for enemies and I just want them a solid color. Maybe it just works to convert them over? I am new to programming so sorry if it is simple.

    @Override
    public void render(Graphics g) //What I have right now
        { 
        g.setColor(Color.blue);
        g.fillRect((int)x, (int)y, 32, 32);
    }

    public void iWantThis(Graphics2D g2d) //What I would like
    {
        BufferedImage img = getImg(); 
        g2d.drawImage(img, (int)x, (int)y, 32, 32, null);
    }

1 Answers1

0

I just did Graphics2D g2d = (Graphics2D) g;