App Lab Code Explained
Below is my code for the quiz. Comments are in green.
setScreen("FirstScreen");
var score = 0;
onEvent("bluebutton", "click", function( ) {
setScreen("blue_screen");
});
onEvent("takemeonvaca", "click", function( ) {
setScreen("vacationscreen");
});
onEvent("rightpathchoice", "click", function( ) {
setText("rightpathchoice", "Sorry, you are under the illusion of choice.");
});
onEvent("leftpathchoice", "click", function( ) {
setScreen("bq1_screen");
});
onEvent("mexicoflag", "click", function( ) {
score = score + 1;
console.log("score");
setScreen("bq1_correctchoice");
});
onEvent("otherflag1", "click", function( ) {
setScreen("bq1_wrongchoice");
});
onEvent("otherflag2", "click", function( ) {
setScreen("bq1_wrongchoice");
});
onEvent("otherflag3", "click", function( ) {
setScreen("bq1_wrongchoice");
});
console.log("bq1 is complete");
onEvent("bq2_transport1", "click", function( ) {
setScreen("bq2_screen");
});
onEvent("bq2_transport2", "click", function( ) {
setScreen("bq2_screen");
});
onEvent("citycorrect", "click", function( ) {
score = score + 1;
setScreen("bq2_correctchoice");
});
onEvent("citywrong1", "click", function( ) {
setScreen("bq2_wrongchoice");
});
onEvent("citywrong2", "click", function( ) {
setScreen("bq2_wrongchoice");
});
onEvent("citywrong3", "click", function( ) {
setScreen("bq2_wrongchoice");
});
console.log("bq2 is complete");
onEvent("bq3transport1", "click", function( ) {
setScreen("bq3_screen");
});
onEvent("bq3_transport2", "click", function( ) {
setScreen("bq3_screen");
});
onEvent("bq3_correct", "click", function( ) {
score = score + 1;
setScreen("bq3_correctchoicescr");
});
onEvent("bq3_wrong1", "click", function( ) {
setScreen("bq3_wrongchoice");
});
onEvent("bq3_wrong2", "click", function( ) {
setScreen("bq3_wrongchoice");
});
onEvent("bq3_wrong3", "click", function( ) {
setScreen("bq3_wrongchoice");
});
console.log("bq3 done");
onEvent("bqend_transport1", "click", function( ) {
setScreen("blue_endscreen");
});
onEvent("bqend_transport2", "click", function( ) {
setScreen("blue_endscreen");
});
onEvent("score", "click", function( ) {
setText("score", score + "/3");
});
onEvent("redscreen_transport", "click", function( ) {
setScreen("red_screen");
});
//now we are done with the blue choice path; transport to red
onEvent("red_button", "click", function( ) {
setScreen("red_screen");
});
onEvent("drawing_transport", "click", function( ) {
setScreen("screen1");
console.log("setting screen 1");
penRGB(120, 180, 200);
show();
penDown();
moveForward(100);
});
// below is the sequence for drawing game
// below is the sequence for drawing game
//change thickness
show();
var penwidth = 3;
onEvent("penwid", "click", function( ) {
show();
moveTo(0, 0);
penwidth = prompt("Enter value 1, 3, or 5 for pen width.");
});
if (penwidth===1) {
penWidth(1);
}
if (penwidth===3) {
penWidth(3);
}
if (penwidth===5) {
penWidth(5);
}
// move the turtle to the x position specificied.
onEvent("xSlider", "input", function(event) {
console.log("xSlider");
console.log(penwidth);
console.log("message");
moveTo(getNumber("xSlider"), getY());
});
// Whenever the value of the y-slider is being updated,
// move the turtle to the y position specificied.
onEvent("ySlider", "input", function(event) {
moveTo(getX(), getNumber("ySlider"));
});
penRGB(120, 180, 200);
//changing pen color
onEvent("blue", "click", function( ) {
penColor(rgb(0, 89, 255));
});
onEvent("pink", "click", function( ) {
penColor(rgb(253, 0, 255));
});
onEvent("yellow", "click", function( ) {
penColor(rgb(255, 181, 0));
});
onEvent("green", "click", function( ) {
penColor(rgb(71, 151, 81));
});
//adding sound
onEvent("bqend_transport1", "click", function( ) {
playSound("sound://category_human/character_kimberly_game_over_1.mp3", false);
});
onEvent("bqend_transport2", "click", function( ) {
playSound("sound://category_human/character_kimberly_game_over_1.mp3", false);
});