import pocketgl as gl import time import math gl.init_window('My game', 800, 600) t = 0 while True: gl.clear_screen() gl.current_color(int(127 + 127 * math.cos(t)), int(127 + 127 * math.cos(2 * t)), int(127 + 127 * math.cos(4 * t))) gl.disc(400, 300, 50) gl.refresh() time.sleep(1 / 60) t += 1 / 60
import pocketgl as gl from types import SimpleNamespace import time import math from random import uniform, gauss gl.init_window('Win', 800, 600, 'sky blue') def vec(x, y): v = SimpleNamespace() v.x = x v.y = y return v def vec_add(u, v): return vec(u.x + v.x, u.y + v.y) def particle(): particle = SimpleNamespace() particle.pos = vec(400 + uniform(-25, 25), 30 + uniform(-20, 20)) particle.speed = vec(gauss(0, 5), uniform(-1, 5)) particle.duration = uniform(0, 1.5) particle.lifetime = 0 return particle def particle_update(p, wind_force): p.lifetime += 1 / 60