| Home | Code/Games | About me |
|---|
a python executable to create a rotating shape the edges of the window.
download
The code:
import pygame, sys
pygame.init()
print('every value is in pixels (exept for max line count and color)')
max_line_count = int(input('max line count: '))
windowHeight = int(input('window height: '))
windowWidth = int(input('window width: '))
line_width = int(input('line width: '))
gap_width = int(input('width between lines: '))
color_pygame_name = input('color (pygame color names): ')
window_size = [windowWidth, windowHeight]
screen = pygame.display.set_mode(window_size, 0, 32)
pygame.display.set_caption("rotating square")
clock = pygame.time.Clock()
i = 0
j = 1
points = [[window_size[0], window_size[1] / 2], [window_size[0] / 2, 0], [0, window_size[1] / 2], [window_size[0] / 2, window_size[1]]]
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
pygame.draw.lines(screen, color_pygame_name, False, points, 2)
pos_change = 5
if len(points) <= max_line_count:
if j % 4 == 1:
points.append([points[i][0], points[i][1] - pos_change])
if j % 4 == 2:
points.append([points[i][0] - pos_change, points[i][1]])
if j % 4 == 3:
points.append([points[i][0], points[i][1] + pos_change])
if j % 4 == 0:
points.append([points[i][0] + pos_change, points[i][1]])
i += 1
j += 1
pygame.display.update()
clock.tick(60)