From a9be84a52fd2abf76ee99726122cece8e7b908af Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Thu, 18 Jul 2024 13:06:59 +0200 Subject: [PATCH] initial commit --- .gitignore | 1 + Untitled.png | Bin 0 -> 10300 bytes main.py | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 .gitignore create mode 100644 Untitled.png create mode 100644 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f7275bb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv/ diff --git a/Untitled.png b/Untitled.png new file mode 100644 index 0000000000000000000000000000000000000000..90161a4a8e13e924172d65c3cd6ee05663ab484f GIT binary patch literal 10300 zcmZ{Kby!s2_chHB4g=C642a}Ni8#^>9a7>*NeMX8-3;B*4bmbdEh17<0+J(AQUbz| zqBH{f9zVbDzc0@tk9QpJJ$IkI*IsMw6QirGdWDjel7N8Vin^MTJ^=wC0{q@Iom#SupuDeOAbtyQR|Us>oYeg6<|=1qTfs^lAKjmX0vCA z)#dy`SuL4m`kVAVYYIJ+YFE>@Z~a!2U42H6$R8=dE(lz`T=YGX>HcQY8~6IS%qM!E zuzT+j1T}s#Xyhd<&#|%ASLe($X9%r@STSElb8(42D7e}uF5N#Z6A;iIcYxS)4@yud zwGjKj3**glGVHz9dpkE{)VBaR{3!($pe=1VP8!3}BGh{EvE_SR!PCfi2itt479#Dv z;SVdcgu%+Qm8@dBw7s#G*Di}IuhHAD19kp%>nfNStxJyZ=^OUaDM6C-R7oEiMo&~G zTX89#tJC}~Uu7D+nOa4pl0f>U5ao99E$C;fNh9*kCQn3){9c@6&~w7B$Ay!1yL(UO zobm`lo_^EVKDEDZah!Unq8fLdP;u@IE zI>61z`6b2p-qS@IysOL!!;F*^`nT^nHtQ)Fv+hYd9z9v{;NezO6nT0>TIuVxTk-pp zX{89#@K5>~L?|16O(RN3`v0yQ=wSl?ySBL$4*j{jtT6acU^~dyb*PX1R=i5dpN6!@ zdKpC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MQh3>Yvwy~LL5i1OL4 z?|gXD4aPM>>m)U7kcv#|&#KWBv^gb|*!8_U$u!`ztEbpCfdMPfxnFS9tfkpk38M21 zFPCF`oGGI)$4?q(F`-{xg z)}3;gF^K39H2jcJe&qqwv8Mf+h`%@xhWvKTbAsuyILvb;E->F|qB_vs{$sANa94t5u07f)=0Gd+`bHuw;o5O-h`E5r(MA7oVD+9nzO zMqJzNbFyc;!5_+#3d&|_@5!s$p53{=5Fa8~%6w`mFXZ`NPNPl;N!uJ8-OwKwVi| KsRm^c`u_l-d(g`O literal 0 HcmV?d00001 diff --git a/main.py b/main.py new file mode 100644 index 0000000..025bff8 --- /dev/null +++ b/main.py @@ -0,0 +1,127 @@ +# Example file showing a basic pygame "game loop" +import pygame +from pygame.math import Vector2 +from time import time + +class FloatingSign(pygame.sprite.Sprite): + # Constructor. Pass in the color of the block, + # and its x and y position + def __init__(self, image: pygame.Surface): + # Call the parent class (Sprite) constructor + pygame.sprite.Sprite.__init__(self) + + # Create an image of the block, and fill it with a color. + # This could also be an image loaded from the disk. + self.image = image + self.width, self.height = image.get_size() + + # Fetch the rectangle object that has the dimensions of the image + # Update the position of this object by setting the values of rect.x and rect.y + self.rect = self.image.get_rect() + + self.pos = Vector2(0, 0) + self.hits = 0 + self.corner_hits = 0 + self.last_hit = Vector2(0, 0) + self.last_corner_hit = 0 + + self.font = pygame.font.SysFont('Noto Sans', 40, True) + self.text_surfaces = [ + self.font.render(f'Hits: {self.hits}', False, (255, 255, 255)), + self.font.render(f'Corner hits: {self.corner_hits}', False, (255, 255, 255)), + None + ] + + def move(self, delta: float):# -> pygame.Rect: + sw, sh = pygame.display.get_window_size() + before = self.pos + hit_x = False + hit_y = False + + movement = self.velocity * delta + self.pos += movement + + if self.pos.x < 0: + hit_x = True + self.pos.x *= -1 + elif self.pos.y < 0: + hit_y = True + self.pos.y *= -1 + elif self.pos.x > sw - self.width: + hit_x = True + self.pos.x -= self.pos.x + self.width - sw + elif self.pos.y > sh - self.height: + hit_y = True + self.pos.y -= self.pos.y + self.height - sh + + if hit_x or hit_y: + if hit_x: self.velocity.x *= -1 + else: self.velocity.y *= -1 + self.hits += 1 + hit_distance = self.pos.distance_to(self.last_hit) + self.last_hit = self.pos.copy() + + if hit_distance < 10: + self.corner_hits += 1 + self.last_corner_hit = time() + self.text_surfaces[1] = self.font.render(f'Corner hits: {self.corner_hits}', False, (255, 255, 255)) + + self.text_surfaces[0] = self.font.render(f'Hits: {self.hits}', False, (255, 255, 255)) + + self.rect.topleft = self.pos + + #return pygame.Rect(min_x, min_y, max_x - min_x, max_y - min_y) + + def lazy_update(self, delta: float): + secs = time() - self.last_corner_hit + if secs < 3600: + fmtd = (str(secs // 1) + 's') if secs < 60 else (str(secs // 60) + 'm') + self.text_surfaces[2] = self.font.render(f'Last corner hit: {fmtd}', False, (255, 255, 255)) + else: + self.text_surfaces[2] = None + +def main(screen_size: tuple[int], background: str, image_path: str, initial_velocity: Vector2): + # pygame setup + pygame.init() + screen = pygame.display.set_mode(screen_size, flags=pygame.RESIZABLE, vsync=1) + clock = pygame.time.Clock() + running = True + + image = pygame.image.load(image_path) + floating_sign = FloatingSign(image) + floating_sign.velocity = initial_velocity + + screen.fill(background) + pygame.display.flip() + lu = 0 + + while running: + delta = clock.tick() + lu += delta + + # poll for events + # pygame.QUIT event means the user clicked X to close your window + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + # fill the screen with a color to wipe away anything from last frame + screen.fill(background) + + movement_swept = floating_sign.move(delta / 1000) + if lu > 1: + floating_sign.lazy_update(lu) + lu = 0 + for i in range(len(floating_sign.text_surfaces)): + if floating_sign.text_surfaces[i] is not None: + screen.blit(floating_sign.text_surfaces[i], (20, 10 + 40 * i)) + screen.blit(floating_sign.image, floating_sign.rect) + + # flip() the display to put your work on screen + pygame.display.flip() + #pygame.display.update(movement_swept) + + pygame.quit() + +if __name__ == "__main__": + main(screen_size=(1280, 720), background="#3b3b3b", image_path="Untitled.png", initial_velocity=Vector2(200, 127)) \ No newline at end of file