Bullets not moving down and left

Question:
I am making a KaboomJS game and while the bullets have no trouble moving up and right, they cannot move down or left at all. Why is this? What simple error do I have?


Repl link:
https://replit.com/@element1010/Battle?v=1#code/main.js
https://battle.element1010.repl.co

onUpdate("bullet", (b) => {
    switch(b.direction) {
      case "left":
        b.move(-BULLET_SPEED, 0);
      case "right":
        b.move(BULLET_SPEED, 0);
      case "down":
        b.move(0, BULLET_SPEED);
      case "up":
        b.move(0, -BULLET_SPEED);
    }
}

you are missing break statements under the b.moves. I might be wrong though.

3 Likes

because there aren’t break statements after the b.move statements, its going to the next case block and messing up what you want it to do.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.