[ot][spam][crazy][crazy][spam]
Karl Semich
0xloem at gmail.com
Fri Jun 17 12:22:40 PDT 2022
class Particle:
def __init__(self, x, y, duration, xv = 0, yv = 0, bounds):
self.x = x
self.y = y
self.t = duration
self.xv = xv
self.yv = yv
def update(self, time):
self.x += self.xv * time
self.y += self.yv * time
self.t -= duration
return self.t >= 0
class ParticleGenerator:
def __init__(self, rate):
self.particles = []
self.rate = rate
self.time_modulus = 0
def update(self, time):
# i'd like to check the constant rate logic in this line
new_particle_count, self.time_modulus = divmod(time +
self.time_modulus, self.rate)
new_particles_made = 0
for idx, particle in enumerate(self.particles):
if particle is None or not particle.update(time):
if new_particles_made < new_particle_count:
self.particles[idx] = self.new_particle()
else:
self.particles[idx] = None
while new_particles_made < new_particle_count:
self.particles.append(self.new_particle())
import random
class CharacterFountain(ParticleGenerator):
def __init__(self, character = '*', gravity = 9.8, fountain_strength
= 10, width=80, height=25, character_aspect = 0.5):
self.character = character
self.gravity = gravity
self.rows = height
self.cols = width
i'd like to calculate the maximum x velocity of a particle that
starts at the bottom center
of the view rectangle, so as to reach the outer corner when it
lands, by solving the parabola
def new_particle(self):
return self.Particle(self)
class Particle(Particle):
def __init__(self, fountain):
self.fountain = fountain
super().__init__((fountain.rows-1) / 2, fountain.cols - 1,
More information about the cypherpunks
mailing list