Can someone help me please with this problem?
I've made a character which can shoot bullets when pressing the spacebar.
it can jump to the right (right+up) and shoot at the same time, but it wont shoot when I jump to the left (left+up)
If you need more code, please ask me.
To make the shooting code understandable, when the player is looking to the right, the bullets should travel to the right and when facing to the left, i made it so it should
public void move() { if(Greenfoot.isKeyDown("right")) { setLocation(getX() + speed, getY()); facingLeft = false; animation(); } else if (Greenfoot.isKeyDown("left")) { setLocation(getX()- speed, getY()); facingLeft = true; animation(); } if(Greenfoot.isKeyDown("up") && isJumping == false) { vSpeed = jumpStrength; fall(); } }
public void shoot() { // player looks to the left if (facingLeft == true) { if (Greenfoot.isKeyDown("space")) { getWorld().addObject(new Bullet("a"), getX(), getY()); } } // player looks to the right if (facingLeft == false) { if (Greenfoot.isKeyDown("space")) { getWorld().addObject(new Bullet("b"), getX(), getY()); } } }