Translation of the Origin

Translation of the Origin: This is a neat little trick that lets you view an image which is larger than the applet area. It may be useful in certain kinds of games which require a large playing area.

PLACE THE FOLLOWING INSIDE YOUR INIT METHOD: w=i.getWidth(null); h=i.getHeight(null); addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e){ if(e.getKeyCode() == KeyEvent.VK_DOWN){ ty-=5; if(ty<-120) ty=-120; repaint(); } else if(e.getKeyCode() == KeyEvent.VK_UP){ ty+=5; if(ty>0) ty=0; repaint(); } else if(e.getKeyCode() == KeyEvent.VK_RIGHT){ tx-=5; if(tx<-100) tx=-100; repaint(); } else if(e.getKeyCode() == KeyEvent.VK_LEFT){ tx+=5; if(tx>0) tx=0; repaint(); } else showStatus("Unrecognized Command"); } }); PLACE THE FOLLOWING METHOD BEFORE YOUR PAINT METHOD: public void update(Graphics g){ g.clearRect(0,0,d.width,d.height); g.translate(tx,ty); showStatus("Translating Graphics: "+tx+", "+ty); paint(g); } IN YOUR PAINT METHOD ONLY DRAW THE IMAGE AND NOTHING MORE.