กลับไปหน้ารวมไฟล์
lcd-hill-run-v2-runner-game-586d0f.md

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.

  1. The 16x2 LCD supports up to 8 custom characters stored in its tiny CGRAM.
  2. 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 using substring(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!

ข้อมูล Frontmatter ดั้งเดิม

title: "LCD Hill Run v2 Runner Game"
description: "A simple LCD screen game where you jump over hills and duck under crows with buttons."
author: "PunkyMunky64"
category: "Gadgets, Games & Toys"
tags:
  - "fun"
  - "games"
  - "lcd screen"
views: 44070
likes: 86
price: 1120
difficulty: "Intermediate"
components:
  - "20x Jumper wires (generic)"
  - "1x Standard LCD - 16x2 White on Blue"
  - "2x Pushbutton switch 12mm"
  - "1x Breadboard (generic)"
  - "2x Resistor 10k ohm"
  - "1x Buzzer"
  - "1x Rotary Potentiometer, 10 kohm"
  - "1x Arduino Mega 2560"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles:
  - "https://projects.arduinocontent.cc/f240df2a-ca91-4b22-b5eb-1edf40168801.ino"
documentationLinks: []
passwordHash: "74fb81d49867209ab8eea4008278d677cdf0de8511e9d72168e063e51851921c"
encryptedPayload: "U2FsdGVkX197hjqYVxc7Xm4WVfzQLgyeuI3fynBRWxEqsfE4UlGelGbccQ6YFlQFi5i7lbLrgVFQ6rsyQzLaU5B8fFj10MLAZbKnNwQZuvg="
seoDescription: "Play LCD Hill Run v2 Runner Game. Jump over hills and duck under crows on an LCD screen using buttons."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/lcd-hill-run-v2-runner-game-586d0f_cover.jpg"
lang: "en"