User Tools

Site Tools


Sidebar

projects

wcp1 (due 20240124)
pct0 (bonus; due 20240125)
pct1 (bonus; due 20240125)
abc0 (due 20240131)
btt0 (due 20240131)
pct2 (due 20240131)
wcp2 (due 20240131)
mpg0 (due 20240207)
pct3 (bonus; due 20240207)
wcp3 (due 20240207)
mpg1 (due 20240214)
pct4 (due 20240214)
wcp4 (due 20240214)
bwp1 (bonus; due 20240228)
mpg2 (due 20240228)
pct5 (bonus; due 20240228)
wcp5 (due 20240228)
cgf0 (due 20240306)
gfo0 (due 20240306)
pct6 (due 20240306)
wcp6 (due 20240306)
cgf1 (due 20240313)
pct7 (bonus; due 20240313)
wcp7 (due 20240313)
cgf2 (due 20240320)
pct8 (due 20240320)
wcp8 (due 20240320)
pct9 (bonus; due 20240327)
wcp9 (due 20240327)
bwp2 (bonus; due 20240410)
cgf3 (due 20240410)
gfo1 (due 20240410)
pctA (due 20240410)
wcpA (due 20240410)
pctB (bonus; due 20240417)
waq0 (due 20240417)
wcpB (due 20240417)
pctC (due 20240424)
waq1 (due 20240424)
wcpC (due 20240424)
pctD (bonus; due 20240501)
wcpD (bonus; due 20240501)
gfo2 (due 20240508)
pctE (bonus; due 20240508)
wcpE (bonus; due 20240508)
EoCE (due 20240516)
haas:spring2024:data:projects:ttb0

Corning Community College

CSCS2320 Data 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

Setting Up TTB0

Migrating Sprites Onto lab46 and PI

After creating your sprites, you will need to move them onto lab46 and possibly onto your PI. One way of doing this is using the scp command. To use the scp command use to following format:

scp FILENAME DESTINATION:PATH

Here is an example:

scp sprites.png username@lab46.g7n.org:~/src/fall2023/discrete/ttb0

If necessary, this is how you would get the desired file onto your PI:

scp sprites.png username@raspberrypi:~/src/fall2023/discrete/ttb0
Adding Sprites To Game

Once you have your sprites .png file on lab46 and on your PI it is now time to load them into the cartridge.
Make sure your texture.png is in your ttb0 directory or you supply the correct path to the file.

To add them to the cartridge open your make.sh file.

Once in the make.sh file, add the following lines:

echo
echo Convert the PNG textures
echo --------------------------
png2vircon BreakoutTextures.png -o BreakoutTextures.vtex || abort_build

“BreakoutTextures.png” is an example that represents the name of your texture file. Yours could be TexturesBreakout.png for example

After including the texture file in make.sh you also need to add it to your .xml file. To do so, open your .xml file and add the following:

    <textures>
        <texture path="BreakoutTextures.vtex" />
    </textures>

“BreakoutTextures” represents the name of your breakout texture file.

Once you have added your texture file to BOTH the make.sh and the .xml file your textures are loaded into the cartridge.

STRUCT

Making Brick Struct

When making your structure for the brick, it is important to remember that every time the ball hits the brick it needs to disappear. This means that inside the brick structure, you need to have a flag, in the below example the flag would be a boolean named Active. The value for a particular index's Active member would change upon collision.

Here is a simple brick structure that you can add or build onto if necessary:

struct BrickOBJ
{
    bool Active;
    int X, Y;          // Brick X and Y location
    int Width, Height; // Brick size
};

POINTERS

A pointer points to and references a location in memory. We can obtain the value that is stored at that location by de-referencing the pointer. The main use of pointers in this project will be to reference/de-reference each brick you have allocated memory for (malloc).

MALLOC

Memory Allocation. This is a way to perform memory management manually for dynamic memory. The syntax for malloc is below.

  ptr = (cast-type*)malloc(byte-size);
  
  
  

MALLOC’ED ARRAY

The array exists as a linear allocation of memory, and any particular value in the array can be accessed by adding the value of that location to the pointer when calling it

Example:

  (*(b_arr + 0)).x = 20;

would make the first x value of the array 20 and

  (*(b_arr + 1)).x = 30;

would make the second x value of the array 30, and so on

ACCESSING WITH POINTER ARITHMETIC

Pointers to structs can be accessed the same way a class can, like so

  [POINTER NAME].[VARIABLE NAME] = [VARIABLE VALUE]

a more practical example would be

  (*b_arr).x = 64

or some such, it functions as classes would in C++, we just need to make them ourselves since this is just C

MALLOC’ED ARRAY OF STRUCTS

For this project we will be using a pointer to point to an array of structs that we have allocated memory for. So we can use a line that looks similar to this.

  ptr = (Brick *)malloc(sizeof(Brick)*number_of_bricks);
  Brick*ptr = NULL;
  

With Brick being a struct. You need to make sure you set the ptr to = NULL before you use it as that is creating it and it needs a value.

free( ptr );

Be sure to free any allocated memory by the end of the program.

 

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/spring2024/data/projects/ttb0.txt · Last modified: 2023/09/03 13:35 by 127.0.0.1