Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Setup [4 marks] Create an active Processing function that draws a spaceship on a dark background. The spaceship is a simple triangle shape

image text in transcribed
Question 1: Setup [4 marks] Create an active Processing function that draws a spaceship on a dark background. The spaceship is a simple triangle shape that can be turned to point in any direction. Use a canvas that is wider than it is high. The screenshots were created with a 600 x 300 canvas Place the ship so that its nose is at the center of the canvas, and so that it is pointing in a randomly chosen direction. The point marked (r, y) on the diagram below is the nose of the ship, and the angle marked of is the direction that the nose is pointing. In the next question, when you make the ship naive, it will always travel in the direction that the nose is pointing. Create global variables for z, y and # (hut give them better nanas in your code). The length & and the angle a describe the shape of the ship. Create global constants for L and a (with better mames), Experiment with values for 2 and a that produce something like the image above. Define a function void dravship () to do the following. . Use the position (F, y), the length L, and the angles & and o to calculate the positions of the other two vertices, and draw the triangle. (Hint: the angles you will need for the other two vertices are 8 + a and 9 - a.) ASSIGNMENT 2 DEPARTMENT AND COURSE NUMBER COMP 1010 . Find the coordinates of the center of the ship by averaging the F coordinates and the coordinates of the three vertices, Draw a dot at the center of the ship to make sure you have found the correct position. Create global variables to hold the r and y coordinates of the ship center: these will be used in later questions. drawlhip () should store the center coordinates that it calculates in these two global variables. Don't proceed to Question 2 until you are sure that the ship will be drawn correctly, no matter what direction it is facing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finite Mathematics

Authors: Stefan Waner, Steven Costenoble

6th Edition

1285415604, 9781285415604

More Books

Students also viewed these Mathematics questions

Question

help please VIDEO PHONES, INCORPORATED Income Statement...

Answered: 1 week ago

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

e. What are notable achievements of the group?

Answered: 1 week ago