Last modified: April 25, 2023
This is a practice quiz designed to prepare you for the Greenfoot Unit Test.
When a laser is in the world, it travels straight in whatever direction it is going until the center of the laser gets to an edge and then removes itself. You decide the speed.
Test your code at this point. Drop a new Laser in the world and see what it does. It should go to the right. Drop a new Laster in the world and right click on it and call setRotation to change the rotation. Press run and the laser should go in the direction you set the rotation to.
Create an animal class of your choice (you pick the name and image).
Animals should appear in random locations fully on canvas every 100 frames.
Test your code at this point. Animals should appear every 100 frames.
When an animal is on the canvas, it always moves either left, right, up or down but never diagonally.
If an animal touches an edge (edge of image is past an edge), it picks a new direction excluding the direction of the edge.
To make things simpler at first, you could say an Animal is touching an edge if its center reaches an edge of the canvas. You can adjust the edge detection later.
Lasers fire from the center of the bottom edge of the canvas toward a random Animal every 50 frames ONLY if there is an animal in the world. It's ok if there is more than one laser in the world.
Hint: If using turnTowards(), the Laser must be added to the World first, before calling turnTowards()
When an animal touches a laser, the animal and laser should both be removed.
Zip your entire project folder and submit it below.
PX_LastName_FirstName_PracticeQuiz
.PX_LastName_FirstName_PracticeQuiz.zip
. For example if you were in 3rd period and named Michael Wang, then you would name the file P3_Wang_Michael_PracticeQuiz.zip
You must Sign In to submit to this assignment
Dark Mode
Outline