Programming Assignment 2

From MWCSWiki

Jump to: navigation, search

UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY

GAME PROGRAMMING ASSIGNMENT #2 Due Date:

Submission: Must submit all files, prior to the beginning of class, in a zipped fashion to japwahl@gmail.com. Must have an exe file, I do not want to compile everything. Must submit a hard copy of the program at the start class.

Description: Create a game that challenges the player’s memory. The first part of the game will randomly display 4 objects in a specific grid fashion for 10 seconds. These figures will then disappear and the user will have 10 different objects located at the bottom of the screen and must recreate the grid by placing the objects in the appropriate location. Once they think they have put each object in the appropriate location they will click on the green square button to check their memory skills. If they are wrong, the correct pattern is shown and then the game slowly fade out and quits, if they are correct they proceed to the next level (6 object 10 seconds). Level 3 is 8 objects 10 second. Level 4 is 10 objects 10 seconds (This is the highest level)

Sample Show & Tell Screen that would appear for 10 seconds

Sample Play Screen


Details:

Game Logic

You will need to have two two-dimensional arrays to represent the first two rows, the playing area. One of the arrays will represent the actual pattern and the second array will represent the guess pattern

• enum game_objects {black_rec, blue_parr, purple_diamond, grey_tri, orange_rect, red_oct, yellow_tri, tan_diamond, purple_oct};

• game_objects pattern;

• game_objects guess;

• You will need a get_shape function that given a box number (index) it gets what is in that box in either the patter or guess.

• You will need a set_shape function that given a box number and shape will fill in the pattern and guess.

• You will need a function that compares the guess and pattern.

• You will need a function to reset/clear the game.

• You will need a random_create function that given the number of images needing to be generated. The objects will be randomly generated and randomly placed in the grid.

Graphics Logic

• Get_Mouse_Input: Will use an if else if statement to figure out what box is being selected. o During the game play you must keep track of two click patterns. First click must select an object from the selection bar; the second must be on the draw grid.  On the first mouse click you must set a global variable indicating the shape (enum type) that was selected  On the second mouse click if it is a valid location you will set_shape and the draw_objects o On exception when the mouse clicks on the green rectangle on the bottom right corner then this is submitting the guess to be check for accuracy, calls compare  If compare is true then you step up to the next level, call reset/car and then random_create  If compare is false then you black out the screen and end the game. • Draw_Objects: Giving an x and y location it will draw the appropriate object. The x and y are the center of the box that was selected; you can draw any object knowing the center of a box. Will call get_shape to figure out which shape is suppose to be drawn and then call one of the following draw functions, must pass the x and y location. o Draw_Octagon o Draw_Triangle o Draw_Diamond o Draw_Rectangle o Draw_Parrallelogram • Draw_Grid: Draws the 2 * 5 Grid, must be draw ever times. • Draw_Object_Selection_Bar: Draws the constant bar on the bottom


The only global variables that you can have are • int mx,my;

A list of things you must adhere to when programming: • You must use C or C++. • Your program must use modular programming techniques. • You must fully document your program • Variable names must be consistent with the functionality of the variable with the exception of loop counters • Function names must be consistent with the functionality of the function • You must adhere to the programming styles outlined in you syllabus packet • You must have error checking, i.e. incorrect file name, file does not exist, array bounds • Sufficiently test your program

I will be using a program called moss to compare everyone’s program in the class to everyone else program. It will catch any kind of copying, even if you change indentation and/or variable names.

Personal tools