Added gun spin animation on space press
This commit is contained in:
20
__main__.py
20
__main__.py
@ -2,11 +2,14 @@ import pygame
|
|||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
screenw = 1280
|
screenw = 1280
|
||||||
screenh = 720
|
screenh = 1080
|
||||||
yOffset = 0
|
yOffset = 0
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
|
gun = pygame.image.load_animation("gun.webp")
|
||||||
|
print(gun[0])
|
||||||
|
|
||||||
#Sounds for the gun :3
|
#Sounds for the gun :3
|
||||||
PlaySound = pygame.mixer.Sound.play
|
PlaySound = pygame.mixer.Sound.play
|
||||||
GunBlank = pygame.mixer.Sound("sfx/gun-blank.mp3")
|
GunBlank = pygame.mixer.Sound("sfx/gun-blank.mp3")
|
||||||
@ -20,6 +23,8 @@ clock = pygame.time.Clock()
|
|||||||
|
|
||||||
running = True #you better start running...
|
running = True #you better start running...
|
||||||
startSpin = False
|
startSpin = False
|
||||||
|
spinning = False
|
||||||
|
spinInc = 0
|
||||||
|
|
||||||
while running:
|
while running:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
@ -35,14 +40,23 @@ while running:
|
|||||||
elif event.key == pygame.K_SPACE:
|
elif event.key == pygame.K_SPACE:
|
||||||
startSpin = True
|
startSpin = True
|
||||||
|
|
||||||
#revolver code
|
|
||||||
|
|
||||||
#screen code
|
#screen code
|
||||||
screen.fill("black")
|
screen.fill("black")
|
||||||
|
|
||||||
pygame.draw.rect(MainSurface, (30,30,30), (0,0,300,100))
|
pygame.draw.rect(MainSurface, (30,30,30), (0,0,300,100))
|
||||||
screen.blit(MainSurface,(0,yOffset))
|
screen.blit(MainSurface,(0,yOffset))
|
||||||
|
|
||||||
|
#gun code WOO
|
||||||
|
if startSpin == True or spinning == True:
|
||||||
|
spinning = True
|
||||||
|
spinInc += 1
|
||||||
|
if spinInc == 61:
|
||||||
|
spinInc = 0
|
||||||
|
spinning = False
|
||||||
|
startSpin = False
|
||||||
|
|
||||||
|
screen.blit(gun[spinInc][0],(0,0))
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
clock.tick(60)
|
clock.tick(60)
|
||||||
|
|||||||
Reference in New Issue
Block a user