77 lines
2.1 KiB
Python
77 lines
2.1 KiB
Python
import pygame
|
|
from random import randint
|
|
|
|
#Oh god here we go. I'm gonna screw up this entire thing
|
|
|
|
def fire():#LETS GO GAMBLING
|
|
if randint(1,6) == 6:
|
|
PlaySound(GunShot)
|
|
#remember to add shock
|
|
else:
|
|
PlaySound(GunBlank)
|
|
|
|
screenw = 730
|
|
screenh = 1080
|
|
yOffset = 0
|
|
|
|
pygame.init()
|
|
|
|
gun = pygame.image.load_animation("gun.webp")
|
|
print(gun[0])
|
|
|
|
GunFlash = pygame.image.load("images/muzzleflash.png")
|
|
|
|
#Sounds for the gun :3
|
|
PlaySound = pygame.mixer.Sound.play
|
|
GunBlank = pygame.mixer.Sound("sfx/gun-blank.mp3")
|
|
GunShot = pygame.mixer.Sound("sfx/gun-shot.mp3")
|
|
GunSpin = pygame.mixer.Sound("sfx/gun-spin.mp3")
|
|
|
|
screen = pygame.display.set_mode((screenw,screenh))
|
|
MainSurface = pygame.Surface((screenw,screenh-yOffset))
|
|
clock = pygame.time.Clock()
|
|
|
|
running = True #you better start running...
|
|
|
|
#gun variables
|
|
startSpin = False
|
|
spinning = False
|
|
spinInc = 0
|
|
|
|
while running:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
running = False
|
|
elif event.type == pygame.KEYDOWN:
|
|
if event.key == pygame.K_1:
|
|
PlaySound(GunBlank)
|
|
elif event.key == pygame.K_2:
|
|
PlaySound(GunShot)
|
|
elif event.key == pygame.K_3:
|
|
PlaySound(GunSpin)
|
|
elif event.key == pygame.K_SPACE:
|
|
startSpin = True
|
|
|
|
#gun code WOO
|
|
if startSpin == True or spinning == True:#check if space was pressed or if the gun is already spinning
|
|
spinning = True #keep the gun spinning
|
|
if spinInc == 0:
|
|
PlaySound(GunSpin)
|
|
spinInc += 1 #next gun frame
|
|
if spinInc == 61: #if we've reached the end
|
|
spinInc = 0 #reset frame count
|
|
spinning = False #stop spinning
|
|
startSpin = False #what did i say bitch? stop spinning
|
|
fire() #check if the user gets shot
|
|
|
|
#screen code
|
|
screen.fill("black")
|
|
|
|
MainSurface.blit(gun[spinInc][0],(0,0))#draw the gun
|
|
screen.blit(MainSurface,(0,yOffset))
|
|
|
|
pygame.display.flip()
|
|
|
|
clock.tick(60)
|
|
|
|
pygame.quit() |