Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import time
- DW = DH = 400 # DisplayWidth, DisplayHeight
- HDW = int(DW / 2) # HalfDisplayWidth
- HDH = int(DH / 2) # HalfDisplayHeight
- pygame.init()
- PD = pygame.display.set_mode((DW, DH)) # PD = Primary Display
- # colors
- RED = [255, 0, 0]
- AMBER = [255,191,0]
- GREEN = [0, 255, 0]
- colors = [RED, AMBER, GREEN]
- colorIndex = 0
- timeStamp = -1
- # press escape to get out!
- while True:
- e = pygame.event.get()
- if pygame.key.get_pressed()[pygame.K_ESCAPE]: break
- now = time.time()
- if now - timeStamp >= 0.5:
- pygame.draw.circle(PD, colors[colorIndex], (100, 100), 100)
- pygame.display.update()
- colorIndex += 1
- if colorIndex == len(colors): colorIndex = 0
- timeStamp = now
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement