Need code for bug grab


#1

Does anyone have the code for the bug grab game? I am having some students having a very difficult time coming up with their own game to write. So my thought is to have them change up the bug grab game or the emoji game. I would like to show them the code for bug grab as a starting point.


#2

Do you need the entire project, or just the Javascript code? I can copy and paste the code here, but you’ll still need to do the Design Mode part of the project.


#3
var score = 0;
var starting_position = getProperty("bug", "x");

onBoardEvent(buttonL, "press", function(event) {
  score = score - 10;
  setProperty("bug", "x", starting_position + score);
  if (score < -100) {
    setProperty("winner", "text", "Player 1");
    setScreen("win_screen");
    buzzer.frequency(900, 1000);
  }
});

onBoardEvent(buttonR, "press", function(event) {
  score = score + 10;
  setProperty("bug", "x", starting_position + score);
  if (score > 100) {
    setProperty("winner", "text", "Player 2");
    setScreen("win_screen");
    buzzer.frequency(200, 1000);
  }
});

#4

Im so glad I found this post!
Will you be putting up example solutions for this in the unit 6 teacher interface soon?