All functions except for draw(), keyPressed(), etc. must be used for them to work.

I will show u the code in a min

Your code isn't working because side_to_side() and shoot() only run once. Put them in draw() like this:

function draw() {
  side_to_side();
  shoot();
}

thx it worked! But um how do I get the projectile to not show up until I press space?

    Zeldaria After defining shot, set its visible property to false.

    shot.visible = false;

    In shoot(), after pressing space, set shot's visible property to true.

    if (keyDown("space")) {
      shot.visible = true;
      shot.x = ship.x;
      shot.y = ship.y - 40;
      shot.velocityY = -8;
    }
    15 days later

    In a different game lab project, I'm trying to get a sprite to move to the right until it reaches x coordinate 300 and then move in the opposite direction until it reaches x coordinate 100, then it moves in the opposite direction and the whole thing repeats itself over and over and stuff; how do I do that?

    Chat