--Originally published at Programming the city
Hello guys.
My friend Gustavo Hinojosa and I did the snake game, like the one that was installed in the Nokia 3310.
First of all, we tried to make the code in atom and run it in the cygwin terminal, but the specifications of the coordinates were wrong. Cygwin didn’t respected the specifications, that’s why we started doing the code in the IDE named CodeBlocks.
First of all we added all the libraries, “Windows.h” was to include the specifications of the coordinates. Later, we added all the variables and the keys of the board to indicate which buttons the program had to take.
Then, we created the functions, this was the hardest part and the most difficult too. First we created the gotoxy function, We could did that function because we asked for help in Google, this function helped us to make the coordinates specifications.
Later that day, we created another eight functions, pintar: it was to build the square where the snake is eating, guardar_posición: it is to sabe the position where the snake crashed, dibujar_cuerpo: is to créate the whole body of the snake, teclear: is to indicate which buttons we needed to use, cambiar velocidad: is to increase the speed of the snake every time it eats, comida: is to put a random place for the food, game over: is to end the game and puntos: is to show the score the user has done.
Finally we created the main function with a small menu which included an image of the snake and the options “1. Jugar 2.Salir” and after that, we added the functions.
Here is the amazing code!
And here is the snake Game!