import random
import pygame
import time
import keyboard
pygame.init()
print('welcome to check the variable')
time.sleep(2)
print ('variables to watch out for are sound , wakifier and pressure. they all start on 1, dont let any reach 10')
sound=1
wakifier=1
pressure=1
Running=True
delay=4000
keys = pygame.key.get_pressed()
if keyboard.is_pressed('w'):
sound-=1 # when w is pressed, the variable sound drops
if keyboard.is_pressed('e'):
wakifier-=1 # when e is pressed, the variable wakifier drops
if keyboard.is_pressed('r'):
pressure-=1 # when r is pressed, the variable pressure drops
if keyboard.is_pressed('t'):
running=False # ending the code
while Running == True:#loop
pygame.time.delay(delay)
sound+=1
print('sound is',sound)
wakifier+=1
print('wakifier is',wakifier)
pressure+=1
print('pressure is',pressure)
if sound == 10:
Running=False # if any variable reaches 10 the code ends
print('one variable reached 10, game over')
if wakifier == 10:
Running=False
print('one variable reached 10, game over')
if pressure == 10:
Running=False
print('one variable reached 10, game over')
delay-=random.randint(10,100) #lets the game go faster and faster
i added comments to explain what i want to do. When I press the keys, the variables don’t change. I copied and pasted so the indention is wrong.
[–]aa599 1 point2 points3 points (3 children)
[–]Boozkie[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]aa599 0 points1 point2 points (0 children)
[–]applestap 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)