From d4d4d96a8e47fe95d5571cd85067c76ccc9ce1f8 Mon Sep 17 00:00:00 2001 From: Megamichi Date: Thu, 18 Jan 2024 21:34:58 +0100 Subject: [PATCH] first commit --- dvd-logo.png | Bin 0 -> 5205 bytes main.py | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 dvd-logo.png create mode 100644 main.py diff --git a/dvd-logo.png b/dvd-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..0607dd46ceff71c4acbf88febce1ece0a2cc528f GIT binary patch literal 5205 zcmeHKc~n#95>E&!yBerqMTsdQh*=3_DPc_zkRU=psO7=Uy*Cgb3rW~TL8$^-R0x(@ zwOFwzSa50G5JfEt)D<402uMYX3)HO^DFW|HK*aNU&O4s-`k%?Ux%ZoI<~K9HnQu;R zUQpl?Q=^ZKFc^%fpD!;M+syFkBrBr4STKxmc2b64Yr5lz^s6 z#28F!yEJH}8E(G8>s|})T37WmmaNUL)^l@|#nFh{f#;}R)-xYe_u^!@9KAv&=_d`c zWl`~VLqUPd?4p2O4;G{!zp>kw(cqu(_3*w#>{ZTc6IbVuK~dR2Y+wAI3%IfFk2%vF@poc5w&qwL>?Zt1+?=&<}q_)T%_w>xFwc+gciTrk$SGo81Jr( zeD>-~)mbzuU@R$ zdBYwb{xjY-HzlSoSaKcqOzHj>~Lj+~OU zd!e@ry27X#|2(aGc++VIW0NjDZhTkA_Fh&drkPQB&s3o>*koy+(b?PC*{>QpR?a?S zBjhNzf7`Y{AGBSn1hiMUAb3FRX}h&swRlg7>SHad{T3U zNRS|0;tFR0RiN-jVCzVUo;c~#U zR!kuhbSmn2E-_pXMDUg?Q38X^AX7>FR7oJu%*7zPhj!AgljEs@IzT1-eJPf~M< zM6geI6Q5Ke5KO?!RO2iFJ}9Y>f{!}f}jZtEd?z&xNJGyix2Lj9|aNp5>le3Izpo|Q5bfa1hGsh0bL0tOpZzmg#ai9!~hUp-L6#L@g$bN_JxC%(Z3VfMfu% zkhV_&f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S(h+ni7ieeJ2zP@s_1QNy!5=s@O0l- zJ6jN=j{2dcY*EL9v|tBj;T;%{Es`BrRe{1MqA{XiTAo2k#R6>6y!B?9I@{vHEWbNg z1OI6JOzOk(iv6GI73Kb3SabMgZ_NGGnk>UDrYqz1?6T_20x+{+igi(cQvhLRp97~f@9tpW?vj?LN4%s&0U{;`NCjc&3rC% z>N7{h;l>(wHYIKA03j21$$?tczT`3fL3zMp+{;&YH}vDreSXlU|M)Fs-c(Yud15Lr5cuRBgG zt-%hC=ASr{*E+B*@;6)0!KToj;d?(WUO)S|@|5F~o~qAX4>vfKiyv+M#yzSwCv3&S zLoWms!71pOj6+sdRk2S;cK&KYt(vCd&sj11ioMw~i-Bs#Ej@0VPyDiat=n|gj5%3` z(e3k&Ux{A3?P!)9Us5-vYnJk{O&>weE|Y5cY?_B2qt5ob`oE?RN%XG9KK-i-Ob3h~ LKaf}D6}|R9NsrNL literal 0 HcmV?d00001 diff --git a/main.py b/main.py new file mode 100644 index 0000000..fd16065 --- /dev/null +++ b/main.py @@ -0,0 +1,100 @@ +import pygame +from random import randint as ri +def scale(vaktor): + scaledx = dvdsizex*vaktor + scaledy = dvdsizey*vaktor + return (scaledx,scaledy) +pygame.init() + +is_fullscreen = True +fill_screen = True +screen = pygame.display.set_mode((0,0),pygame.FULLSCREEN) +pygame.display.set_caption("Screensaver") +x,y = pygame.display.get_window_size() + +clock = pygame.time.Clock() + +dvd = pygame.image.load("dvd-logo.png") +dvdsizex,dvdsizey = dvd.get_size() + +dvdscale = 1 +dvdscalesize = scale(dvdscale) +dvdscaled = pygame.transform.scale(dvd,dvdscalesize) +dvdx,dvdy = ri(0,x-dvdsizex),ri(0,y-dvdsizey) +wobspeed = 3 + +richtung = ["r","u"] +def randcolor(): + return (ri(0,255),ri(0,255),ri(0,255)) + +def moving(richtung,wobx,woby): + if richtung[0] == "r": + wobx += wobspeed + else: + wobx -= wobspeed + if richtung[1] =="u": + woby += wobspeed + else: + woby -=wobspeed + return wobx,woby + +def toggle_fullscreen(is_fullscreen): + if is_fullscreen: + pygame.display.set_mode((600,500),pygame.RESIZABLE) + else: + pygame.display.set_mode((0,0),pygame.FULLSCREEN) + is_fullscreen = not is_fullscreen + return is_fullscreen,pygame.display.get_window_size() + +running = True +if __name__ == "__main__": + color = randcolor() + 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_f] and screen.get_size(): + is_fullscreen,(x,y) = toggle_fullscreen(is_fullscreen) + if pressed_keys[pygame.K_UP] and wobspeed>=0: + wobspeed += 1 + if pressed_keys[pygame.K_DOWN] and wobspeed>=1: + wobspeed -= 1 + if pressed_keys[pygame.K_RIGHT] and dvdscale>0.1: + dvdscale += 0.1 + dvdscalesize = scale(dvdscale) + if pressed_keys[pygame.K_LEFT] and dvdscale>=0.2: + dvdscale -= 0.1 + dvdscalesize = scale(dvdscale) + + preview_pressed_keys = pressed_keys + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + exit() + if event.type == pygame.WINDOWRESIZED: + x,y = pygame.display.get_window_size() + + if dvdx+dvdscalesize[0] >= x: + richtung[0] = "l" + color = randcolor() + if dvdx <= 0: + richtung[0] = "r" + color = randcolor() + if dvdy+dvdscalesize[1] >= y: + richtung[1] = "o" + color = randcolor() + if dvdy <= 0: + richtung[1] = "u" + color = randcolor() + + dvdx,dvdy = moving(richtung,dvdx,dvdy) + pygame.draw.rect(screen,color,(dvdx,dvdy,dvdscalesize[0],dvdscalesize[1])) + dvdscaled = pygame.transform.scale(dvd,dvdscalesize) + screen.blit(dvdscaled,(dvdx,dvdy)) + pygame.display.update() + clock.tick(60) \ No newline at end of file