Compare commits
2 Commits
2deb001322
...
5a62ca10d0
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a62ca10d0 | |||
| ccf08724ab |
27
game.py
27
game.py
@ -1,6 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import pygame
|
import pygame
|
||||||
from random import randint
|
import random
|
||||||
import gameUtils
|
import gameUtils
|
||||||
|
|
||||||
#Oh god here we go. I'm gonna screw up this entire thing
|
#Oh god here we go. I'm gonna screw up this entire thing
|
||||||
@ -26,7 +26,9 @@ class Game(gameUtils.Game):
|
|||||||
# and should have an animation accompanying it.
|
# and should have an animation accompanying it.
|
||||||
# see Brosef for the animation.
|
# see Brosef for the animation.
|
||||||
|
|
||||||
self.turnHandler = gameUtils.RoundTable(1, self.pm)
|
# TODO: Add a hook to see if the current player has become inactive.
|
||||||
|
playerName = random.choice(list(self.pm.keys()))
|
||||||
|
self.currentlyPlaying = self.pm[playerName]
|
||||||
|
|
||||||
#Sounds for the gun :3
|
#Sounds for the gun :3
|
||||||
self.playSound = pygame.mixer.Sound.play
|
self.playSound = pygame.mixer.Sound.play
|
||||||
@ -68,7 +70,7 @@ class Game(gameUtils.Game):
|
|||||||
#I feel horrible writing this code this feels super unoptimised :c
|
#I feel horrible writing this code this feels super unoptimised :c
|
||||||
# Bro I'm gonna be honest, there's not much I'd change about that, you're good.
|
# Bro I'm gonna be honest, there's not much I'd change about that, you're good.
|
||||||
# The only thing I can think if just moving `set_volume()` to after both if statements.
|
# The only thing I can think if just moving `set_volume()` to after both if statements.
|
||||||
self.musicNumber = randint(1,2)
|
self.musicNumber = random.randint(1,2)
|
||||||
if self.musicNumber == 1:
|
if self.musicNumber == 1:
|
||||||
pygame.mixer.music.load("./assets/surrounded.ogg")
|
pygame.mixer.music.load("./assets/surrounded.ogg")
|
||||||
self.playMusic(-1)
|
self.playMusic(-1)
|
||||||
@ -78,12 +80,20 @@ class Game(gameUtils.Game):
|
|||||||
self.playMusic(-1)
|
self.playMusic(-1)
|
||||||
pygame.mixer.music.set_volume(0.5)
|
pygame.mixer.music.set_volume(0.5)
|
||||||
|
|
||||||
|
def nextPlayer(self):
|
||||||
|
playerIndex = list(self.pm.keys()).index(self.currentlyPlaying.name)
|
||||||
|
playerIndex += 1
|
||||||
|
if playerIndex >= len(self.pm):
|
||||||
|
playerIndex = 0
|
||||||
|
playerName = list(self.pm.keys())[playerIndex]
|
||||||
|
self.currentlyPlaying = self.pm[playerName]
|
||||||
|
self.popup('Next player', f'Pass shocker to {self.currentlyPlaying.name},\nthen press R-CTRL+ENTER to continue.')
|
||||||
|
|
||||||
def fire(self):#LETS GO GAMBLING
|
def fire(self):#LETS GO GAMBLING
|
||||||
if randint(1,6) == 6:
|
if random.randint(1,6) == 6:
|
||||||
self.playSound(self.gunShot)
|
self.playSound(self.gunShot)
|
||||||
self.turnHandler.playing[0].punish(self.shockScale)
|
self.currentlyPlaying.punish(self.shockScale)
|
||||||
print(f'{self.turnHandler.playing[0].name} is fucking dead.')
|
print(f'{self.currentlyPlaying.name} is fucking dead.')
|
||||||
return 0.04
|
return 0.04
|
||||||
#remember to add shock
|
#remember to add shock
|
||||||
else:
|
else:
|
||||||
@ -112,14 +122,13 @@ class Game(gameUtils.Game):
|
|||||||
self.playSound(self.gunSpin)
|
self.playSound(self.gunSpin)
|
||||||
elif event.type == gameUtils.AnimFinish:
|
elif event.type == gameUtils.AnimFinish:
|
||||||
if event.objectID == self.gun.objectID and event.animationID == 'spin':
|
if event.objectID == self.gun.objectID and event.animationID == 'spin':
|
||||||
self.timeout("FireDelay",randint(750,2000)/1000)
|
self.timeout("FireDelay",random.randint(750,2000)/1000)
|
||||||
self.playSound(self.gunCyclinderStop)
|
self.playSound(self.gunCyclinderStop)
|
||||||
|
|
||||||
elif event.type == gameUtils.Timeout and event.timeoutID == 'FireDelay':
|
elif event.type == gameUtils.Timeout and event.timeoutID == 'FireDelay':
|
||||||
self.shockScale += self.fire() #check if the user gets shot
|
self.shockScale += self.fire() #check if the user gets shot
|
||||||
self.shockScale = min(self.shockScale, 1) #keeps shockScale in bounds
|
self.shockScale = min(self.shockScale, 1) #keeps shockScale in bounds
|
||||||
self.turnHandler.next()
|
self.nextPlayer()
|
||||||
self.popup('Next player', f'Pass shocker to {self.turnHandler.playing[0].name},\nthen press R-CTRL+ENTER to continue.')
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user