Skip to main content

Decides when to start a game, based on who's holding a button.

Project description

Build Status Coverage Status

To see a demo of the game start, clone, then run python3 -m GameStarter.gamestart

There are also some test cases that test that the class handles some simple invalid configurations correctly and that it can handle the various imperfections of the humans that want to start a game. Run the tests with ./gamestart_test.py

To use this code:

  • import it
	from gamestart import GameStarter
  • instantiate the GameStarter class
	gs = GameStarter(max players, activation threshold, start threshold, grace time)
	#eg...
	gs = GameStarter(4, 2.0, 5.0, 0.5)
  • then report whenever a player pushes or releases a button:
	gs.push(0)	#report button push for first player
	gs.release(1)	#report button release for second player
  • regularly update the internal timer at the desired resolution:
	gs.timeStep(0.05) #Step 0.05 seconds, call this every 0.05 seconds (for example)
  • then you can see if you have enough players ready like so:
	if gs.shouldStart() : #we have enough players to start
  • you can get an exact number with this:
	gs.totalStartablePlayers()
  • and you can loop through all players to see if each one is joining in:
	for i in range(4):
		if gs.isStartablePlayer(i):
			#add player i to game

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

game-starter-1.0.0.tar.gz (1.8 kB view hashes)

Uploaded Source

Built Distributions

game_starter-1.0.0-py3.6.egg (1.7 kB view hashes)

Uploaded Source

game_starter-1.0.0-py3-none-any.whl (1.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page