H
heisenburg

    • Jun 1, 2023
    • Joined May 31, 2023
    • 0 best answers
    • 0 points
    • 0 Following0 Followers
    • Ⓒ 9
    • So basically, i just got help from chatgpt to make my code work, i guess i dont need this thread anymore

    • ackvonhuelio im not progamming on ipad, i was just replying to people on ipad, im on my computer now

    • heisenburg I can’t really look right now, I’m currently on my school iPad, but I know it’s set as a variable

    • This is my first post in the code.org forum. I made this account to ask a coding question.

      I am currently trying to make a fighting game in game lab, and right now I'm working on the basic controls and attacks, however I have an issue.

      I'm working on an explosion attack when the Z key is pressed and your MP Is over 100, but im having a problem. I put comment in the code below explaining where the problem is. If anyone has a better version of this code that will work please let me know. (Also I'm really new to Game Lab, I just learned the basics in my CS class.)

      if (keyWentDown("z")) {
      savemp = mp;
      mp = mp - 100;
      //checks if mp will be less than 0 if subtracted 100 from its current value
      if (mp < 0) {
      //sets the mp to the amount you had when you pressed z but mp went less than 0
      mp = savemp;
      } else {
      boom.visible = true;
      //turns on the explosion hitbox
      boom.setCollider("rectangle", 0, 0);
      zactive = 1;
      //starts the timer for the attack
      var btime = btime + 1;
      }
      //when btime reaches 100 the attack should stop.
      //my problem is that btime is not updating at all
      //im getting an error that says 'btime' is used out of scope
      //not sure what that means
      if (btime >= 100) {
      boom.visible = false;
      //turns off explosion hitbox
      boom.setCollider("rectangle", 5000, 5000);
      btime = 0;
      }
      }

      Chat