Racers-API - a game where you have to go around racing with your car, earning money

Overview

Racers-API

About

Racers API is a game where you have to go around racing with your car, earning money. With that money you can buy cars and progress through the game! You have to combine your coding skills and knowledge to start and finish. Making HTTP requests to the API and getting a response is what you need to learn. You can play Racers API with any language that supports HTTP requests. Learn more in the Documentation section

Documentation

Python

Checking the status of the server:

import requests

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

If it outputs "Racers API is ready to play!" then the server is available. Otherwise, you might get an error. If that happens and all you code is correct, it means the server is likely down.

Getting a key and starting off:

import requests
import json

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

#Getting an API key
username = "hello"
startURL = "https://racersapi.billybob456.repl.co/start/" + username

x = requests.get(startURL)
x = x.content
x = json.loads(x)
key = x["key"]
print(x["message"])

Getting your account information:

import requests
import json

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

#Getting an API key
username = "hello"
startURL = "https://racersapi.billybob456.repl.co/start/" + username

x = requests.get(startURL)
x = x.content
x = json.loads(x)
key = x["key"]
print(x["message"])

account = requests.get("https://racersapi.billybob456.repl.co/account/" + key).content.decode("utf-8")
print(account)

Getting your current car:

import requests
import json
import ast

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

#Getting an API key
username = "hello"
startURL = "https://racersapi.billybob456.repl.co/start/" + username

x = requests.get(startURL)
x = x.content
x = json.loads(x)
key = x["key"]
print(x["message"])

account = ast.literal_eval(requests.get("https://racersapi.billybob456.repl.co/account/" + key).content.decode("utf-8"))
print(account)

currentCar = account["car"]
print(currentCar)

Getting the available races:

...
availableRaces = requests.get("https://racersapi.billybob456.repl.co/available-races/" + key).content.decode("utf-8")
print(availableRaces)

Selecting the race with best difficult:payout ratio:

...
#Selecting the best race with difficulty:payout ratio
litEvalList = ast.literal_eval(availableRaces)
length = len(litEvalList)
for race in litEvalList:
	avgSpeed = race["average top speed"]
	if avgSpeed == currentCar["top speed"]:
		raceNum = litEvalList.index(race)
raceKey = json.loads(availableRaces)[raceNum]["key"]

Racing the selected race:

...
#Racing the selected race
raceURL = "https://racersapi.billybob456.repl.co/race/" + key + "/" + raceKey
raceResults = requests.get(raceURL).content.decode('utf-8')
raceKey = ""
raceResults = ast.literal_eval(raceResults)
key = raceResults["key"] #new key
print(raceResults["message"])

Full script:

import requests
import json
import ast

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

#Getting an API key
username = "hello"
startURL = "https://racersapi.billybob456.repl.co/start/" + username

x = requests.get(startURL)
x = x.content
x = json.loads(x)
key = x["key"]
print(x["message"])

#Getting account information
account = ast.literal_eval(requests.get("https://racersapi.billybob456.repl.co/account/" + key).content.decode("utf-8"))
print(account)

#Getting you current car
currentCar = account["car"]
print(currentCar)

#Getting available races
availableRaces = requests.get("https://racersapi.billybob456.repl.co/available-races/" + key).content.decode("utf-8")
print(availableRaces)

#Selecting the best race with difficulty:payout ratio
litEvalList = ast.literal_eval(availableRaces)
length = len(litEvalList)
for race in litEvalList:
	avgSpeed = race["average top speed"]
	if avgSpeed == currentCar["top speed"]:
		raceNum = litEvalList.index(race)
raceKey = json.loads(availableRaces)[raceNum]["key"]

#Racing the selected race
raceURL = "https://racersapi.billybob456.repl.co/race/" + key + "/" + raceKey
raceResults = requests.get(raceURL).content.decode('utf-8')
raceKey = ""
raceResults = ast.literal_eval(raceResults)
key = raceResults["key"]
print(raceResults["message"])

Well done! You've successfully gone through the basics of Racers API and completed your first race! Below are your next steps.

After getting you new key, you want to save it somewhere! Here's a modified script of the full script that will allow you to continue your game with the new key:

import requests
import json
import ast

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

key = "YOUR KEY HERE!" #put your key in there!

#Getting account information
account = ast.literal_eval(requests.get("https://racersapi.billybob456.repl.co/account/" + key).content.decode("utf-8"))
print(account)

#Getting you current car
currentCar = account["car"]
print(currentCar)

#Getting available races
availableRaces = requests.get("https://racersapi.billybob456.repl.co/available-races/" + key).content.decode("utf-8")
print(availableRaces)

#Selecting the best race with difficulty:payout ratio
litEvalList = ast.literal_eval(availableRaces)
length = len(litEvalList)
for race in litEvalList:
	avgSpeed = race["average top speed"]
	if avgSpeed == currentCar["top speed"]:
		raceNum = litEvalList.index(race)
