Chrome Dino Game Player

The Chrome Dino Game Player application is an innovative Python project that combines hardware and software to bring a new dimension to the classic Chrome Dino Game. In this project, an SMD Motor Driver, a DC Motor, and an add-on Ambient Light Module work together to create a dynamic and immersive gaming experience.

Project Key Components:

  1. SMD Motor Driver:

    • The SMD Motor Driver serves as the interface between the Python script and the DC Motor. It translates commands from the script into actions that control the movement of a physical element in response to events in the game.

  2. DC Motor:

    • The DC Motor is connected to the SMD Motor Driver and serves as the physical actuator. It is responsible for performing actions based on the gameplay, such as moving a physical obstacle or character.

  3. Ambient Light Module Add-on:

    • An additional Ambient Light Module is integrated into the project to capture the ambient light conditions. This module adds a dynamic lighting effect to the gaming experience, reacting to in-game events or creating atmospheric changes.

  4. Python Script:

    • The Python script is the heart of the application. It communicates with the game (potentially using web scraping or game APIs), interprets game events, and sends commands to the SMD Motor Driver and Ambient Light Module to synchronize the physical and visual elements.

Project Key Features:

  1. Dynamic Obstacle Movement:

    • The DC Motor, controlled by the SMD Motor Driver, can be programmed to move a physical obstacle or character in sync with the game's virtual elements. For example, it could simulate jumping over obstacles or navigating the game environment.

  2. Ambient Lighting Effects:

    • The Ambient Light Module adds a layer of immersion to the gaming experience by dynamically adjusting the lighting based on in-game events. It could change colors during different gameplay phases, flash in response to obstacles, or create a dynamic ambiance.

  3. Responsive Gameplay:

    • The Python script continuously monitors the game's state and triggers actions on the hardware components accordingly. This creates a responsive and interactive gaming experience where physical elements mirror the virtual world in real-time.

Project Wiring Connection:

Getting Started:

  1. Hardware Setup:

    • Connect the DC Motor to the SMD Motor Driver following the provided documentation.

    • Integrate the Ambient Light Module into the setup, ensuring secure connections.

  2. Software Integration:

    • Implement the Python script to interact with the Chrome Dino Game. This may involve using web scraping techniques or interfacing with the game's API.

    • Utilize the SMD Motor Driver library to control the DC Motor's movement based on game events.

    • Integrate the Ambient Light Module library to control the ambient lighting effects.

  3. Run the Application:

    • Execute the Python script, launching the Chrome Dino Game Player application.

    • Observe how the physical elements (DC Motor) and ambient lighting respond to the virtual events in the game, creating a unique and engaging gaming experience.

Project Codes:

from smd.red import *

SerialPort = "COM3"         # Serial port of the USB gateway module
baudrate = 115200           # Baud rate of communication
ID = 0                      # ID of the SMD board
ambient_module_id = 1       # ID of the ambient light module

master = Master(SerialPort, baudrate)       # Defines the USB gateway module
master.attach(Red(ID))                      # Gives acces to the SMD of specified ID

master.set_shaft_rpm(ID, 100)                               # Sets the RPM value of the motor
master.set_shaft_cpr(ID, 6533)                              # Sets the CPR value of the motor

master.set_operation_mode(ID, 1)                            # Sets the operation mode to 'Position Control'
master.set_control_parameters_position(ID, 10, 0, 8)        # Sets the PID parameters, can be auto-tuned instead
master.enable_torque(ID, 1)                                 # Enables the motor to spin if any command say so

while True:
    light = master.get_light(ID, ambient_module_id)         # Variable to store the ambient light data
    print(light)                                            # Printing the value to observe

    if light < 30:                          # If it sees obstacles, which are black, so will emit less light than other colors
        master.set_position(ID, 1000)       # Motor goes to the spacebar key location, change position value if it doesn't reach
        time.sleep(0.2)
        master.set_position(ID, 0)          # Motor goes back to the start position
        
    else:
        master.set_position(ID, 0)          # Stays at the start position if there are no obstacles

Last updated