Inspiration

What it does

it tells the user to make a username and password if they don't have one. However, if they have an "account" then it will ask them to enter it. if the username or password is not entered, it shows a page saying "YOU NEED AN ANSWER" after passing that page it will take you to the game. The game is a battery that you have to tap on 10 times. Every time you tap on it, it moves to a random position. if you don't tap the battery and tap on the background then you lose a life. you have 3 lives. if you win, then it will take you to another screen that will say you won and it will take you to the next level when you click on it or it will log you out when you click the log out button.

How we built it

I built it using Javascript

Challenges we ran into

challenges I ran into was not getting any data saved and if you enter anything wrong, it continues with it being wrong

Accomplishments that we're proud of

I'm proud of making the username and password as it is the first time for me to use data and usernames/passwords

What we learned

I learned how to create code for username and password

What's next for Battery Clicker

the next thing I am considering doing is to publish it on android but my only problem with that is that the code is different.

View code

var lives = 3;
var score = 0;
onEvent("start_button", "click", function() {
  setScreen("game_screen");
  lives = 3;
  score = 0;
  setText("number_lives", lives);
  setText("total_score", score);
});
onEvent("half", "click", function() {
  setPosition("half", randomNumber(50,280), randomNumber(50, 350));
  if (score == 9) {
    setScreen("win_screen");
  }
  score = score + 1;
  setText("total_score", score);
});
onEvent("background", "click", function() {
  if (lives <= 1) {
    setScreen("lose_screen");
  } else {
    lives = lives - 1;
  }
  setText("number_lives", lives);
});
onEvent("playAgain_button", "click", function() {
  setScreen("welcome_screen");
  timedLoop(1000, function() {
    setPosition("half", randomNumber(50,280), randomNumber(50,350));
  });
});
onEvent("tryAgain_button", "click", function() {
  setScreen("welcome_screen");
});
onEvent("btnnewUser", "click", function( ) {
  setScreen("screen2");
});
onEvent("btnOK2", "click", function( ) {
if(getText("txtUserNameInput2")==""||getText("txtPasswordInput2")==""){
  fillInBlank();
  } else {
  setScreen("screen3");
  createRecord("LoginInformation", {Username:(getText("txtUserNameInput2")), Password:(getText("txtPasswordInput2")),LoginTime:(Date.now())}, function(record) {

  });
}
});
onEvent("btnCancel2", "click", function( ) {
  setScreen("screen1");
});
onEvent("BtnBack3", "click", function( ) {
  setScreen("screen1");
});
onEvent("btnlogin", "click", function( ) {
  if(getText("txtUserNameInput1")==""||getText("txtPasswordInput1")==""){
    fillInBlank();
  } else {
    readRecords("LoginInformation", {}, function(records) {
      for (var i =0; i < records.length; i++) {
        if (getText("txtUserNameInput1") == (records[i]).Username && getText("txtPasswordInput1") == (records[i]).Password) {
          setScreen("screen4");
        }
      }
    });
  }
});
onEvent("btnLogout", "click", function( ) {
  setScreen("screen1");
});
onEvent("moveOn3", "click", function( ) {
  setScreen("welcome_screen");
});
onEvent("moveOn4", "click", function( ) {
  setScreen("welcome_screen");
});
onEvent("logout", "click", function( ) {
  setScreen("screen1");
});
function fillInBlank() {
  hideElement("lblUserName1");
  hideElement("lblUserName2");
  hideElement("lblPassword1");
  hideElement("lblPassword2");
  hideElement("btnlogin");
  hideElement("btnnewUser");
  hideElement("text_area5");
  hideElement("txtUserNameInput1");
  hideElement("txtUserNameInput2");
  hideElement("txtPasswordInput1");
  hideElement("txtPasswordInput2");
  showElement("fillinAnswers1");
  showElement("fillinAnswers2");
  timedLoop(1000, function() {
    hideElement("fillinAnswers1");
    hideElement("fillinAnswers2");
    showElement("lblUserName1");
    showElement("lblUserName2");
    showElement("lblPassword1");
    showElement("lblPassword2");
    showElement("btnlogin");
    showElement("btnnewUser");
    showElement("text_area5");
    showElement("txtUserNameInput1");
    showElement("txtUserNameInput2");
    showElement("txtPasswordInput1");
    showElement("txtPasswordInput2");
    stopTimedLoop();
  });
}

Built With

Share this project:

Updates