I am only a kid and mostly an amateur at Arduino. After reading some project hub projects and learning Arduino, I was inspired to create this fun game. It did not take too much debugging and is really cool. The code is pretty clean by my standards. ENJOY!! Please respect and comment.
Remember to download the libraries included in this program and put them in the directory folder. If there is an error that it cannot find the library, then just use sketch>include library. Comment if you have any problems.
Libraries at https://github.com/PunkyMunky64/HillRun2Libraries
🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)
You have played the Google Chrome "No Internet Dinosaur" game. The LCD Hill Run v2 project mathematically forces that entire, fast-paced side-scrolling video game directly into the agonizingly restrictive 32-character buffer of a standard 16x2 I2C LCD screen, requiring intense custom character creation and high-speed string modification.
Carving Custom Glyphs (Binary Byte Arrays)
The standard LCD font doesn't have a picture of a "Running Man" or a "Cactus." You must literally draw them pixel-by-pixel using binary.
- The 16x2 LCD supports up to 8 custom characters stored in its tiny CGRAM.
- You define the 5x8 pixel grid in pure C++ bytes:
byte runner[8] = {
B01110,
B01110,
B00100,
B11111,
B00100,
B01010,
B01010,
B10001
};
lcd.createChar(0, runner); // Burns the drawing into the LCD memory!
The Side-Scrolling Array Engine
The video game illusion is purely a shifting string sequence.
- The Obstacles: The Arduino generates a massive hidden string (e.g.,
X X X X). - During the
loop(), the code forces the string to physically shift one space to the left every 100 milliseconds usingsubstring(1). - The Player Physics (Interrupts): The player character is always locked at
Column 2. if (digitalRead(jumpButton) == LOW) { playerRow = 0; }(The player instantly jumps to the top row!)- Collision Detection:
if (obstacleString.charAt(2) == 'X' && playerRow == 1)-> The deadly cactus violently hits the player on the bottom row! Game Over!
Gaming Hardware Needs
- Arduino Uno/Nano (Standard architecture).
- 16x2 Character LCD Display with I2C Backpack (I2C reduces the wiring from 16 confusing parallel pins down to just 4 simple jumper wires!).
- A highly responsive Arcade Tactile Push Button.
- A Passive Piezo Buzzer to play jumping sound effects and the final crash noise!