Scaling Graphics (Beginning Java Programmer)

I am Chris. I am fairly new to coding, I don’t know many terms, this is my third and most successful attempt at learning Java. Yeah, It didn’t work out so much was I was younger. Anyhow, I am trying to create a game but I’m having a slight problem.

I made a 16 x 16 image as my character, however – as expected- it shows up as fairly small. This is what it looks like

I have absolutely no clue how to make it larger.

Here is the code:

package code;

import java.awt.Graphics;

public class Skeleton extends Loop{ //Should extend Applet?

private static final long serialVersionUID = 1L;

public void init(){
Thread th= new Thread(this);
offscreen = createImage(120,160); // 120, 160
d = offscreen.getGraphics();
addKeyListener(this); //15:43
public static final int HEIGHT = 120; //Original Height/Width= "120 x 160"
public static final int WIDTH = 160;
public static final String TITLE= "Test Game BETA";
public static final int SCALE = 3;

public void paint(Graphics g) {
d.clearRect(0, 0, 160, 120); //Error Here, Scale perhaps? -Disregard //0, 0, 160, 120
d.drawImage(him, x, y, this);     //12:17
g.drawImage(offscreen, 0, 0, this);
public void update(Graphics g){

} //Finished at 15:33 ERROR w/ the circle -Fixed
//2D Tile Engine Must be Created


The drawImage function can take a destination size, and it will scale your image for you:

drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)


Leave a Reply

Your email address will not be published. Required fields are marked *