Whenever i hold down the keys or spam for a little bit everything stops working and I have to restart the app. Heres the code for the player
public class player1 extends Actor { GifImage gifRight = new GifImage("run1.gif"); GifImage gifLeft = new GifImage("run2.gif"); private int shootCounter=0, reloadDelay=50; private static int GRAVITY = 1; private int vSpeed; private int speed = 3; private int jumpCounter=0, jumpDelay=30; public void act() { checkKeys(); rightshoot(); leftshoot(); vSpeed += GRAVITY; setLocation(getX(), getY() + vSpeed); ground(); jump(); } public void checkKeys() { if (Greenfoot.isKeyDown("d")) { setImage(gifRight.getCurrentImage()); setLocation(getX() + speed, getY()); } else{ if (Greenfoot.isKeyDown("a")) { setImage(gifLeft.getCurrentImage()); setLocation(getX() - speed, getY()); } } } public void rightshoot() { shootCounter++; if(Greenfoot.isKeyDown("c")) { if(shootCounter>reloadDelay) { shootCounter=0; getWorld().addObject(new bullet(), getX()+20, getY()); Greenfoot.playSound("shoot.wav"); } } } public void leftshoot() { shootCounter++; if(Greenfoot.isKeyDown("x")) { if(shootCounter>reloadDelay) { shootCounter=0; getWorld().addObject(new bullet1(), getX(), getY()); Greenfoot.playSound("shoot.wav"); } } } public void ground() { if(isTouching(platform1.class)) { GRAVITY = 0; vSpeed = 0; } else{ GRAVITY = 1; vSpeed += GRAVITY; } } public void jump() { jumpCounter++; if (Greenfoot.isKeyDown("w")) { if(jumpCounter>jumpDelay) { jumpCounter=0; GRAVITY = -1; vSpeed = -15; Greenfoot.playSound("jump.wav"); } } } }