Skip to content

Instantly share code, notes, and snippets.

@raek
Created November 8, 2015 20:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save raek/884d933492e4a790e82f to your computer and use it in GitHub Desktop.
Super advanced simulation
import pygame
import sys
assert sys.version_info.major == 2, "This is a Python 2 program"
def draw(surface, width, height, time):
surface.fill((0, 255, 0))
for i in range(256):
v = (i + (time / 10)) % 256
color = (v, v, v)
rect = (2 * i, 0, 2, height)
surface.fill(color, rect)
def run():
pygame.init()
width = 512
height = 128
frame_rate = 60
surface = pygame.display.set_mode((width, height))
clock = pygame.time.Clock()
time = 0
while True:
event = pygame.event.poll()
if event.type == pygame.QUIT:
break
draw(surface, width, height, time)
pygame.display.flip()
time += clock.tick(frame_rate)
pygame.quit()
return 0
if __name__ == "__main__":
sys.exit(run())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment