It is okay to use an onEvent as an algorithm. But the algorithm and one of the two sub-algorithms must have math/logic. Also, the structure of the code in your gamescreen() function is incorrect. The student should **not** put an onEvent inside a function. Correcting the format, the student should write it as:

function gamescreen() {

setPosition(“skateboard”, randomNumber(50,280), randomNumber(50, 350));

total_score = total_score+scoreMultiplier;

setText(“total_score”, total_score);

}

onEvent(“skateboard”, “click”, function() {

gamescreen();

});

Looking at the above corrected algorithm, I see two sub-algorithms (1. set the position of the skateboard to a random location and 2. update the score) with math/logic. Note that even though I am counting random number as math, it has been debated. To be on the safe side use more than just a random number generator for a math operation. The main algorithm (the onEvent) does not have any math/logic and hence in my opinion would lose the point for row 5.

The second onEvent in your example in my opinion may pass rows 4, 5, and 6. It has a main algorithm of checking if the person has clicked the background and update the number of lives. The sub algorithm would be to change the screen and then “loose()”. So the main algorithm could be the decrementing of lives, the sub algorithm could be checking if any lives are left, if not go to lose_screen. Much is left to the interpretation of the reader here. It would be much easier to interpret if the onEvent has function calls as shown below.

function updateScreenIfLost(){

if (lives == 0) {

setScreen(“lose_screen”);

}

function loose() {

…//I don’t know the code that goes here

}

onEvent(“background”, “click”, function() {

lives = lives - 1;

setText(“total_lives”, lives);

updateScreenIfLost();

loose();

I hope this helps.