User Tools

Site Tools


Sidebar

projects

pct0 (bonus; due 20230823)
wcp1 (due 20230823)
abc0 (due 20230830)
btt0 (due 20230830)
pct1 (bonus; due 20230830)
pct2 (due 20230830)
wcp2 (due 20230830)
mpg0 (due 20230906)
pct3 (bonus; due 20230906)
wcp3 (due 20230906)
pct4 (due 20230913)
ttb0 (due 20230913)
wcp4 (due 20230913)
pct5 (bonus; due 20230920)
ttb1 (due 20230920)
wcp5 (due 20230920)
dap0 (due 20230927)
gfo0 (due 20230927)
pct6 (due 20230927)
wcp6 (due 20230927)
cgf0 (due 20231004)
pct7 (bonus; due 20231004)
wcp7 (due 20231004)
bwp1 (bonus; due 20231018)
cgf1 (due 20231018)
pct8 (due 20231018)
wcp8 (due 20231018)
cgf2 (due 20231025)
pct9 (bonus; due 20231025)
wcp9 (due 20231025)
cgf3 (due 20231101)
gfo1 (due 20231101)
pctA (due 20231101)
wcpA (due 20231101)
pctB (bonus; due 20231108)
waq0 (due 20231108)
wcpB (due 20231108)
pctC (due 20231115)
waq1 (due 20231115)
wcpC (due 20231115)
bwp2 (bonus; due 20231129)
pctD (bonus; due 20231129)
wcpD (bonus; due 20231129)
gfo2 (due 20231206)
pctE (bonus; due 20231206)
wcpE (bonus; due 20231206)
EoCE (due 20231214)
haas:fall2023: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/fall2023/data/projects/ttb0.txt · Last modified: 2023/09/03 13:35 by 127.0.0.1