CSCS1320 C/C++ Programming
PROJECT: FUN WITH GAMES (fwg3)
OBJECTIVE
Using your Vircon32 build and installation from fwg0, and the game foundations from fwg1 and fwg2, implement your own 2D game of your choosing, this time organizing your game's data with structs. Rather than tracking each game object as a scattering of loose variables, you will group related data (position, velocity, size, state) into well-defined struct types, and start utilizing custom functions to assist in game operations.
The choice of game is up to you. Some ideas:
- Space Invaders-style shooter (player ship, bullets, enemies)
- Frogger-style crossing game (frog, lanes of vehicles/logs)
- Asteroids-style (ship, rocks, shots)
- Snake, Pac-Man-style maze chase, Flappy-style side scroller
- Catch/dodge game (things fall from the sky, you catch or avoid them)
- something entirely your own: be creative!
Your game should be simple enough to finish, but have enough going on that it is clearly a game: something the player controls, something that reacts or opposes them, and a way to win, lose, or score.
PROGRAM
You are to write a Vircon32 C game that:
- has a player-controlled object, moved via the gamepad
- has at least one other kind of game object (enemy, obstacle, projectile, pickup, etc.) that acts on its own
- detects collisions between objects, with a meaningful result
- keeps a score (or lives, or timer) displayed or otherwise tracked
- has a win and/or lose condition (even if it simply resets)
- is built around structs:
- define at least TWO distinct struct types in your game, for example a player type and an enemy/projectile type
- each struct holds that object's state: position, velocity, size, and an active/alive flag at a minimum (as relevant to your game)
- create struct variables for your game objects
- create and utilize functions that perform some game operation, such
such as
update_player(),draw_enemy(), orcollide()
NOTE: you are free to use arrays of structs if your game calls for it (many enemies, many bullets), but the emphasis of this project is on the design and use of the structs themselves.
NOTE: the first gamepad by default is mapped to the keyboard
STRUCT REMINDERS
A quick example of the sort of thing we are after (yours will differ):
struct point
{
int x;
int y;
};
struct sprite
{
struct point pos; // where it is on screen
struct point vel; // how it moves each frame
int width;
int height;
int active; // is it currently in play?
};
void move_sprite(struct sprite *s)
{
s->pos.x += s->vel.x;
s->pos.y += s->vel.y;
}
Remember: use the dot operator (.) with a struct variable, and the
arrow operator (->) with a pointer to a struct.
CARTRIDGE BUILD PROCESS
All of these steps can be automated with the use of the provided
Makefile simply by typing make at the prompt.
NOTE that with certain modifications, you'll first need to modify the XML file as appropriate.
COMPILE
First step is to compile the C code, which can be done with the following
command from the Vircon32 developer tools C compiler (compile):
yoursystem:~/src/SEMESTER/cprog/fwg3$ compile fwg3.c -o fwg3.asm
This compiles, or translates, the C code into Vircon32 assembly language code, which will then need to be assembled to machine code:
ASSEMBLE
Once you've compiled your code successfully, you can use the Vircon32
assemble DevTool to assemble the assembly:
yoursystem:~/src/SEMESTER/cprog/fwg3$ assemble fwg3.asm -o fwg3.vbin
IMAGE CONVERSTION
Any PNG images you'd like to use need to be converted to Vircon32 texture
format via the png2vircon tool:
yoursystem:~/src/SEMESTER/cprog/fwg3$ png2vircon background.png -o background.vtex
yoursystem:~/src/SEMESTER/cprog/fwg3$ png2vircon sprites.png -o sprites.vtex
Note that you'll also want to ensure the XML file has been updated to reference these textures:
<binary path="fwg3.vbin" />
<textures>
<texture path="background.vtex" />
<texture path="sprites.vtex" />
</textures>
AUDIO CONVERSION
Should you have any WAV files you'd like to use need to be converted to
the Vircon32 sound format via the wav2vircon tool:
yoursystem:~/src/SEMESTER/cprog/fwg3$ wav2vircon backgroundmusic.wav -o backgroundmusic.vsnd
yoursystem:~/src/SEMESTER/cprog/fwg3$ wav2vircon soundfx.wav -o soundfx.vsnd
Note that you'll also want to ensure the XML file has been updated to reference these sounds:
<sounds>
<sound path="backgroundmusic.vsnd" />
<sound path="soundfx.vsnd" />
</sounds>
PACKING THE ROM
Once all the components have been built, you can pack them together into
a Vircon32 cartridge for use in the emulator via the packrom tool:
yoursystem:~/src/SEMESTER/cprog/fwg3$ packrom fwg3.xml
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
- Any "to be implemented" comments MUST be removed
- No global variables (without instructor approval), no goto statements, no calling of main()!
- Track/version the source code in your private 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/cprog/fwg3$ make submit
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:
234:fwg3:final tally of results (234/234)
*:fwg3:code modified to meet project specifications [26/26]
*:fwg3:screenshot or video posted to class DISCORD of game running [26/26]
*:fwg3:at least two distinct struct types defined and used [26/26]
*:fwg3:structs hold object state (position, velocity, size, active) [26/26]
*:fwg3:utilize some functions to perform various game actions [26/26]
*:fwg3:working collision detection between game objects [26/26]
*:fwg3:game has scoring (or lives/timer) and a win/lose condition [26/26]
*:fwg3:game uses at least one texture and one sound [26/26]
*:fwg3:code compiles, cartridge builds with no warning or error [13/13]
*:fwg3:committed project related changes to private semester repo [13/13]
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