Skip to content

Instantly share code, notes, and snippets.

@CDWimmer
Created March 24, 2019 04:33
Show Gist options
  • Save CDWimmer/056276a134bc3800ab8bc441bf8de5e1 to your computer and use it in GitHub Desktop.
Save CDWimmer/056276a134bc3800ab8bc441bf8de5e1 to your computer and use it in GitHub Desktop.
#You want aids? you got it:
#(c) gogglebot motherfucker
#last edit at 4 fucking am
import pyglet
import numpy as np
from random import randint
window = pyglet.window.Window()
class State(object):
def __init__(self):
self.dangle = 1 # interval in angle
self.max_points = 40
self.white = [255]*3
self.radius = 150
self.points = []
self.colours = []
self.vertex_count = 0
game = State()
vertex_list = pyglet.graphics.vertex_list_indexed(3,
[],'v2d', 'c3B',
)
# generate circle point coords into appropriate lists with corrosponding colours
def generate_vertices():
game.points = [window.width //2,window.height //2]
game.colours = [0,0,0]
game.vertex_count = 1
indices = [0]
#first coord in the centre as the polygon is based on it
for i in np.linspace(0,360,game.max_points):
x = (np.cos(np.deg2rad(i))* game.radius) + (window.width //2)
y = (np.sin(np.deg2rad(i))* game.radius) + (window.height //2)
#squishy-izer
x += randint(-5,5)
y += randint(-5,5)
game.points.append(x)
game.points.append(y)
game.colours.extend(game.white)
#game.colours.extend([randint(0,255),randint(0,255),randint(0,255)])
#update vertex list
for i in range(1,(len(game.points)//2)+2): #offset by 1 and +1 due to
indices.append(i) #centre point pre-addition
#indices.append(0)
vertex_list.resize(len(game.points)//2, len(indices))
vertex_list.vertices = game.points
vertex_list.colors = game.colours
vertex_list.indices = indices
print("coords: ", len(game.points)//2)
##print("colors: ", len(game.colours)//3)
@window.event()
def on_draw():
window.clear()
game.max_points -= game.dangle
if(game.max_points <= 1):
print("Done")
exit()
generate_vertices()
vertex_list.draw(pyglet.gl.GL_POLYGON)
print("drawing")
#apparently just pressing certain keys makes it take a step here so just
#hit spacebar to iterate through the fun shapes
def update(dt):
pass
#pyglet.clock.schedule_interval(update, 1/10.0)
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment