Implement a variant of the classic bouncing ball animation

Assignment Help Computer Graphics
Reference no: EM13934821

Problem set- Mandatory

Description

Your task is to implement a variant of the classic bouncing ball animation. To give you an idea of what such an animation could look like we've enclosed a windows executable as part of this assignment (see below). Aim to develop something very similar to what you see in this example.

Each ball should start off at the top of the screen with a random speed in the x direction. Whenever a ball hits a screen boundary it should bounce off at an angle equal to the impact angle and lose some speed. Eventually each ball should come to a rest at the bottom of the screen. Five seconds after coming to a rest a ball should be removed from the screen.

To ensure that the balls come to a rest at the bottom of the screen you need a constant gravity pulling on each ball. The direction of the gravity should be down.

Each ball must be represented as a separate object data structure (see -object.h- in the zip file). The object data structure contains all variables pertinent to rendering the object on the screen (translation, scale, model coordinates, etc.). Note that the object data structure uses floats to represent translation coordinates. This is to make it easier to handle very small movements (at points, a ball might be moving at a speed less than a pixel). Cast the translation coordinates into integers before drawing the triangles on the screen.

Your code must keep track of objects (balls) by placing the object data structures in a linked list. You need to create your own linked list implementation. Below is a brief description of the object programming interface:

• CreateObject - Create a new object. The function accepts as input parameters a pointer to the SDL screen, a pointer to a model triangle array, and a variable telling the size of the model triangle array. The function returns a pointer to a new object data structure. The model triangle array specified as input parameter should not be shared across objects. (Not sharing the model triangle array allows e.g. objects to have different colors.) Perform the necessary memory allocation and copying.

• DestroyObject - Free object. The function accepts as input parameters a pointer to an object data structure. The function should free all memory allocated to represent the object (memory allocated for the model triangle array and the object data structure itself).

• Drawobject - Draw object on screen. The function accepts as input parameters a pointer to an object data structure. The function must draw the object on the screen by calling DrawTriangle on each of the model triangles. Remember to update scale, translation, etc., in each triangle data structure before invoking DrawTriangle.

Hint: Do not make the bouncing algorithm too complex. Bouncing a ball off a vertical or horizontal surface can be accomplished without resorting to calculating impact angles.

Code

Your starting point is the following set of files:

• drawline.h - Specifies the interface of the drawline function.

• drawline.c - Implements the DrawLine function.

• triangle.h- Specifies the triangle data structure and the interface to the DrawTriangle function.

• triangle.c- Draw triangle and friends.

• teapot_data.h- Coordinates for the classic teapot model.

• sphere_data.h- Coordinates for a sphere model.

• list.h- Specifies the interface of the list functionality. Do not modify this file • list.c- Empty stubs for each function in the list interface. Modify this file.

• object.h - Specifies the interface of the object functionality. Do not modify this file • object.c - Empty stubs for each function in the object interface. Modify this file.

• main.c- Contains the main function and calls to initialize SDL. Place your bouncing ball code in this file.

• bouncingballs32.exe/bouncingballs64.exe - Executable showing what your end result might look like. Extract p6.zip to run this executable. Run make before attempting to run the executable.

• Makefile - A Makefile for compiling the code.

We've bundled all of these files in a zip file. The zip file is located in the same folder as this document. Use this zip file as a starting point, as it also includes the necessary SDL files.

Resources

On the Web there is a wealth of information on how to make a bouncing ball animation. Do a Web search.

In particular, your documentation should at least describe the following:

• Your implementation of the object interface.

• Your list implementation.

• How you have implemented animation.

• The algorithm for bouncing balls off screen edges.

• The algorithm for detecting when a ball has come to a rest and how you time removal of the ball from the screen.

Topics that could be discussed in the technical background part of the documentation:

• Dynamic memory allocation.

• Lists vs arrays.

Reference no: EM13934821

Questions Cloud

Strategies used in a health and social care settings : Write a 3000 word essay consisting of three main sections (1,000 words per section) addressing the learning outcomes above. In this assignment students must demonstrate their understanding of communication principles, techniques and strategies..
What is the percentage change in price of bond : Both bond A and bond B have 9.8 percent coupons and are priced at par value. Bond A has 9 years to maturity, while bond B has 20 years to maturity. a. If interest rates suddenly rise by 2.4 percent, what is the percentage change in price of bond A an..
Introduction the area of cyber security : Introduction The area of Cyber security is rapidly evolving, with important research being conducted at all levels. The current and potential damage to societies, businesses, and individuals is a topic of growing importance to Governments across t..
Knowledge development and refined abilities : Effective study skills which focuses upon knowledge development and refined abilities form the sole foundation for the process of learning (Adams et.al, 1994).
Implement a variant of the classic bouncing ball animation : Your task is to implement a variant of the classic bouncing ball animation. To give you an idea of what such an animation could look like we've enclosed a windows executable as part of this assignment.
What must be the forecasted inflation rate in year : Suppose the real risk-free rate currently is 3% and a maturity risk premium of 0.15% per year to maturity applies, i.e., MRP=0.15%*t, where t is the years to maturity. The averaged expected inflation rate over the next following 3 years is 2.5%. If t..
How does dehydration trap so much chemical energy : 2-phosphoglycerate and phosphoenolpyruvate differ only by dehydration between C-2 and C-3, yet the difference in delta G knot prime of hydrolysis is about -50Kj/mol. How does dehydration "trap" so much chemical energy?
Major key establishment protocols : Cryptography transforms security problem into key management problems. That is to say, to use encryption, digital signatures, or message authentication codes(MAC), the parties involved have to hold the 'right' cryptographic keys. The following 2 w..
What is the markets forecast for one year forward rate : Suppose the interest rate on a 1-year bond is 4% and that on a 2 year T-bond is 4.5%. Assuming the pure expectation theory is correct, what is the market's forecast for 1-year forward rate one year from now?

Reviews

Write a Review

Computer Graphics Questions & Answers

  Does the above statement apply to microeconomics

Does the above statement apply to microeconomics or macroeconomics? Why? Think about the cases of government intervention that create a different price compared to the price-finding mechanism of supply and demand.

  How can you create employee loyalty through your

how can you create employee loyalty through your orientation and socialization process? discuss the differences and the

  Selecting bit mapped or vector graphics

For each of the provide a detailed rational for selecting bit mapped or vector graphics when they used in a web based application,

  Dissertation proposal video presentation

This is your last research course for the DHA program. You have been working with the organization in which you will collaborate in completing your Action Research project.

  Create a gouraud light model

Create a Gouraud light model - Experiment with the different component of light and create a camera class that will enable the user to manipulate the camera.

  Select two of the more prominent cooperative linkages that

select two of the more prominent cooperative linkages that your selected firm apple has made. make sure that there are

  What challenges the engineering team make user-friendly gui

What challenges the engineering team must have faced to make such user-friendly GUIs. What are two key features that should be included in all mobile devices? For each, suggest a simple algorithm that may power these features.

  Question 1jarum industrial tools is considering a 3-year

question 1jarum industrial tools is considering a 3-year project to improve its production efficiency. buying a new

  As a newly promoted vice president your ceo has invited you

as a newly promoted vice president your ceo has invited you to participate in this years upcoming strategic planning

  About color memorization

Color Memorization

  How would you describe way vision was use at mentor graphics

How would you describe the way vision was used at Mentor Graphics? Did it strengthen or weaken the company? How? Why?

  What is the gamut of a color space

What is the gamut of a color space and what is the gamma of a color space (or color display device) - What is the advantage of interlaced video? What are some of its problems?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd