I'm working on custom basic functions to simplify coding for me, like wait(seconds) or msg(...), and now I'm working on the window setup and updating, it works, but when I put it in a thread, it just won't do anything. I don't get any errors, so I'm confused and frustrated. I dont need you to debug it or anything, I just need help to know where the problem is and why it's a problem.
Here's my script so far (the script is at the bottom):
# Imports
if True:
import pygame, math, random, time, sys, threading
from pygame.locals import *
pygame.init()
# Setup
if True:
win_n = "New Project"
win_w = 800
win_h = 600
win_c = (0, 0, 0)
# Code
if True:
def wait(seconds):
time.sleep(seconds)
def wait_until(bool):
while not bool:
wait(0.001)
# Execute
if True:
def e_ws():
mainClock = pygame.time.Clock()
pygame.display.set_caption(win_n)
monitor_size = [pygame.display.Info().current_w, pygame.display.Info().current_h]
screen = pygame.display.set_mode((win_w, win_h), pygame.RESIZABLE)
fullscreen = False
while True:
screen.fill(win_c)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == VIDEORESIZE:
if not fullscreen:
screen = pygame.display.set_mode((event.w, event.h), pygame.RESIZABLE)
if event.type == KEYDOWN:
if fullscreen:
screen = pygame.display.set_mode(monitor_size, pygame.FULLSCREEN)
else:
screen = pygame.display.set_mode((screen.get_width(), screen.get_height()),
pygame.RESIZABLE)
pygame.display.update()
mainClock.tick(60)
t_ws = threading.Thread(target=e_ws)
t_ws.start()
print("done")
Run a script with python yourscriptname.py
from the command line.