Snake Game Corbett Crook and Chris Rice Our Project ● We chose to recreate the classic snake game ● However, due to limitations of the HCS12 we had to modify our original design to create an original game inspired by snake. How we changed it ● For our variation, the snake does not grow. Instead it becomes faster every time you eat. ● The goal is to eat as much food as you can without running into a wall. Hardware ● Graphic LCD from SparkFun ● HCS12 Microcontroller ● Pushbuttons ● Logic Level Converter (MAX232) Schematic Software Goals ● Communicate with the LCD via the SCI. ● Check for button presses periodically using the RTI system. ● Create game logic for the snake Snake Logic ● To draw snake segments we need to store an x and y position of the pixel and the direction that pixel should move on the next frame ● When a new frame is drawn the direction value on the 0th pixel of the snake (the head) Is copied to the second pixel, and the old value of the second pixel is copied to the third pixel, and so on propagating down the length of the snake vector ● The direction value of the snakehead is determined by a direction flags, which are set when a player pushes a button Get Input From User ● We used the RTI system to get input from the user on how the snake should move ● At regular time intervals the system checks for a button press from the user and sets the appropriate flag ● The system interrupt timing is set so that it should always be able to catch a button press during the time during which the user holds the button down Draw Snake Segments ● We used the putCharSCI function from previous labs to put ASCII characters into the SCIDRL register ● Then functions were created to clear the screen and draw snake and food pixels, using special commands included with the sparkfun LCD chip ● Loops in our main function called these functions each time it needed to draw or erase a pixel on the screen Conclusion Just like many great video game classics hardware limitations actually contributed to the game design by creating challenges for us to work around We feel like this game captures the spirit and fun of the original snake without being the same game. It is enjoyable and entertaining for everyone Not only that but we also learned a few new tricks with the HCS12 in addition to using our old ones in order to complete this project