Get Instant Help From 5000+ Experts For

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
Guaranteed Higher Grade!
Implementing a Bouncing Ball Animation in C - Oblig 6

Problem set 6 - 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. Submission guidelines For this assignment we expect two hand-ins: A report describing how your C code fulfills the requirements of the assignment text (as printed text, in the PDF format). The C code that you have written (as one or more .h and .c files). This assignment can be completed alone or in cooperation with at most one other student. If you choose to cooperate with someone, then: The report must state the names of both students. The hand-in must be registered by both students in Fronter. Do not refer to the C code as self-explanatory. We encourage use of figures to illustrate data structures and pseudo-code to illustrate algorithms. 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. The report and the C code must be placed in a zip archive and submitted via the Fronter course page. Note the following rules: 1. Zip archive name: _inf1100_oblig6.zip (e.g. Ola_Nordmann_inf1100_oblig6.zip) 2. Zip archive contents: _inf1100_oblig6 (this is a folder/directory) doc (this is a folder/directory) report.pdf src (this is a folder/directory) include object.c list.c ... If you cooperate with someone, the name of both students must be part of the zip archive name (e.g.John_Doe_Kari_Nordmann_inf1100_oblig6.zip) IMPORTANT!! You hand-in will be judged ikke godkjent if you do not follow these instructions. There will be a folder named Innlevering Oblig 6 under the Hand-in section. See Wikipedia for details on archiving files.