@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_W) { p.moveUp(); } else if (e.getKeyCode() == KeyEvent.VK_A) { p.moveLeft(); } else if (e.getKeyCode() == KeyEvent.VK_D) { p.moveRight(); } else if (e.getKeyCode() == KeyEvent.VK_S) { p.moveDown(); } }
public void keyReleased(KeyEvent e) { p.stopMovement(); }
public void paintComponent(Graphics g) { g.drawImage(bg, 0, 0, getWidth(), getHeight(), this); p.render(g); repaint(); }