Professional Documents
Culture Documents
Class 23
Class 23
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
3. Use the push() and pop() function to apply new settings to the cannonball.
4. Create a new cannonball and display the cannonball in the sketch.js file.
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
Output:
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
5. Change the angle of the cannon when the left and right arrow keys are pressed by
adding this.angle property in the constructor() for the cannon.
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
7. Move the angle of the cannon up and down by using the UP_ARROW and
DOWN_ARROW keys.
8. Move the cannon with a given angle and not from the origin by using the translate()
function.
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
Output:
9. Restrict the cannon from moving in wide-angle by adding a condition to the earlier
condition where we are changing the angle of the cannon on keypress.
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
Output:
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
13. Call the cannonBall.shoot() inside sketch.js after the function draw() using the
keyPressed() function.
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.
CS-PRO-C23(V3)
OUTPUT:
What’s next?
In the next class, we will learn how to create multiple balls and shoot them from the cannon.
© 2019 The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to
share any part of this message with any third party without a written consent of the sender. If you received this message by mistake,
please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.