How to use the asteroid.Asteroid function in asteroid

To help you get started, we’ve selected a few asteroid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vojtechruz / pyladies-7 / zaverecny-projekt / asteroids / v16_engine / asteroids.py View on Github external
def init_asteroids():
    for i in range(ASTEROID_COUNT):
        asteroid = Asteroid(batch)
        position = random.choice([0,1])
        if position == 0:
            asteroid.x = random.randint(0, window.width)
            asteroid.y = random.choice([0, window.height])
        else:
            asteroid.x = random.choice([0, window.width])
            asteroid.y = random.randint(0, window.height)

        asteroid.x_speed = random.choice([-1,1]) * random.randint(ASTEROID_MIN_SPEED,ASTEROID_MAX_SPEED)
        asteroid.y_speed = random.choice([-1,1]) * random.randint(ASTEROID_MIN_SPEED,ASTEROID_MAX_SPEED)
        objects.append(asteroid)
github vojtechruz / pyladies-7 / zaverecny-projekt / asteroids / v10_asteroids_added / asteroids.py View on Github external
def init_asteroids():
    for i in range(ASTEROID_COUNT):
        asteroid = Asteroid()
        position = random.choice([0,1])
        if position == 0:
            asteroid.x = random.randint(0, window.width)
            asteroid.y = random.choice([0, window.height])
        else:
            asteroid.x = random.choice([0, window.width])
            asteroid.y = random.randint(0, window.height)

        asteroid.x_speed = random.choice([-1,1]) * random.randint(ASTEROID_MIN_SPEED,ASTEROID_MAX_SPEED)
        asteroid.y_speed = random.choice([-1,1]) * random.randint(ASTEROID_MIN_SPEED,ASTEROID_MAX_SPEED)
        objects.append(asteroid)
github irskep / pyglettutorial / version5 / game / load.py View on Github external
def asteroids(num_asteroids, player_position, batch=None):
    """Generate asteroid objects with random positions and velocities, not close to the player"""
    asteroids = []
    for i in range(num_asteroids):
        asteroid_x, asteroid_y = player_position
        while util.distance((asteroid_x, asteroid_y), player_position) < 100:
            asteroid_x = random.randint(0, 800)
            asteroid_y = random.randint(0, 600)
        new_asteroid = asteroid.Asteroid(x=asteroid_x, y=asteroid_y, batch=batch)
        new_asteroid.rotation = random.randint(0, 360)
        new_asteroid.velocity_x, new_asteroid.velocity_y = random.random()*40, random.random()*40
        asteroids.append(new_asteroid)
    return asteroids
github vojtechruz / pyladies-7 / zaverecny-projekt / asteroids / v18_cooldown / asteroids.py View on Github external
def init_asteroids():
    for i in range(ASTEROID_COUNT):
        asteroid = Asteroid(batch, objects)
        position = random.choice([0,1])
        if position == 0:
            asteroid.x = random.randint(0, window.width)
            asteroid.y = random.choice([0, window.height])
        else:
            asteroid.x = random.choice([0, window.width])
            asteroid.y = random.randint(0, window.height)

        asteroid.x_speed = random.choice([-1,1]) * random.randint(ASTEROID_MIN_SPEED,ASTEROID_MAX_SPEED)
        asteroid.y_speed = random.choice([-1,1]) * random.randint(ASTEROID_MIN_SPEED,ASTEROID_MAX_SPEED)
github irskep / pyglettutorial / version4 / game / load.py View on Github external
def asteroids(num_asteroids, player_position, batch):
    """Generate asteroid objects with random positions and velocities, not close to the player"""
    asteroids = []
    for i in range(num_asteroids):
        asteroid_x, asteroid_y = player_position
        while util.distance((asteroid_x, asteroid_y), player_position) < 100:
            asteroid_x = random.randint(0, 800)
            asteroid_y = random.randint(0, 600)
        new_asteroid = asteroid.Asteroid(x=asteroid_x, y=asteroid_y, batch=batch)
        new_asteroid.rotation = random.randint(0, 360)
        new_asteroid.vx, new_asteroid.vy = random.random()*40, random.random()*40
        asteroids.append(new_asteroid)
    return asteroids