Unlocked to the gun from the framerate. I told you lot to do this from the beginning. Fuck every last one of you.

This commit is contained in:
2025-06-20 19:27:42 +01:00
parent 4abb2353e1
commit 894ac59038

31
game.py
View File

@ -39,17 +39,20 @@ class Game(gameUtils.Game):
self.gunLoad = pygame.mixer.Sound("./assets/gun-load.mp3") self.gunLoad = pygame.mixer.Sound("./assets/gun-load.mp3")
self.gunCyclinder = pygame.mixer.Sound("./assets/gun-cylinder-stop.mp3") self.gunCyclinder = pygame.mixer.Sound("./assets/gun-cylinder-stop.mp3")
self.gun = pygame.load_animation('./assets/gun-spin.webp') #self.gun = pygame.load_animation('./assets/gun-spin.webp')
self.gunFlash = pygame.image.load("./assets/muzzleflash.png") self.gunFlash = pygame.image.load("./assets/muzzleflash.png")
self.gun = self.createAnimObj('gun', './assets/gun-base.png')
self.gun.addAnimation(gameUtils.AnimationHandler('spin', './assets/gun-spin.webp', 60))
self.shockScale = 0 #controls shock level sent to PDO (on a scale of 0 to 1) self.shockScale = 0 #controls shock level sent to PDO (on a scale of 0 to 1)
#gun variables #gun variables
self.startSpin = False self.startSpin = False
self.spinInc = 0 self.spinInc = 0
#render variables #render variables
self.gunw=self.gun[0][0].size[0] #calculates width of gun anim self.gunw=self.gun.size[0] #calculates width of gun anim
self.gunh=self.gun[0][0].size[1] #calculates height of gun anim self.gunh=self.gun.size[1] #calculates height of gun anim
#NOTE: Brosef, istg you better not make the gun webm #NOTE: Brosef, istg you better not make the gun webm
# change sizes mid file, or so help me # change sizes mid file, or so help me
@ -86,28 +89,24 @@ class Game(gameUtils.Game):
elif event.key == pygame.K_3: elif event.key == pygame.K_3:
self.playSound(self.gunSpin) self.playSound(self.gunSpin)
elif event.key == pygame.K_SPACE: elif event.key == pygame.K_SPACE:
self.startSpin = True self.gun.playAnim('spin')
elif event.type == gameUtils.AnimStart:
if event.objectID == self.gun.objectID and event.animationID == 'spin':
self.playSound(self.gunSpin)
elif event.type == gameUtils.AnimFinish:
if event.objectID == self.gun.objectID and event.animationID == 'spin':
self.shockScale += self.fire() #check if the user gets shot
self.shockScale = min(self.shockScale, 1) #keeps shockScale in bounds
def update(self): def update(self):
""" """
Ran once per frame, put your drawing code and any Ran once per frame, put your drawing code and any
game logic that should be ran once per frame in here. game logic that should be ran once per frame in here.
""" """
#gun code WOO
if self.startSpin == True:#check if space was pressed or if the gun is already spinning
if self.spinInc == 0:
self.playSound(self.gunSpin)
self.spinInc += 1 #next gun frame
if self.spinInc == len(self.gun): #if we've reached the end
self.spinInc = 0 #reset frame count
self.startSpin = False #what did i say bitch? stop spinning
self.shockScale += self.fire() #check if the user gets shot
self.shockScale = min(self.shockScale, 1) #keeps shockScale in bounds
#screen code #screen code
self.surf.fill("black") self.surf.fill("black")
self.surf.blit(pygame.transform.scale_by(self.gun[self.spinInc][0],self.gunScale),(self.gunMidx,self.gunMidy))#draw the gun self.surf.blit(pygame.transform.scale_by(self.gun.getFrame(),self.gunScale),(self.gunMidx,self.gunMidy))#draw the gun
#screen.blit(pygame.transform.scale_by(MainSurface,1),(0,yOffset))#renders the main surface to the screen, while also scaling it for the required display resolution #screen.blit(pygame.transform.scale_by(MainSurface,1),(0,yOffset))#renders the main surface to the screen, while also scaling it for the required display resolution
# TODO: # TODO: