Coordination Game

3DSpaceship and asteroid

General Instructions:

Click on the link to open the Starter file, it contains images and some code to help you get started.

Now, click on the fork icon .

coloured background

Then at the bottom it will give the option to fork the project to save and modify .

coloured background

Add the code inside the highlighted box in the examples.

coloured background



Catch game basic shapes:


Under box, write the pair of push() and pop(), to consolidate the box code.

coloured background


Then add the translate() with x-axis and y-axis positions to make it appear in the center.

coloured background


Finally, make a 3D box and rotate in all axes. coloured background


Now, under the sphere add the pair of push()and pop() to consolidate the sphere code.

coloured background


Add translate() with x and y axes to make it appear higher up.

coloured background


Finally add the 3D sphere.

coloured background

Make two variables x and y , which have ths initial position of the 3D box.

coloured background


Replace the hard coded values inside the translate of the 3D box with the variable x and y. Since variables can change we can use them to move the 3D box.

coloured background


In the 3D sphere code, replace the hard coded values in the translate and use the mouse x and y position to make the 3D sphere move.

coloured background


Under the collision detection, make a local variable "d" to store the calculation of the distance between 3D box and the sphere using their x and y positions.

coloured background

Make a conditional statement, that checks how close the two objects needs to be that the collision can happen. And when collison happens randomly change the x and y position of the 3D box.
random(minmum value , maximum value).

coloured background

Bonus Activity :



Bonus 1 - Score:


Make the variable of score and initialise it with 0.

coloured background


Increment the score by any value of your choice.

coloured background


Finally add the scoring function to make the score appear on the 3D canvas. It will also have the win screen condition if the score reaches 50.

coloured background

Happy Coding!!

Continue Reading

Map & Random

Learn More

Function

Learn More