
Code HS Animation Unit
Authored by Stephanie Young
Computers
12th Grade
Used 88+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
18 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does this program do?
var ball;
function start(){
ball = new Circle(40);
add(ball);
setTimer(draw, 20);
}
function draw(){
ball.move(2, 2);
}
Animates a ball by moving it down and to the right once every 20 milliseconds.
Notes: Correct! setTimer(draw, 20) will result in the function draw being called every 20 milliseconds, and each time it is called it moves the ball down and to the right.
Animates a ball by moving it up and to the right once every 20 milliseconds
Notes: setTimer(draw, 20) will result in the function draw being called every 20 milliseconds, and each time it is called it moves the ball down and to the right.
Animates a ball by moving it down and to the right every 20 seconds
Notes: setTimer(draw, 20) will result in the function draw being called every 20 milliseconds, and each time it is called it moves the ball down and to the right.
2.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
var ball;
function start(){
ball = new Circle(40);
add(ball);
setTimer(draw, 20);
}
function draw(){
ball.move(2, 2);
}
Which of the two statements is true?
ball is a local variable
the ball variable in draw is different from the ball variable in start
ball is a global variable
ball’s scope includes both start and draw
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
var ball;
function start(){
ball = new Circle(40);
add(ball);
setTimer(draw, 20);
mouseClickMethod(stopAnimation);
}
function draw(){
ball.move(2, 2);
}
function stopAnimation(e){
//your code here
...
}
Which statement would stop the animation in this program?
stopTimer(ball.move(2, 2));
stopTimer(draw);
stopTimer(draw());
stopTimer(draw, 20);
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
1 var ball;
2 var moveCounter = 0;
3 function draw(){
4
5 ball.move(2, 2);
6 moveCounter++;
7
8 if(moveCounter == 25){
9 stopTimer(draw);
10 }
11 }
12
13 function start(){
14 ball = new Circle(40);
15 add(ball);
14 setTimer(draw, 20);
15 }
How many times will the ball be moved before the animation stops?
20
40
2
25
5.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Which of the following are techniques that make our code more reusable?
Using constants instead of magic numbers
Using specific values in our functions rather than using parameters
Writing multiple functions that solve small subproblems rather than one function that solves the entire problem.
Writing as few lines of code as possible
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which function has better reusability?
function drawCircle(x, y, radius, color){
var circle = new Circle(radius);
circle.setPosition(x, y);
circle.setColor(color);
add(circle);
}
function drawGreenCircleInCenter(radius){
var circle = new Circle(radius);
circle.setPosition(getWidth() / 2, getHeight() / 2);
circle.setColor(Color.green);
add(circle);
}
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What statement should we use to determine if ball is hitting the bottom edge of the window?
if(ball.getX() + ball.getRadius() < 0){
//ball is hitting bottom edge
}
if(ball.getY() - ball.getRadius() < 0){
//ball is hitting bottom edge
}
if(ball.getY() + ball.getRadius() > getHeight()){
//ball is hitting bottom edge
}
if(ball.getY() + ball.getRadius() < 0){
//ball is hitting bottom edge
}
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Microsoft
or continue with
%20(1).png)
Apple
Others
Already have an account?