Virtual University Of Pakistan Network
Assignment No. 02
CS602: Computer Graphics
Total Marks: 20
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
The objective of this assignment is to;
This assignment is based your Assignment No.1. Please see the given startup code for this assignment (in attached folder StartupCode) which is same as solution of Assignment No.1. Open Assigment2.dev project file in Dev-C++ and after successful compilation and execution, you will see the output. You can see the code in order to understand how coordinates of the Ball are modified to introduce back and forth motion effect along horzintal axis.
After understanding it’s working, you need to further modify the code as desired in this assignment.
Your task is to slightly modify this code just by improving motion effect of the Ball as shown in the executables “Desired_Output.exe”. You can see, Ball is not restricted to horizontal motion only, rather its moving in the rectangular rigion and get reflected with the same angle as inccident angle after colliding with the walls. Each time you execute the program, Ball get started from a randomnly selected position near the top line of rectangle.
Hint: To get ball reflected with the same angle as inccident angle, you can to add/subtract 3 from both x and y coordinates of the ball depending upon its motion direction.
Screenshot of the desired output:
You are required to submit your solution through LMS in zip format containing two files.