From 2f549afa1f2f8b37a330cd6804ac15d1dcb2760f Mon Sep 17 00:00:00 2001 From: megamichi Date: Tue, 27 Feb 2024 18:33:30 +0100 Subject: [PATCH] init --- main.py | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..6a80acf --- /dev/null +++ b/main.py @@ -0,0 +1,62 @@ +#!/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)