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

  Create a simple warm-up program using your g3d

Create a simple warm-up program using your G3D programming and graphics environment.

  Shadow effect while rolling a sphere

Shadow effect while rolling a sphere as well as the options of shading and lighting.

  Relative positioning and interactive positioning

Relative Positioning and Interactive Positioning by Dragging and Clicking and some Simple Animation

  Draw a teapot at the global origin

Draw a teapot at the global origin

  Concepts of computer graphics

Concepts of Computer Graphics and develop a program using OpenGL

  The security policy document outline

Using the GDI Case Study below, complete the Security Policy Document Outline

  Develop the image manipulations

Develop the image manipulations

  What does resolution mean

What does resolution mean How is resolution connected to ppi and dpi units

  Differentiate between a bitmap image and a vector image

Differentiate between a bitmap image and a vector image Explain the following terms

  Essential elements of a design pattern

configuration of an Iterator pattern, patterns could be used in a Library System, Singleton, Template, Decorator, Façade,What does Alexander means by the following declaration "But it is impossible to form anything which has the temperament of natu..

  Framework of user interface design

design of user interfaces, natural mapping, GUI applications, web page design different to designing for printed media, risks exposed in this "phone as individual proxy" approach, interaction designers of ubicomp applications, Storyboards are usual..

  What are the factors affecting picture composition

Define picture composition What are the factors affecting picture composition. Elaborate on each factor Describe the basic lines present in a composition

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