User Tools

Site Tools


haas:fall2023:discrete:projects:ttb0

Corning Community College

CSCS2330 Discrete Structures

PROJECT: Transition To Breakout (TTB0)

OBJECTIVE

With a basic pong game bootstrapped, transition it to a breakout-style game, making use of a malloc’ed array of structs to represent the field of bricks.

EDIT

You will want to go here to edit and fill in the various sections of the document:

TTB0

STRUCT

A structure is an always-public class. For this project, we'll be using one to group together the code we need for our Breakout brick.

Format the code similarly to a class:

struct Brick {
    int positionX;
    int positionY;
    ...
};

Remember that for structures, a semicolon is needed after the closing curly brace. You'll get an error otherwise.

POINTERS

MALLOC

Malloc, short for “memory allocation,” does what it says on the tin.

Malloc is used to allocate memory for specific purposes. For breakout, since we'll know how many bricks are going into our brick field, we'll use an array. An array is always the same size, which means the amount of memory used for the array will remain constant. Malloc is perfect for this scenario.

When the malloc() function is called, it sends a request to the heap in the form of a memory block (heap is memory allocated for each program). The heap's available memory must be at least equivalent to the memory block size. In this case, it will assign the malloc() that memory size function against its request. If the heap has no memory, null value is returned. The memory block is cleared using the free() function to free up the memory for other program instructions.

MALLOC’ED ARRAY

For Breakout, we need to allocate the amount of memory needed to hold our entire brick field (AKA the array of brick structs). We do that by using the sizeof function:

BrickArray = ( [Brick structure]* ) malloc( sizeof( [Brick structure] ) * [Number of bricks] );
ACCESSING WITH POINTER ARITHMETIC

In the example above BrickArray is the name of our array of brick structures. To access an individual point in the array, we'll need to use pointer arithmetic.

The position in the array will be notated as an addition to the brick array, so the following code looks at the 3rd position in the array:

BrickArray+3

In order to access the brick structure's individual variables however, we need to dereference the array. Instead of looking at the memory of the 3rd position of the array, we now look at the data stored at it:

*( BrickArray+3 )

With an additional set of parentheses, we'll be ready to access any variable of the brick structure like you would for any member of a class:

(*( BrickArray+3 )).positionX

MALLOC’ED ARRAY OF STRUCTS

 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

  • Project must be submit on time, by the deadline.
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output, if applicable, must be correct based on values input
  • Code must be nicely and consistently indented
  • Code must be consistently written, to strive for readability from having a consistent style throughout
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
      • Sufficient comments explaining the point of provided logic MUST be present
  • No global variables (without instructor approval), no goto statements, no calling of main()!
  • Track/version the source code in your lab46 semester repository
  • Submit a copy of your source code to me using the submit tool by the deadline.

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

RUBRIC

I'll be evaluating the project based on the following criteria:

26:ttb0:final tally of results (26/26)
*:ttb0:functional breakout game [13/13]
*:ttb0:malloced array of structs used for bricks [13/13]

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 1024 bytes (absolute value of data content change))
      • near the class content contribution average (a value of at least 1kiB)
      • no zero-sum commits (adding in one commit then later removing in its entirety for the sake of satisfying edit requirements)
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2023/discrete/projects/ttb0.txt · Last modified: 2023/09/03 09:34 by 127.0.0.1