

Int oppositeDirection(int input1, int input2) SetConsoleCursorPosition(hStdOut, homeCoords) * Fill the entire buffer with the current colors and attributes */Ĭsbi.wAttributes, //Character attributes to useĬellCount, //Number of cells to set attribute &count //receives the number of characters written (TCHAR) ' ', //character to write to the buffer HStdOut, //handle to console screen buffer If (!GetConsoleScreenBufferInfo(hStdOut, &csbi)) return ĬellCount = * * Get the number of cells and cell attributes in the current buffer */ SetConsoleCursorPosition(hStdOut, coord) If (hStdOut = INVALID_HANDLE_VALUE) return HStdOut = GetStdHandle(STD_OUTPUT_HANDLE) Int input = RIGHT //global variable to take in the user's input (0, -1) is UP (because the row number increase from top to bottom) direction array, for use with RIGHT, UP, LEFT, DOWN constants negative values represent areas that cannot be touched or else game over Thereafter, we will create the display by changing those numbers into something that we can visualize and understand.
SCREEN SNAKE PLUS CODE
The code for the Snake program shown in the video above is shown below here! I will explain it in detail below too! The main idea is to create a mathematical layer where each number represent the wall, snake, food, etc. So, Enjoy the game! Oh, please press in case something acts up. It will probably prompt a warning for virus but don’t worry about that because ThePoorEngineer has no interest in infecting your computer or anything.
SCREEN SNAKE PLUS WINDOWS
* The attached file only works in the windows operating system. If you are learning C++ programming, I would say that this exercise would be very beneficial to you, and it is fun as well! Below is a video on the Program, and here is the EXECUTABLE FILE. It might seem complicated at first but it is actually quite simple. In order to do this, I decided to recreate the old Snake game from the Nokia phone using C++. Both the Arduino IDE and Qt programming (my work in the ARC Lab in NUS requires me to use Qt) uses C++ so I thought it might be good to revise the lecture notes, and also pick up C++ programming along the way. Tft.I had a class on Programming methodology during my 1st semester in NUS which uses the C language. println( "Couldn't start touchscreen controller ") Snake's speed between movement(miliseconds) Size of the snake (on proper situation it would be 22x23=506 positions of the grid, though it's limited by arduino's memory
SCREEN SNAKE PLUS PLUS
The display also uses hardware SPI, plus #9 & #10Īdafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC) The STMPE610 uses hardware SPI on the shield, and #8Īdafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS) This is calibration data for the raw touch data to the screen coordinates # include // this is needed even tho we aren't using it

* Adafruit-GFX-Library(Graphics Library):

* Adafruit_ILI9341(Screen controller library): * MIT license, all text above must be included in any redistribution * Snake game for Arduino Uno and Adafruit 2,8" touch screen for Arduino
