Corning Community College
CSCS2650 Computer Organization
Read through pertinent technical specifications and guides for Vircon32, and implement a functioning snake game that can be played in the emulator.
You will want to go here to edit and fill in the various sections of the document:
The Vircon32: C API reference page may be helpful - http://www.vircon32.com/api.html
For this project, you will be making a Snake game.
The game loop for Snake is simple: you will control a snake around the screen to eat pieces of food. Once a piece of food has been eaten, your score will increase, and the snake will get longer.
The game ends when the head of the snake runs into either a wall, or another part of its body.
Another good option for designing your snake is downloading a photo off the internet(probably an animated/cartoon one). I personally got the following photo “https://pngtree.com/freepng/cartoon-snake_6160039.html” and cropped just the head. I then designed the body off of the colors from the head.
There is obviously your arrow key inputs but there are other buttons available as well. At least for gamepad(0) we have button_?_ = ? for the average keyboard:
For those out there who want the whole experience of gaming, therein lies the ability to plug in a real video game controller, if your system allows (some laptops will at least). To that end, the controls are pretty straight-forward. Either console controller will rely upon the D-pad for movement, and the buttons should map to the controllers as well. For example, 'X' on a playstation controller should correspond to the “a_buttonpress” vircon command. The same should apply to 'A' on an Xbox controller.
If you are just trying to make the input based off of your arrow keys, you can simply copy the same setup:
// Buttons to move up, down, left, and right bool mRight = (gamepad_right() == 1); bool mLeft = (gamepad_left() == 1); bool mUp = (gamepad_up() == 1); bool mDown = (gamepad_down() == 1);
NOTE: You'll want to do this in your game loop (the while loop) and make sure it is inside of main but outside of you game loop have the following:
// Selects keyboard as gamepad to use for input select_gamepad(0);
When making you gamepad you'll make gamepad_direction values, WalkX and WalkY for example purposes.
With those you would probably make it so that when WalkX < 0 var = 1. And then do:
if( var == 1 ) { Snake[0].X -= PlayerSpeed; }
to make your snake constantly move after pressing an arrow key.
you could also set up a switch and do something like the following:
case RIGHT: SHead.X += speed; Break;
Things to note before doing the above. Youll need to create global variables LEFT, RIGHT, UP, and DOWN. In the given example there is a struct named Shead (Stands for snake head). You will also need the following:
// The direction is updated based on given input if (mRight && SHead.Direction != LEFT) { SHead.Direction = RIGHT; }
The “&& SHead.Direction != LEFT” prevents the snake from going back on its self.
The screen on vircon32 is 640 by 360, however, you do not have to type these out every time you make a game in vircon32 as they are stored in the screen_width and screen_height variables respectively. One way of bounds checking is to see where you are about to spawn the snake's head, if it is within the screen window then it is fine. However, if it is outside that window then game over.
To handle motion you could do:
int SnakeX; if( Right) { SnakeX = SnakeX + 20; }
you need the string.h header file
make a variable for the score
make an array to display the score
use the itoa function to convert the data, then use the print_at function to print it on the screen.
you can use the Vircon32 tutorials as a guide to help build and display the strings: https://github.com/vircon32/ConsoleSoftware/tree/main/Tutorials/WritingText
To be successful in this project, the following criteria (or their equivalent) must be met:
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.
I'll be evaluating the project based on the following criteria:
39:mpg0:final tally of results (39/39) *:mpg0:input via gamepad interface [8/8] *:mpg0:proper bounds checking [13/13] *:mpg0:display of snake and objects [9/9] *:mpg0:custom build script and resources [9/9]