emil das klappt so ned

This commit is contained in:
Michael S. 2024-01-20 09:48:03 +01:00
parent d84aa6c0d1
commit 27af4863df

39
main.py
View file

@ -19,14 +19,14 @@ speeds = 1
class DVD(): class DVD():
def __init__(self,scale,speed): def __init__(self,scale,speed):
self.newcolor()
self.dvd = pygame.image.load("dvd-logo.png") self.dvd = pygame.image.load("dvd-logo.png")
self.size = self.dvd.get_size() self.size = self.dvd.get_size()
self.scale = scale self.scale = scale
self.speed = speed self.speed = speed
self.get_sdvd()
self.pos = ri(0,screensize[0]-self.size[0]),ri(0,screensize[1]-self.size[1]) self.pos = ri(0,screensize[0]-self.size[0]),ri(0,screensize[1]-self.size[1])
self.get_dvd()
self.richtung = ["r","u"] self.richtung = ["r","u"]
self.newcolor()
self.render() self.render()
@ -59,19 +59,26 @@ class DVD():
def newcolor(self): def newcolor(self):
self.color = (ri(0,255),ri(0,255),ri(0,255)) self.color = (ri(0,255),ri(0,255),ri(0,255))
def get_sdvd(self): def get_dvd(self):
scaledx = self.size[0]*self.scale scaledx = self.size[0]*self.scale
scaledy = self.size[1]*self.scale scaledy = self.size[1]*self.scale
self.scalesize = (scaledx,scaledy) self.scalesize = (scaledx,scaledy)
self.sdvd = pygame.transform.scale(self.dvd,self.scalesize) self.rendered_dvd = pygame.surface.Surface(self.scalesize, flags=pygame.SRCALPHA)
self.rendered_dvd.fill(self.color)
self.rendered_dvd = pygame.transform.scale(self.dvd,self.scalesize)#(self.scalesize[0],self.scalesize[1]+10))
#pygame.transform.threshold(self.advd, self.advd, (0, 0, 0), (0, 0, 0,128), self.color, inverse_set=False)
screen.blit(self.rendered_dvd,self.pos)
def render(self): def render(self):
self.get_sdvd() self.get_dvd()
pygame.draw.rect(screen,self.color,(self.pos[0],self.pos[1],self.scalesize[0],self.scalesize[1])) pygame.draw.rect(screen,self.color,(self.pos[0],self.pos[1],self.scalesize[0],self.scalesize[1]))
screen.blit(self.sdvd,self.pos) screen.blit(self.rendered_dvd,self.pos)
dvds = [] dvds = []
dvds.append(DVD(1,1)) dvds.append(DVD(1,1))#ri(1,10)))
def toggle_fullscreen(is_fullscreen): def toggle_fullscreen(is_fullscreen):
if is_fullscreen: if is_fullscreen:
@ -82,10 +89,18 @@ def toggle_fullscreen(is_fullscreen):
return is_fullscreen,pygame.display.get_window_size() return is_fullscreen,pygame.display.get_window_size()
def get_debug_text(): def get_debug_text():
debug_text = "" def text(text,line_counter):
for index,a in enumerate(globals()): debug_text = default_font.render(str(text), True, (240, 240, 240))
debug_text = default_font.render(f"{str(a)} = {globals()[a]}", True, (240, 240, 240)) screen.blit(debug_text,(0,line_counter*default_font.get_height()))
screen.blit(debug_text,(0,index*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
for a in dvds:
text(vars(a),line_counter)
line_counter += 1
running = True running = True
if __name__ == "__main__": if __name__ == "__main__":
@ -111,7 +126,7 @@ if __name__ == "__main__":
if pressed_keys[pygame.K_LEFT] and scales>=0.2: if pressed_keys[pygame.K_LEFT] and scales>=0.2:
scales -= 0.1 scales -= 0.1
if pressed_keys[pygame.K_PLUS] and not preview_pressed_keys[pygame.K_PLUS]: if pressed_keys[pygame.K_PLUS] and not preview_pressed_keys[pygame.K_PLUS]:
dvds.append(DVD(1,1)) dvds.append(DVD(1,1)) #ri(1,30)))
if pressed_keys[pygame.K_MINUS] and not preview_pressed_keys[pygame.K_MINUS] and not len(dvds) == 0: if pressed_keys[pygame.K_MINUS] and not preview_pressed_keys[pygame.K_MINUS] and not len(dvds) == 0:
dvds.pop(0) dvds.pop(0)