Giter VIP home page Giter VIP logo

cli-race's Introduction

CLI-Based Two-Player Vehicle Racing Game in PHP

This project is a simple command-line interface (CLI) based two-player racing game implemented in PHP. Players can choose a vehicle from a list provided in a vehicles.json file. Each vehicle has a maximum speed, and the application calculates the time taken by each vehicle to complete a given distance(It's being set as default to 100 kms) based on its speed. The winner is then declared based on the race results.

Core Features

  1. Vehicle Selection: Load the list of available vehicles from the vehicles.json file and allow two players to select a vehicle each.
  2. Race Simulation: Run a race using the selected vehicles.
  3. Time Calculation: Calculate the time taken by each vehicle to complete the race based on its speed.
  4. Winner Declaration: Determine and display the winner based on the race results.
  5. Race Statistics: Display the time taken by each vehicle to finish the race.

Usage (how to play)

  1. clone the project. (make sure to place it where you can run php).
  2. in the root directory of the project execute this command in the terminal
php ./public/index.php
  1. You will face this:
Welcome to the CLI Racing Game!
** Choose your vehicle: **
1. Car (150 km/h)
2. Motorcycle (200 km/h)
3. Bus (100 km/h)
4. Bicycle (30 km/h)
5. Jet Ski (92.6 km/h)
6. Speed Boat (129.64 km/h)
7. Yacht (37.04 km/h)
8. Helicopter (259.28 km/h)
9. Airplane (898.22 km/h)
10. Hot Air Balloon (9.26 km/h)
Player 1, choose your vehicle (1-10):
  1. choose a number between 1-10
  2. do it again for the player two
  3. The race will begin and the winner and race statistics will appear.

p.s: The speed numbers are being converted to km/h for the sake of simplicity in comparison

p.s: I know that this game may be boring. It's for the sake of OOD and not for entertainment! :)

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.