CS602 Computer Graphics Assignment No. 01 Solution and Discussion Fall 2014

Objective

The objective of this assignment is to;

Learn and practice basic concepts of computer graphics using Dev-C++. (you can download Dev-C++ setup from LMS)
Learn to draw text, rectangle and circles using graphics library functions.
Assignment

Sponsored Links



In this assignment, you are provided with a small startup code attached with this assignment in folder “StartupCode”. Your job is to slightly modify this code as desired in this assignment.

First, you need to understand the working of the given code and execute it in Dev-C++. This program essentially draws some text on screen with a rectangle and two circles labeled as “Earth” and “Moon” and a large circle represents the orbit of Moon as shown in following screenshot.



Initially, you need to open Assigment1.dev project file in Dev-C++. After successful compilation and execution, you will see the output. You will notice that small circle representing the Moon is blinking. The blinking effect is introduced just by simple continuous drawing this circle in WHITE and BLACK colors with some delay in between. When circle is drawn in WHITE color, it appears on the screen. After some delay, we draw the same circle in BLACK color which makes the circle disappear because our background color is also black. Delay of 100ms is introduced by using delay() function.

Your Task

Your task is to slightly modify this code in order to introduce motion effect to the Moon as shown in “Earth_Moon.exe”. This simply requires only few lines of code to modify the x and y coordinates of the Moon. You shall add your code in the areas indicated with comments “Add your code here to modify coordinates of Moon”.

Hint: You have to use your mathematical skills in order to calculate the coordinates of Moon along the orbit.

Screenshot of the desired output:
cs602.jpg

Your Task

Your task is to slightly modify this code in order to introduce motion effect to the Moon as shown in “Earth_Moon.exe”. This simply requires only few lines of code to modify the x and y coordinates of the Moon. You shall add your code in the areas indicated with comments “Add your code here to modify coordinates of Moon”.

Hint: You have to use your mathematical skills in order to calculate the coordinates of Moon along the orbit.

Screenshot of the desired output:

cs6021.jpg