63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
|
#!/usr/bin/python3
|
||
|
import pygame
|
||
|
from math import radians,sin,cos
|
||
|
|
||
|
pygame.init()
|
||
|
default_font = pygame.font.SysFont("sans", 14)
|
||
|
|
||
|
def draw_arrow(winkel,pos,radius):
|
||
|
pygame.draw.line(screen,(255,255,255),
|
||
|
pos[0]+sin(radians(winkel)*radius),
|
||
|
pos[0]+sin(radians(winkel)*radius)
|
||
|
)
|
||
|
|
||
|
arrows = [10,50,80]
|
||
|
|
||
|
fill_screen = True
|
||
|
show_debug = False
|
||
|
screen = pygame.display.set_mode((600,500))
|
||
|
pygame.display.set_caption("Shot")
|
||
|
screensize = pygame.display.get_window_size()
|
||
|
|
||
|
clock = pygame.time.Clock()
|
||
|
|
||
|
def get_debug_text():
|
||
|
def text(text,line_counter):
|
||
|
debug_text = default_font.render(str(text), True, (240, 240, 240))
|
||
|
screen.blit(debug_text,(0,line_counter*default_font.get_height()))
|
||
|
|
||
|
line_counter = 1
|
||
|
globalvars =globals()
|
||
|
for a in globalvars:
|
||
|
text(f"{str(a)} = {str(globalvars[a])}",line_counter)
|
||
|
line_counter += 1
|
||
|
|
||
|
running = True
|
||
|
if __name__ == "__main__":
|
||
|
while running:
|
||
|
if fill_screen:
|
||
|
screen.fill((0,0,0))
|
||
|
pressed_keys = pygame.key.get_pressed()
|
||
|
|
||
|
if pressed_keys[pygame.K_ESCAPE]:
|
||
|
exit()
|
||
|
if pressed_keys[pygame.K_SPACE] and not preview_pressed_keys[pygame.K_SPACE]:
|
||
|
fill_screen = not fill_screen
|
||
|
if pressed_keys[pygame.K_d] and not preview_pressed_keys[pygame.K_d]:
|
||
|
show_debug = not show_debug
|
||
|
|
||
|
preview_pressed_keys = pressed_keys
|
||
|
|
||
|
for event in pygame.event.get():
|
||
|
if event.type == pygame.QUIT:
|
||
|
exit()
|
||
|
if event.type == pygame.WINDOWRESIZED:
|
||
|
screensize = pygame.display.get_window_size()
|
||
|
|
||
|
pygame.draw.circle(screen,(100,100,100),(0,0),30)
|
||
|
|
||
|
if show_debug:
|
||
|
get_debug_text()
|
||
|
pygame.display.flip()
|
||
|
clock.tick(60)
|