Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Animation and Games CodeHS || INSTRUCTOR APPROVED QUESTIONS AND ANSWER KEY!!

Rating
-
Sold
-
Pages
18
Grade
A+
Uploaded on
19-05-2025
Written in
2024/2025

In the following code: var ball; function start(){ ball = new Circle(20); add(ball); setTimer(draw, 20); } function draw(){ (2, 2); } When will the function draw be called? correct answers Every 20 milliseconds Which statement will call a function animate every 50 milliseconds? correct answers setTimer(animate, 50); 9.1.5 Crazy Ball correct answers var RADIUS = 100; var circle; function start(){ circle = new Circle(RADIUS); Position(getWidth()/2, getHeight()/2); add(circle); setTimer(crazyBall, 100); } function crazyBall(){ var x = RInt(RADIUS, getWidth()-RADIUS); var y = RInt(RADIUS, getHeight()- RADIUS); Position(x,y); Color(RColor()); } What does this program do? function drawCircle(x, y, radius, color){ var circle = new Circle(radius); Position(x, y); Color(color); add(circle); } function start(){ setTimer(draw, 50); } function draw(){ var color = RColor(); var centerX = getWidth()/2; var centerY = getHeight()/2; var radius = 100; drawCircle(centerX, centerY, radius, color);

Show more Read less
Institution
CodeHS
Course
CodeHS

Content preview

Animation and Games CodeHS || INSTRUCTOR
APPROVED QUESTIONS AND ANSWER KEY!!
In the following code:
var ball;
function start(){
ball = new Circle(20);
add(ball);
setTimer(draw, 20);
}
function draw(){
ball.move(2, 2);
}
When will the function draw be called? correct answers Every 20 milliseconds

Which statement will call a function animate every 50 milliseconds? correct answers
setTimer(animate, 50);

9.1.5 Crazy Ball correct answers var RADIUS = 100;
var circle;
function start(){
circle = new Circle(RADIUS);
circle.setPosition(getWidth()/2, getHeight()/2);
add(circle);
setTimer(crazyBall, 100);
}
function crazyBall(){
var x = Randomizer.nextInt(RADIUS, getWidth()-RADIUS);
var y = Randomizer.nextInt(RADIUS, getHeight()- RADIUS);
circle.setPosition(x,y);
circle.setColor(Randomizer.nextColor());
}

What does this program do?
function drawCircle(x, y, radius, color){
var circle = new Circle(radius);
circle.setPosition(x, y);
circle.setColor(color);
add(circle);
}
function start(){
setTimer(draw, 50);
}
function draw(){
var color = Randomizer.nextColor();
var centerX = getWidth()/2;
var centerY = getHeight()/2;
var radius = 100;
drawCircle(centerX, centerY, radius, color);

,} correct answers Draws several randomly colored circles at the center of the canvas by
drawing 1 every 50 milliseconds.

Which statement would stop the timer in the following program?
function drawCircle(x, y, radius, color){
var circle = new Circle(radius);
circle.setPosition(x, y);
circle.setColor(color);
add(circle);
}
function start(){
setTimer(draw, 50);
}
function draw(){
var color = Randomizer.nextColor();
var centerX = getWidth()/2;
var centerY = getHeight()/2;
var radius = 100;
drawCircle(centerX, centerY, radius, color);
} correct answers stopTimer(draw);

9.2.5: Growing Circle correct answers var START_RADIUS = 1;
var INCREMENT = 1;
var CHANGE_COLORS_AT = 10;
var circle;
var MAX_RADIUS = 240;
var counter = 0;
function start(){
circle = new Circle(START_RADIUS);
circle.setPosition(getWidth()/2, getHeight()/2);
add(circle);
setTimer(draw, 50);
}
function draw(){
START_RADIUS = START_RADIUS + INCREMENT;
circle.setRadius(START_RADIUS);
counter++;
if(START_RADIUS % 10 == 0){
circle.setColor(Randomizer.nextColor());
}
if(counter == MAX_RADIUS){
stopTimer(draw);
}
}

9.2.6: Paint splatter correct answers var CIRCLES_PER_SPLATTER = 20;
var MIN_RADIUS = 5;
var MAX_RADIUS = 25;
var DELAY = 500;
/* This program creates a paint splatter.

, * It's art. */
function start(){
setTimer(splatter, 500);
}
function drawCircle(color){
var paint = new Circle(Randomizer.nextInt(5,25));
paint.setColor(color);
paint.setPosition(Randomizer.nextInt(0, getWidth()), Randomizer.nextInt(0, getHeight()));
add(paint);
}
function splatter(){
var color = Randomizer.nextColor();
for(var i = 0; i < 20; i++){
drawCircle(color);
}
}

Why do we want our code to be "reusable"? correct answers All of the above

How can we make our code reusable? correct answers All of the above

Which function has better reusability? correct answers function drawRectangle(x, y, width,
height, color){
//Draw a rectangle using the parameters as properties
...
}

9.3.5: Circle Wall correct answers // Constants
var RADIUS = 20;
var DELAY = 40;
// Define your global variables here
var yPos = RADIUS;
var xPos = RADIUS;
var counter = 0;
function start(){
setTimer(draw, DELAY);
}
function draw(){
var circle = new Circle (RADIUS);
circle.setPosition(xPos, yPos);
if(counter % 2 ==0){
circle.setColor(Color.red);
}
counter++;
add(circle);
xPos += 2*RADIUS;
if(xPos > getWidth()){
xPos = RADIUS;
yPos += 2*RADIUS;
}

Written for

Institution
CodeHS
Course
CodeHS

Document information

Uploaded on
May 19, 2025
Number of pages
18
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$16.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF


Also available in package deal

Thumbnail
Package deal
CodeHS ||Complete Revision Power Pack || GUARANTEED PASS!!
-
14 2025
$ 72.43 More info

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ProPerfomer (self)
View profile
Follow You need to be logged in order to follow users or courses
Sold
443
Member since
3 year
Number of followers
322
Documents
8875
Last sold
6 days ago
Global Scholars’ Resource Hub

Welcome to your ultimate exam success hub! We provide top-quality, up-to-date, and approved exam materials—study guides, practice tests, and notes for a variety of subjects. Whether you’re preparing for school, college, or professional exams, our resources are designed to help you study smarter and score higher. Thousands have passed with our materials—now it’s your turn!Need more resources or something specific? Contact me anytime, and I’ll be happy to help you find exactly what you need. Your success is our mission!" ✅ Covers multiple subjects and exam types ✅ Includes real practice questions, answers, and study tips ✅ Ideal for students, test takers, and last-minute review Your Exam Success Starts Here – Grab Your Bundle Before It’s Gone!

Read more Read less
3.8

84 reviews

5
36
4
25
3
9
2
2
1
12

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions