0% found this document useful (0 votes)
241 views2 pages

ESP32 OLED Chrome Dino

The document describes a simple Chrome Dino game implemented on an ESP32 with an OLED display. It includes the game code that handles the dino's jumping mechanics and obstacle movement. The conclusion suggests potential enhancements such as scoring and sound effects.

Uploaded by

tempmail040404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
241 views2 pages

ESP32 OLED Chrome Dino

The document describes a simple Chrome Dino game implemented on an ESP32 with an OLED display. It includes the game code that handles the dino's jumping mechanics and obstacle movement. The conclusion suggests potential enhancements such as scoring and sound effects.

Uploaded by

tempmail040404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ESP32 OLED Chrome Dino Game

Introduction
A simple dino running game where the player jumps over obstacles.

Game Code
#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64

#define OLED_RESET -1

#define BTN_JUMP 18

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

int dino_y = 50, dino_dy = 0;

int obstacle_x = 128;

void setup() {

pinMode(BTN_JUMP, INPUT_PULLUP);

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

void loop() {

display.clearDisplay();

// Draw dino
display.fillRect(10, dino_y, 10, 10, WHITE);

// Draw obstacle

display.fillRect(obstacle_x, 50, 10, 10, WHITE);

// Move obstacle

obstacle_x -= 3;

if (obstacle_x < 0) obstacle_x = SCREEN_WIDTH;

// Dino jump

if (digitalRead(BTN_JUMP) == LOW && dino_y == 50) dino_dy = -5;

dino_y += dino_dy;

if (dino_y < 30) dino_dy = 3;

if (dino_y >= 50) dino_y = 50;

display.display();

delay(50);

Conclusion
This game demonstrates how to use ESP32 and an OLED display for interactive graphics and

gameplay. You can enhance it by adding more features like scoring, sound effects, and difficulty

levels.

You might also like