Code: #!/usr/bin/env python # -*- encoding: utf-8 -*- import pygame, datetime from copy import copy from sys import exit target = datetime.date(datetime.MINYEAR, 11, 7) # obscured for privacy now = datetime.date.today() if target.month == now.month and target.day == now.day: size = (800, 600) pygame.init() screen = pygame.display.set_mode(size) fps = pygame.time.Clock() pos = (0,0) direction = [3,2] font = pygame.font.SysFont('Helvetica', 48) s = font.render('Herzlichen Glückwunsch, mq!'.decode('utf8'), True, [255]*3) while 1: fps.tick(40) for event in pygame.event.get(): if event.type == pygame.KEYDOWN and event.key in (pygame.K_f, pygame.K_ESCAPE) or event.type == pygame.QUIT: pygame.quit() exit(0) oldpos = copy(pos) pos = [pos[0]+direction[0], pos[1]+direction[1]] if pos[0] >= size[0]-s.get_width() or pos[0] <= 0: direction[0] = -direction[0] if pos[1] >= size[1]-s.get_height() or pos[1] <= 0: direction[1] = -direction[1] screen.fill([0]*3, (oldpos, s.get_size())) screen.blit(s, pos) pygame.display.update(([oldpos, s.get_size()], [pos, s.get_size()])) Alles erdenklich Gute, mq.
#!/usr/bin/env python # -*- encoding: utf-8 -*- import pygame, datetime from copy import copy from sys import exit target = datetime.date(datetime.MINYEAR, 11, 7) # obscured for privacy now = datetime.date.today() if target.month == now.month and target.day == now.day: size = (800, 600) pygame.init() screen = pygame.display.set_mode(size) fps = pygame.time.Clock() pos = (0,0) direction = [3,2] font = pygame.font.SysFont('Helvetica', 48) s = font.render('Herzlichen Glückwunsch, mq!'.decode('utf8'), True, [255]*3) while 1: fps.tick(40) for event in pygame.event.get(): if event.type == pygame.KEYDOWN and event.key in (pygame.K_f, pygame.K_ESCAPE) or event.type == pygame.QUIT: pygame.quit() exit(0) oldpos = copy(pos) pos = [pos[0]+direction[0], pos[1]+direction[1]] if pos[0] >= size[0]-s.get_width() or pos[0] <= 0: direction[0] = -direction[0] if pos[1] >= size[1]-s.get_height() or pos[1] <= 0: direction[1] = -direction[1] screen.fill([0]*3, (oldpos, s.get_size())) screen.blit(s, pos) pygame.display.update(([oldpos, s.get_size()], [pos, s.get_size()]))
Foren-Regeln