*This code will only work on an OSU FEH Proteus controller. *
Important variables:
int xchicken – The x-coordinate of the chicken
int ychicken – The y-coordinate of the chicken
int ChickenColor – The color of the chicken, can be changed in the store
int xcars[], ycars[], dircars[] – Contains the x-coordinates, y-coordinates, and direction of each of the 15 cars on the map
int speed – The speed of the cars in pixels per refresh
int rate – The refresh rate of the screen
int level – The current level of the game the user is on
bool GameFlag – True if currently playing the game, false when there is a game over
bool LevelFlag – True if currently in a level, false if transitioning to the next level
World world – The one instance of the class World, contains all functions and many variables
Functions:
World() – Constructor, sets speed, rate, and level equal to their starting values
void nextLevel(ButtonBoard) – Sets up the next level, waits until user presses button before moving to next level
void chickenUpdate(int) – Changes the chicken’s coordinates based on the direction parameter sent to the function
void carsUpdate() – Changes the coordinates of all cars
void screenUpdate(int) – Draws the cars and chicken onto the screen. Takes the chicken’s color as a parameter
void checkCollisions() – Checks all chicken coordinates with all car coordinates to see if there’s a collision. If so, set LevelFlag and GameFlag equal to false to indicate a game over
bool checkGameFlag() – Returns the boolean value of GameFlag
bool checkLevelFlag() – Returns the boolean value of LevelFlag
int checkLevel() – Return the integer value of level
void reset() – Reset speed, rate, and level equal to their starting values after a game over
The program performs as intended, but there are issues with the refresh rate of the Proteus controller. Because the controller only has so much processing power, the refresh rate is kept low, resulting in button presses sometimes being unresponsive and the graphics to be spotty.