Giter Club home page Giter Club logo

red_light_green_light's Introduction

This repo is a python implementation of red light green light game in Squid game.

  • It is a simple game where a player is supposed to move when the doll turns back and green light is turned on, And stop when it displays red light.
  • If a player is caught moving when there is a red light, then the player is dead.
  • How ever there is also a time-limit to reach the winning position and player is expected to reach before the timer runs out.

Implemention OverView.

  • This game uses pygame module which is a 2D game library for python.
  • It uses a thread based implementation, Since there are many things to handle parallely. Basically there are 4 threads init_thread, timer_thread, player_thread, doll_thread.
  • Let me explain the idea on a high level behind each thread. init_thread: This is the initialiser thread, sets the initial position for the player, turns the backgroud music and listens for keys pressed by the player. When ever any key is pressed the desired location is inserted into the Queue for the player_thread to consume and update its position. timer_thread: This thread only does the countdown of time. Currently set to 90 secs. if the timer runs-out it signals the other threads to stop. player_thread: This listens for player positions to set when any key is pressed from the queue. It is the init_thread job to push to the queue the ne location of the player. doll_thread: This thread swaps the doll front, doll back, red light, green light images on the screen. Pauses the background music when there is a red light.

How to play:

  • Once the project is cloned, just run python3 red_light_green_light.py

Demo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.