The basic principle of the Google Chrome Dinosaur (Dino) game is to provide an endless, simple runner experience that challenges the player’s timing and reflexes. Here’s a breakdown of the core concepts:
1- Endless Runner Concept
Automatic Movement:
The dinosaur character continuously runs forward. The game world (usually a desert landscape) scrolls from right to left, giving the illusion of forward movement even though the dinosaur’s horizontal position remains mostly fixed.
Infinite Play:
There is no defined “end” to the game. The challenge comes from the increasing pace and frequency of obstacles rather than reaching a final goal.
2- Single Control Mechanism
Jumping Action:
The only action the player can perform is to make the dinosaur jump. This is typically triggered by a simple input (such as pressing the spacebar or the up arrow key).
Gravity and Timing:
The jump is governed by a simple physics simulation where gravity brings the dinosaur back to the ground. The player must time the jump carefully to clear obstacles.
3- Obstacles and Difficulty
Randomly Generated Obstacles:
Various obstacles (most commonly cacti, and later, pterodactyls) appear in the dinosaur’s path. These obstacles come at varying distances and sizes, requiring the player to react quickly.
Increasing Challenge:
As the game progresses, the speed of the scrolling background increases, and obstacles may appear more frequently or in different patterns, making it progressively harder to avoid collisions.
Collision Detection:
The game continuously checks whether the dinosaur has collided with an obstacle. A collision ends the game, prompting a “Game Over” state.
4- Scoring System
Distance or Time-Based Score:
The player’s score increases as the dinosaur runs further. Typically, the score is based on the distance covered or the number of obstacles successfully avoided.
Speed Increases and Milestones:
As the player’s score increases, the game often introduces changes such as speed boosts, which add to the challenge.
The Google Chrome Dinosaur game is built around an endless running loop where the player controls a continuously moving dinosaur by using a single jump action to avoid obstacles. Its design is focused on simplicity, gradual increase in difficulty, and a straightforward scoring system, making it both easy to play and challenging to master. This minimalistic yet engaging gameplay is what has made the Chrome Dino game a memorable and widely recognized experience during offline moments.
Dinausore is a simplified, endless runner game inspired by the Google Chrome Dinosaur game. In this version, the dinosaur is represented by a character (for example, the letter "D") on a 16×2 LCD, and obstacles (such as the letter "O") move across the screen. The player makes the dinosaur jump by pressing a push button, while a buzzer provides sound cues for actions like jumping or collisions.
How It All Works Together ?
1. Game Initialization:
The ESP32 initializes the I²C connection and sets up the LCD using lcd_api.py
and i2c_lcd.py
. It also configures the push button (with
an internal pull-up) and the PWM output for the buzzer.
2- Game Loop:
Input:
The ESP32 continuously reads the push button. When the button is pressed (active low), the code sets a “jump” flag.
Game State Update:
The dinosaur (represented by “D”) is normally drawn on the bottom row (the “ground”).
When a jump is triggered, the dinosaur moves to the top row (the “air”) for a fixed number of cycles (simulating a jump) before returning to the ground.
An obstacle (represented by “O”) moves from right to left on the ground. When it reaches the left edge, it resets to the right side and the player’s score increases.
The program checks for a collision. If the obstacle reaches the dinosaur’s column while the dinosaur is on the ground, it’s a collision.
Audio Feedback:
A short, high-frequency beep is played when a jump is initiated.
A collision triggers a longer or lower-frequency beep.
Display Update:
The LCD is cleared and updated on each loop iteration to show the dinosaur’s current position, the obstacle’s position, and the score.
In case of a collision, a “GAME OVER” message is displayed along with the final score before the game resets.
3- Game Over and Reset:
When a collision is detected, the game signals it with a sound and a message on the LCD. After a short pause, the game variables are reset
and the game starts again.
ESP32 Microcontroller
Role:
- Serves as the game’s “brain” by running the MicroPython code.
- Reads input from the push button.
- Drives the LCD (via I²C) using libraries such as lcd_api.py
and i2c_lcd.py
.
- Controls the buzzer with PWM to produce sound effects.
LCD I²C Screen (16×2)
Role:
Provides the visual display for the game.
Displays a minimalistic “scene” with two lines of text. For example:
- A character (say D) represents the dinosaur.
- Another character (say O) represents an obstacle.
- The score and messages (like “GAME OVER”) are also shown.
Push Button
Role:
Acts as the game’s sole user input.
When pressed, it makes the dinosaur jump.
Buzzer
Role:
Provides audio feedback to the player.
Plays a short beep when the dinosaur jumps.
Emits a different sound when a collision (game over) occurs.
Jumper Wires
Jumper wires will be used to make connections between the components.
Breadboard:
A breadboard can be used to create a temporary circuit for testing and prototyping.
ESP32 → LCD I2C screen
SDA → GPIO 21
SCL → GPIO 22
VCC → 5V
GND → GND
ESP32 → Push button
One leg of the push button → GPIO 19
Another leg of the push button → GND
ESP32 → Buzzer
(+) terminal of buzzer → GPIO 23 (PWM)
(-) terminal of buzzer → GND
Below is a condensed outline of what the MicroPython code might look like. (Note that this code uses the two libraries "i2c_lcd" and "lcd_api"for the LCD; make sure these are loaded onto your ESP32.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
from machine import I2C, Pin, PWM import time from lcd_api import LcdApi from i2c_lcd import I2cLcd # ---------- Hardware Setup ---------- # I2C and LCD (adjust the I2C pins and address as needed) i2c = I2C(scl=Pin(22), sda=Pin(21), freq=400000) I2C_ADDR = 0x27 # Change as needed for your LCD lcd = I2cLcd(i2c, I2C_ADDR, 2, 16) # Button (active low) button = Pin(19, Pin.IN, Pin.PULL_UP) # Buzzer setup (PWM capable pin) buzzer_pin = Pin(23, Pin.OUT) # ---------- Game Variables ---------- DINO_COL = 2 GROUND_ROW = 1 AIR_ROW = 0 JUMP_FRAMES = 3 dino_row = GROUND_ROW jumping = False jump_counter = 0 obstacle_col = 15 score = 0 # ---------- Buzzer Sound Function ---------- def beep(freq=1000, duration=0.1): buzzer = PWM(buzzer_pin) buzzer.freq(freq) buzzer.duty(512) time.sleep(duration) buzzer.deinit() # ---------- Main Game Loop ---------- while True: # Check button for jump (if pressed and dinosaur is on the ground) if not button.value() and not jumping and dino_row == GROUND_ROW: jumping = True jump_counter = JUMP_FRAMES beep(1500, 0.05) # Jump sound if jumping: dino_row = AIR_ROW jump_counter -= 1 if jump_counter <= 0: jumping = False dino_row = GROUND_ROW else: dino_row = GROUND_ROW # Move obstacle leftwards obstacle_col -= 1 if obstacle_col < 0: obstacle_col = 15 score += 1 # Refresh LCD display lcd.clear() # Display score lcd.move_to(10, 0) lcd.putstr("S:" + str(score)) # Draw the dinosaur lcd.move_to(DINO_COL, dino_row) lcd.putstr("D") # Draw the obstacle (if within visible range) if 0 <= obstacle_col < 16: lcd.move_to(obstacle_col, GROUND_ROW) lcd.putstr("O") # Collision detection if dino_row == GROUND_ROW and obstacle_col == DINO_COL: beep(500, 0.2) # Collision sound lcd.clear() lcd.putstr("GAME OVER") lcd.move_to(0, 1) lcd.putstr("Score:" + str(score)) time.sleep(2) # Reset game variables dino_row = GROUND_ROW jumping = False obstacle_col = 15 score = 0 continue time.sleep(0.2) |
Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info