raceKey = json.loads(availableRaces)[raceNum]["key"]

#Racing the selected race
raceURL = "https://racersapi.billybob456.repl.co/race/" + key + "/" + raceKey
raceResults = requests.get(raceURL).content.decode('utf-8')
raceKey = ""
raceResults = ast.literal_eval(raceResults)
key = raceResults["key"]
print(raceResults["message"])

More documentation coming out soon including how to buy new cars and mod the game to add your own cars!

Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

cocos2d-x Win32 Others cocos2d-x is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications. It is

cocos2d 16.7k Jan 04, 2023
A game developed while learning python

Alien_Invasion a game developed while learning python you must have python-3 installed in your computer. and pygame module is also required for this.

Jani Shubham 0 Oct 10, 2022
Editor for Bioware's Original Neverwinter Nights Game

neveredit This is an import of an old sourceforge project. Neveredit is an editor for Bioware's Neverwinter Nights game. It also includes all the low

Peter Gorniak 2 Apr 12, 2022
WIP python/pygame 2D zombie shooter

2d-shooter project A single/multiplayer co-op survival small space zombie shooter. If you'd like to contribute, feel free to join the discord! INSTALL

36 Dec 08, 2022
Small game I made in 2019 using python/pygame.

Kill-The-Blokk // Shoot or Die This is a small game I made in gr.10 (2019) for my high school computer science class; the game was coded in python usi

1 Nov 13, 2021
Minesweeper clone with 3 modes of difficulty, UI scaling and custom games feature.

Insect Sweeper Minesweeper clone with 3 modes of difficulty, UI scaling and custom games feature. Mines are replaced with random insects that a player

Piotr Data 1 Nov 05, 2021
Utility.py - a utility that offerres cool cli tools and games.

Utilty.py Utility.py is a utility that offerres cool cli tools and games. Currently the offerd games/items are: get the number, countdown, random name

bee-micizi 1 Dec 08, 2021
Discord.py Gaming Bot🎮, for fun & engaging discord minigames

Status 🧭 This Project will not no longer be developed/finished due to a) discord.py's ( main dependency ) discontinuation b) My personal lack of int

Wordsetter 11 Nov 21, 2022
Python Interactive Mini Games

Python Interactive Mini Games Mini projects from Coursera's An Introduction to I

Ashish Choudhary 1 Jan 16, 2022
A script to install a Windows game through GOG on Linux

proton-gog-install A script to install a Windows game through GOG on Linux. Based on this gist. Tested on Arch, might work elsewhere. Requirements: Im

5 Dec 28, 2022
Client-Server design (guess the closest number to the average score game)

Multiplayer game (enter the number closest to the average) Design Client-Server design The client's side is responsible for sending numbers from the g

Adam Piszczek 0 Jun 29, 2022
Fully functional BlackJack game with a graphical user interface.

BlackJack Welcome to BlackJack! This game is fully functional, with a casino sound package integrated using Pygame, dynamic game logic developed using

Shwetang Desai 2 Jan 10, 2022
learn and have fun developing 2D retro games using python and pygame

Retro 2D Game Development Using Python + PyGame Skill up your programming skills with a walk down the memory lane. Learn how to create a retro 2D game

Marvin Trilles 1 Feb 23, 2022
A sprite ripper and converter for Com2uS' 2007 game Music World.

Music World Sprite Dumper This repository contains a python script reads an UNCOMPRESSED Music World pxo file and attempts to dump sprites from it. Th

Buu342 1 Mar 16, 2022
中文版本的ai地牢,一个使用GPT-2的文字冒险游戏,使用清源CPM预训练模型finetune而成。

中文版本的ai地牢,一个使用GPT-2的文字冒险游戏,使用清源CPM预训练模型finetune而成。

icybee 178 Jan 03, 2023
A converter for the .BMR / .RLE bitmap files used in some Neversoft PS1 games.

Requirements python3 pyqt5 - can be installed with pip install PyQt5 pypng - Included Usage Instructions This program can be running py main.py in the

4 Jul 30, 2022
A game that depicts a real astronaut's struggles

Interstel-quickscooping-game Right from the beginning of our (i.e, me and me alone) journey in the creation of this game, our goal was to give a game

Sharath V 3 Jul 12, 2021
It calculates the Nim sum of a nim game.

nim-sum It calculates the Nim sum of a nim game. The rules of Nim The traditional game of Nim is played with a number of coins arranged in heaps: the

2 Jan 02, 2022
This repository has the lessons of the gamming programming course

learning-python-game-programming This repository has the lessons of the gamming programming course Na faculdade, estou fazendo a disciplina de program

Mateus Faustino 1 Nov 16, 2021
An interactive pygame implementation of quadtree spatial quantization

QuadTree-py An interactive pygame implementation of quadtree spatial quantization Contents Installation Usage API Reference TODO Installation Clone th

Ethan 1 Dec 05, 2021