Skip to content

Instantly share code, notes, and snippets.

@nst
Last active November 25, 2024 17:31
Show Gist options
  • Save nst/3f987d236c9e7e7dffe1cf5f399bf7ab to your computer and use it in GitHub Desktop.
Save nst/3f987d236c9e7e7dffe1cf5f399bf7ab to your computer and use it in GitHub Desktop.
import pygame as p
import random as m
R=range
r=m.randrange
S=(480,320)
def n(l,v):
for i in R(4):
v[i]*=-1+2*(l[i]+v[i]in R(S[i%2]))
return[l[i]+v[i]for i in R(4)]
V=[[r(-9,9,2)]*4for _ in R(5)]
L=[[r(x)for x in S+S]for _ in R(5)]
p.init()
s=p.display.set_mode(S)
while 1:
L=[n(L[g],V[g])for g in R(5)]+L[:8*5]
s.fill([0]*3);[p.draw.line(s,[255]*3,l[0:2],l[2:4])for l in L]
p.display.update();p.event.get();p.time.delay(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment