Decides when to start a game, based on who's holding a button.
Project description
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)
Built Distributions
game_starter-1.0.0-py3.6.egg
(1.7 kB
view hashes)
Close
Hashes for game_starter-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cef9efeb3c87e28c8e5ac3ea9c47d444e8a858bc5a690a94b331ca5b153a96e |
|
MD5 | 9d361e5fb8818e6e653f96c8d5ff03fd |
|
BLAKE2b-256 | fcd6beb5e034c232bf5e248a8fda894911d81c1d75bd0714d904a5e076584944 |