Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Dr Who
- # @eigenbom
- # Requires: pygame-zero
- from math import sin, cos, pi
- from random import uniform as u
- import pygame
- WIDTH, HEIGHT = 512, 512
- center = WIDTH/2, HEIGHT/2
- tunnel = center
- time = 0
- sign = lambda x: 1 if x > 0 else -1 if x < 0 else 0
- def update(dt):
- global time, tunnel
- time += dt
- def draw():
- global tunnel, center
- # rotate and zoom
- speedxor = 1.1 + 0.05 + 0.05*sin(time*0.33)
- rotxor = 5.5 + 1.0*sin(time*0.33)
- old_rect = screen.surface.get_rect()
- new_surface = pygame.transform.rotozoom(screen.surface, rotxor,speedxor)
- new_surface.set_alpha(200)
- new_rect = new_surface.get_rect()
- offx = old_rect.centerx - new_rect.width / 2
- offy = old_rect.centery - new_rect.height / 2
- screen.blit(new_surface, (offx,offy))
- # update tunnel center
- tunnel = center[0] + 10*sin(time), center[1] + 10*cos(time)
- # colour
- step = int(16 * (0.5 + 0.5*sin(time * 5)))
- col = 128 + step*8
- screen.draw.filled_circle(tunnel, 10, (col, col, col))
- screen.draw.filled_circle(tunnel, 5, (col/2,col/2,col/2))
- pulsor = sin(time*5) > 0.8
- twistor = sin(time*88.01)
- for i in range(4):
- x, y = 10*sin(-twistor*time*1.1 + i*pi/2), 10*cos(-twistor*time*1.1 + i*pi/2)
- if pulsor:
- colour = 0, 0, 0
- else:
- colour = [(255,0,0), (0, 255, 0), (0, 0, 255), (0, 128, 128)][i]
- screen.draw.filled_circle((tunnel[0] + x, tunnel[1] + y), int(5 + 2*sin(time)), colour)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement