Compare commits
2 Commits
09ae4c8d7e
...
894ac59038
| Author | SHA1 | Date | |
|---|---|---|---|
| 894ac59038 | |||
| 4abb2353e1 |
BIN
assets/gun-base.png
Normal file
BIN
assets/gun-base.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 5.0 MiB After Width: | Height: | Size: 5.0 MiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
43
game.py
43
game.py
@ -33,14 +33,17 @@ class Game(gameUtils.Game):
|
||||
|
||||
#Sounds for the gun :3
|
||||
self.playSound = pygame.mixer.Sound.play
|
||||
self.gunBlank = pygame.mixer.Sound("sfx/gun-blank.mp3")
|
||||
self.gunShot = pygame.mixer.Sound("sfx/gun-shot.mp3")
|
||||
self.gunSpin = pygame.mixer.Sound("sfx/gun-spin.mp3")
|
||||
self.gunLoad = pygame.mixer.Sound("sfx/gun-load.mp3")
|
||||
self.gunCyclinder = pygame.mixer.Sound("sfx/gun-cylinder-stop.mp3")
|
||||
self.gunBlank = pygame.mixer.Sound("./assets/gun-blank.mp3")
|
||||
self.gunShot = pygame.mixer.Sound("./assets/gun-shot.mp3")
|
||||
self.gunSpin = pygame.mixer.Sound("./assets/gun-spin.mp3")
|
||||
self.gunLoad = pygame.mixer.Sound("./assets/gun-load.mp3")
|
||||
self.gunCyclinder = pygame.mixer.Sound("./assets/gun-cylinder-stop.mp3")
|
||||
|
||||
self.gun = pygame.image.load_animation("gun.webp")
|
||||
self.gunFlash = pygame.image.load("images/muzzleflash.png")
|
||||
#self.gun = pygame.load_animation('./assets/gun-spin.webp')
|
||||
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)
|
||||
#gun variables
|
||||
@ -48,8 +51,8 @@ class Game(gameUtils.Game):
|
||||
self.spinInc = 0
|
||||
|
||||
#render variables
|
||||
self.gunw=self.gun[0][0].size[0] #calculates width of gun anim
|
||||
self.gunh=self.gun[0][0].size[1] #calculates height of gun anim
|
||||
self.gunw=self.gun.size[0] #calculates width of gun anim
|
||||
self.gunh=self.gun.size[1] #calculates height of gun anim
|
||||
#NOTE: Brosef, istg you better not make the gun webm
|
||||
# change sizes mid file, or so help me
|
||||
|
||||
@ -86,7 +89,14 @@ class Game(gameUtils.Game):
|
||||
elif event.key == pygame.K_3:
|
||||
self.playSound(self.gunSpin)
|
||||
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):
|
||||
"""
|
||||
@ -94,20 +104,9 @@ class Game(gameUtils.Game):
|
||||
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
|
||||
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
|
||||
|
||||
# TODO:
|
||||
|
||||
Reference in New Issue
Block a user