I am trying to put keylistener and move the "download.jpg" to the left and right. I put the ; but the error says that ; is needed. Did I do anything wrong?? What do I need to fix?? Do I need to add anything?
public class GameScreen extends JPanel implements KeyListener {
public BufferedImage bg;
public BufferedImage ci;
public JLabel lab;
int ciXp = 250;
int ciYp = 665;
int ciWidth = 330;
int ciHeight = 745;
public GameScreen()
{
gui();
}
public void gui()
{
try{
bg = ImageIO.read(new File("supermario.jpg"));
ci = ImageIO.read(new File("download.png"));
}
catch(Exception ex){
}
}
public void paintComponent(Graphics g)
{
g.drawImage(bg,0,0,null);
g.drawImage(ci,ciXp,ciYp,ciWidth,ciHeight,0,0,ci.getWidth(),ci.getHeight(),null);
}
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_LEFT) {
int ciXp-10;
}
if (key == KeyEvent.VK_RIGHT) {
int ciXp+10;
}
}
}