User Tools

Site Tools


Sidebar

projects

wcp1 (due 20250129)
abc0 (due 20250205)
btt0 (due 20250205)
pct0 (bonus; due 20250205)
pct1 (bonus; due 20250205)
pct2 (due 20250205)
wcp2 (due 20250205)
mtb0 (due 20250212)
pct3 (bonus; due 20250212)
wcp3 (due 20250212)
mtb1 (due 20250219)
pct4 (due 20250219)
wcp4 (due 20250219)
mtb2 (due 20250226)
pct5 (bonus; due 20250226)
wcp5 (due 20250226)
gfo0 (due 20250305)
mtb3 (due 20250305)
pct6 (due 20250305)
wcp6 (due 20250305)
mtb4 (due 20250312)
pct7 (bonus; due 20250312)
wcp7 (due 20250312)
bwp1 (bonus; due 20250326)
mag0 (due 20250326)
pct8 (due 20250326)
wcp8 (due 20250326)
mag1 (due 20250402)
pct9 (bonus; due 20250402)
wcp9 (due 20250402)
haas:spring2025:cprog:projects:mtb3

Corning Community College

CSCS1320 C/C++ Programming

PROJECT: Move The Block (MTB3)

OBJECTIVE

Modify your pong game (or start from scratch) to implement a functioning breakout game (brickfield of at least 30 bricks).

Paddle-ball collisions, ball-brick collisions.

EDIT

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

MTB3

Only task headings have been provided. You are not expected to know how to do the task given by just that description (although in some cases it can be adequately figured out). Instead, if no further information is yet present, ASK FOR DETAILS on the discord, then contribute that clarity here.

If something is present but needs polish: spruce it up.

If something is present but is incorrect: please fix it.

This is intended to be an informative, useful document that all can benefit from.

Those with prior experience, please be mindful not to gobble up all the low-hanging fruit from the newcomers.

URLs

Breakout

Game where you have a set of bricks that are breakable by the ball. You also have a paddle to bounce the ball towards the bricks. If the ball falls under the paddle, end game or lose lives.

brick field

You can save yourself a lot of time and effort by using a for loop for the brick field. This way you can check for bounds and draw each box and then loop, rather than write the same code with a few numbers changed for as many times as you have boxes. The basic structure of a for loop in C is as follows:

for ( int counter = 0; counter < 10; counter++ ) 
{
//code
}

This tell the loop to initialize a counter variable as 0 in this case. It will check if the counter is less than 10 and continue with the code. The counter++ tells the loop to add one to the counter variable every time it loops, so eventually, counter will be 10 and the loop will stop.

brick structure
array of bricks

You can use an array of boolean values to check if the box has had a collision or not. This would look something like:

bool[#ofboxes] Boxes;

You can make use of for loops to initialize every value in the array to true or false. Then when drawing the boxes, use a for loop and only draw each box if the corresponding value in the boolean array is true or not ( This would assume when the ball collides with the box you set that boxes boolean value to false )

brick ball collision detection

There are many ways to check for collisions. First, an object that needs to be collided with has to have a hitbox. This means there needs to be a variable representation of an object's dimensions with an x variable and y variable. Since many parts of this game will have a hitbox, It might be smart to make a struct. A struct is a user defined data type that groups together variables; good for organization and helps with parameters with functions. You can make a struct containing x and y variables. This will make it so you don't have to individually make variables anymore, and can group them into one object through encapsulation. Though when using structs, if you want to pass them as parameters, you would have to learn about pointers.

pointers

Pointers are simply a variable that stores a memory address of other variables. pointers themselves have their own data types aswell, like an int datatype to the number 52. The pointer datatype has the goal of formatting data to represent a memory address of some given variable. Because of this, the pointer also needs to know to what type of variable it is pointing to. There could be a pointer that points to a memory address of an integer, or a pointer that points to the memory address of a string. In order to represent a memory address of a variable, it needs to know what type of variable it is pointing to. Pointers don't just point to the memory address of something, they can be dereferenced and reveal the value at which they are pointing at. to dereference a pointer, and reveal the value at the memory address that it is pointing at, there are many techniques. First let's define a pointer. To define a pointer, memory needs to be allocated manually within c, but only to the data that it is pointing to.

int *hi;

This is how you define a pointer. By itself, it is saying make a new pointer type of thing, that points to an integer. But in this format, the computer only allocates the memory for a pointer type, and not the thing being pointed to. The integer that is being pointed to has not yet had memory allocated for it. Normally behind the scenes, when you create a variable of some type of thing, memory is allocated automatically, but for pointers, they need to manually allocate memory for the thing that the pointer is pointing to.

malloc( [bytes] ) is a function that returns a pointer to the first memory address of a section of memory that is allocated based on the parameter of how big you want that space to be (in bytes).

one would need to allocate enough memory to represent an integer, if a pointer is pointing to that type.

There is a function that returns how big a datatype is in bytes: sizeof([type])

so to allocated enough memory for an integer manually you would do: malloc(sizeof(int)), which returns a pointer to the first address of the section of allocated memory whose size is the parameter passed in (how many bytes to make up an integer type of thing). to summarize it returns the pointer to the first address of a block of memory that is the size of an integer.

the pointer that is return though is a pointer that points to nothing, aka a null pointer. the pointer needs to be casted to change it's type to a int pointer.

(*int)malloc(sizeof(int)) -returns an int pointer

the variable that was first created can now be assigned to this

int *hi = (*int)malloc(sizeof(int));

now after all that, it can now be understood that a memory block that represents an integer has been allocated, and the starting address of that memory is now stored as a value to a pointer type, which when called, will give the starting address of the integer that it points to.

 

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:

156:mtb3:final tally of results (156/156)
*:mtb3:submitted Vircon32 cartridge [13/13]
*:mtb3:submitted C code XML and build script [13/13]
*:mtb3:breakout brick field implemented as array [26/26]
*:mtb3:collision detection, ball against brick [26/26]
*:mtb3:cartridge is NOT added to repository [13/13]
*:mtb3:proper bounds checking in place for all objects [26/26]
*:mtb3:committed project related changes to semester repo [13/13]
*:mtb3:screenshot or video to class discord channel [26/26]

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))
      • 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
  • Individuals who have not participated at least 50% will be subject to a 50% overall deduction.
haas/spring2025/cprog/projects/mtb3.txt · Last modified: 2025/02/23 15:09 by 127.0.0.1