def generate_points( self, N, x_min=10, x_max=SCREEN_WIDTH - 10, y_min=20, y_max=SCREEN_HEIGHT - 10, v_min=0.1, v_max=2, ): pts = [] for _ in range(N): x = pyxel.rndi(x_min, x_max) y = pyxel.rndi(y_min, y_max) v = pyxel.rndf(v_min, v_max) angle = pyxel.rndf(0, 360) vx = v * pyxel.cos(angle) vy = v * pyxel.sin(angle) num_edges = pyxel.rndi(1, 2) # NOTE: can connect to self which isn't great connections = [pyxel.rndi(0, N - 1) for _ in range(num_edges)] pt = Point(x=x, y=y, connections=connections, vx=vx, vy=vy) pts.append(pt) return pts
def random(cls): # worked out the original numbers for 120 so whatever, bodge a scale factor VY_SCALE = 5.0 args = dict( x=pyxel.rndi(-10, SCREEN_WIDTH-1), y=pyxel.rndi(-10, 0), vx=0.05 + pyxel.rndf(-0.2, 2.0), vy=pyxel.rndf(VY_SCALE, VY_SCALE + 0.4), col=cls._COLORS[pyxel.rndi(0, len(cls._COLORS)-1)] # vx=0.0, # vy=0.0, ) return cls(**args)
def __init__(self): self.r = pyxel.rndf(3, 10) self.pos = Vec2( pyxel.rndf(self.r, SCREEN_WIDTH - self.r), pyxel.rndf(self.r, SCREEN_HEIGHT - self.r), ) self.vel = Vec2( pyxel.rndf(-MAX_BUBBLE_SPEED, MAX_BUBBLE_SPEED), pyxel.rndf(-MAX_BUBBLE_SPEED, MAX_BUBBLE_SPEED), ) self.color = pyxel.rndi(1, 15)
def __init__(self): self.stars = [] for i in range(NUM_STARS): self.stars.append(( pyxel.rndi(0, pyxel.width - 1), pyxel.rndi(0, pyxel.height - 1), pyxel.rndf(1, 2.5), ))