1/42
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is the frame rate set in the setup() function of the Snake game?
a) 5 frames per second b) 10 frames per second c) 20 frames per second d) 30 frames per second
a
What is the purpose of the scale(rez) command in the draw() function?
a) It resizes the canvas to fit the browser window b) It zooms so that 1 grid-square equals 20 real pixels c) It changes the speed of the game loop d) It rotates the entire game board
b
What value is assigned to rez in the global variables of sketch.js?
a) 10 b) 15 c) 20 d) 25
c
Which file loads the ml5 library for machine learning functionality?
a) style.css b) snake.js c) sketch.js d) index.html
d
What is stored in this.body within the Snake class?
a) The snake's current direction b) The snake's current score c) An array of squares representing the snake's body d) The food position
c
Which function in sketch.js is responsible for placing the first piece of food at the start of the game?
a) setup() b) draw() c) foodLocation() d) keyPressed()
b
In keyPressed(), what direction does snake.setDir(0, 1) represent?
a) Left b) Right c) Up d) Down
c
Where is the snake's head located within the this.body array?
a) At the front (index 0) b) At the middle c) At the end (last index) d) It changes randomly each frame
c
What does the grow() method do to the snake?
a) It doubles the snake's speed b) It adds one extra square to the snake's body c) It resets the snake to its starting length d) It shrinks the snake by one square
b
Which two numbers are passed to setDir() to make the snake move upward?
a) (0, 1) b) (1, 0) c) (0, -1) d) (-1, 0)
c
What is the minimum confidence threshold used in gotResults() to ignore uncertain voice predictions?
a) 0.50 b) 0.75 c) 0.85 d) 0.95
c
How many classes are recommended for the Teachable Machine audio project (including Background Noise)?
a) 3 b) 4 c) 5 d) 6
d
What is the total number of grid squares across the width of the canvas (w) when rez = 20 and createCanvas(400, 400) is used?
a) 10 b) 20 c) 30 d) 40
b
Which p5.js function runs once at the very beginning of the game, before setup()?
a) draw() b) keyPressed() c) preload() d) foodLocation()
c
What does the endGame() method check for when determining if the snake has crashed?
a) Whether the snake is moving too fast b) Whether the snake's head is off the board or touching its own body c) Whether the food has disappeared d) Whether the snake has grown too long
b
What does the eat(pos) method return to draw() when the snake's head is on the food?
a) false b) true c) The new food position d) The snake's new length
b
In snake.js, what is the starting position of the snake's body when a new Snake is created?
a) The top-left corner (0, 0) b) The middle of the board c) The bottom-right corner d) A random position
a
Which line of code in index.html must come BEFORE sketch.js to avoid a "Snake is not defined" error?
a) <script src="style.css"></script> b) <script src="snake.js"></script> c) <script src="ml5.min.js"></script> d) <script src="p5.js"></script>
b
What color is the food drawn as in the draw() function?
a) Black b) Green c) Red d) Blue
c
What does the classifier.classify(gotResults) line do when added to setup()?
a) It loads the Teachable Machine model from the URL b) It starts the microphone and classifies sounds continuously c) It trains the model on new audio samples d) It stops the classifier from running
b
What is the recommended action if the model outputs a word with confidence below 0.85?
a) Change the snake's direction immediately b) Ignore the prediction and do nothing c) Print an error message to the console d) Restart the game
a
In the update() method, what is the first step in moving the snake?
a) Remove the tail using this.body.shift() b) Add a new head using this.body.push() c) Copy the current head position d) Change the direction using setDir()
c
What is the purpose of the style.css file in the Snake game project?
a) To style the game canvas with colors b) To remove default margins and padding from the page c) To load the p5.js library d) To define the Snake class
b
Which function is called when the user presses a key in the Snake game?
a) keyIsPressed() b) keyDown() c) keyPressed() d) onKey()
c
What is the effect of changing frameRate(10) to frameRate(5)?
a) The game runs faster b) The game runs slower c) The canvas size changes d) The snake grows faster
b
In the Teachable Machine setup, what is the first class that must be created in an Audio Project?
a) up b) down c) Background Noise d) left
c
What does the noLoop() function do when called in draw()?
a) It restarts the game loop b) It stops the draw() loop from repeating c) It pauses the game temporarily d) It clears the canvas
b
Which of the following is NOT one of the four directional classes recommended for the Teachable Machine model?
a) up b) down c) stop d) right
c
What is the value of rez when the game has a 10×10 grid on a 400×400 canvas?
a) 10 b) 20 c) 30 d) 40
d
What does the this.len variable track in the Snake class?
a) The number of squares in the snake b) The score or length counter c) The current frame rate d) The number of foods eaten
b
In draw(), what happens immediately after the snake eats the food?
a) The game ends b) The food moves to a new random location c) The snake shrinks d) The frame rate doubles
b
What does the show() method in snake.js do?
a) It updates the snake's position b) It draws every square of the snake as a black rectangle c) It displays the current score on the canvas d) It checks if the snake has eaten the food
b
Which of the following is a valid reason to increase the confidence threshold above 0.85?
a) To make the snake turn more often b) To reduce false positives from background noise c) To make the game run faster d) To allow more words to be recognized
b
In the gotResults() function, what does results[0].label contain?
a) The confidence level of the prediction b) The error message if classification fails c) The model's best guess of the spoken word d) The raw audio data from the microphone
c
What is the purpose of the copy() method used on the head position in update() and grow()?
a) To delete the original head position b) To create a new independent vector instead of referencing the original c) To double the snake's speed d) To reverse the snake's direction
b
What happens when the snake crashes into a wall in the game?
a) The screen turns red and noLoop() stops the game b) The snake wraps around to the opposite side c) The game speed increases d) The snake shrinks by one square
a
Which function in sketch.js is called when the browser first loads the game, before setup()?
a) draw() b) preload() c) keyPressed() d) foodLocation()
b
What color is the snake drawn as in the default show() method?
a) Red b) Green c) Black d) Blue
c
What is the recommended number of short audio samples to record for each voice command class in Teachable Machine?
a) 3 or fewer b) 5 c) 8 or more d) 15
c
In the keyPressed() function, what does the spacebar do when pressed?
a) It pauses the game b) It changes the snake's direction to up c) It makes the snake grow by one d) It restarts the game
c
What is the effect of changing rez = 20 to rez = 40 on the game board?
a) The canvas size doubles b) The number of grid squares decreases c) The snake moves faster d) The food becomes larger
b
Which method in the Snake class is called by draw() to check if the head is on the food?
a) endGame() b) update() c) eat() d) show()
c
In the Teachable Machine model, what happens if a class is named "Up" with a capital U but the code checks for "up"?
a) The code will automatically correct it b) The snake will still turn correctly c) The snake will never turn for that command d) The game will crash
c