import pygame, sys, time, os
from scripts import UltraColor
from scripts import textures
pygame.init()
displayWidth = 1280
displayHeight = 720
black = (0,0,0)
white = (255,255,255)
menu = True
gender = True
display = pygame.display.set_mode((displayWidth, displayHeight))
pygame.display.set_caption("Blazing Badge")
clock = pygame.time.Clock()
warriorImage = pygame.image.load("warrior.png")
grassImage = pygame.image.load("grass.png")
playButton = pygame.image.load("play button.png")
durandal = pygame.image.load("durandal.png")
mainscreen = pygame.image.load("mainmenu.jpg")
logo = pygame.image.load("logo.png")
running = True
menu_viewed = False
def empty_screen():
display.fill(white)
def text_objects(text, font, colour):
textSurface = font.render(text, True, colour)
return textSurface, textSurface.get_rect()
action = None
def game_menu():
intro = True
while intro:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
display.fill(white)
largeText = pygame.font.Font("The Fighter.otf", 115)
TextSurf, TextRect = text_objects("Tech Demo", largeText, black)
TextSurf = pygame.transform.rotate(TextSurf, 15)
TextRect.center = ((displayWidth*0.68), (displayHeight*0.4))
playpos = (((displayWidth/2)-100), (displayHeight)*0.7)
durandalpos = (((displayWidth/2)-280), (displayHeight*0.2))
display.blit(mainscreen, (0,0))
display.blit(playButton, playpos)
durandalresized = pygame.transform.scale(durandal, (561, 333))
display.blit(durandalresized, durandalpos)
display.blit(logo, ((displayWidth*0.2), (displayHeight*0.35)))
display.blit(TextSurf, TextRect)
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
print(click)
print(mouse)
if 580 < mouse[0] < 710 and 532 < mouse[1] < 674:
if click[0] == 1:
intro = False
print("Start Game")
pygame.display.update()
clock.tick(15)
def character_creation():
creation = True
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
gender_symbols = pygame.image.load(os.path.join("graphics\Character Creation", "Gender Symbols.png"))
creation_background = pygame.image.load(os.path.join("graphics\Character Creation", "creationbackground.jpg"))
TextSurf, TextRect = text_objects("Choose your gender", pygame.font.Font("The Fighter.otf", 115), white)
display.blit(creation_background, (0,0))
display.blit(TextSurf, (((1280/2)-500), displayHeight*0.1))
display.blit(gender_symbols,(340, (displayHeight*0.6)))
pygame.display.update()
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
print(click)
print(mouse)
mcgender = "Null"
creation = False
gender = True
while gender:
print(click)
print(mouse)
if 365 < mouse[0] < 602 and 457 < mouse[1] < 702:
if click[0] == 1:
mcgender = "Female"
elif 457 < mouse[1] < 702 and 677 < mouse[0] < 916:
if click[0] == 1:
mcgender = "Male"
if mcgender != "Null":
gender = False
print(mcgender)
display.blit(creation_background, (0,0))
pygame.display.update()
stone1 = pygame.image.load(os.path.join("graphics", "stone1.png"))
#Game Loop follows -----------------------------------------------------------------------------------------------------
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
print(event)
if menu_viewed == False:
game_menu()
menu_viewed = True
clear_screen = True
gender = True
character_creation()
pygame.quit()
quit()
Can anyone provide some assistance? Running the following code, works will until the following section:
while gender:
print(click)
print(mouse)
if 365 < mouse[0] < 602 and 457 < mouse[1] < 702:
if click[0] == 1:
mcgender = "Female"
elif 457 < mouse[1] < 702 and 677 < mouse[0] < 916:
if click[0] == 1:
mcgender = "Male"
if mcgender != "Null":
gender = False
No error code is produced, but the game window stops responding with no sign of restoring. The mouse readings continue in the terminal, but no response comes from the window. The only way to exit the program is be forcefully stopping the code from Pycharm.