Dojo Defender Sessie 1: Cheatsheet

# Schip bewegen
if keyboard.left and ship.x > 30:
    ship.x -= 5
if keyboard.right and ship.x < WIDTH - 30:
    ship.x += 5
# Asteroïde spawnen
def spawn_asteroid():
    rock = Actor('asteroid_big')
    rock.x = random.randint(30, WIDTH - 30)
    rock.y = -30
    rock.speed = random.uniform(3, 5)
    asteroids.append(rock)
# Timer elke seconde (60 frames)
timer += 1
if timer % 60 == 0:
    spawn_asteroid()
# Asteroïden laten vallen en verwijderen
for rock in asteroids[:]:
    rock.y += rock.speed
    if rock.y > HEIGHT + 30:
        asteroids.remove(rock)
# Collision detectie
if rock.colliderect(ship) and not invincible:
    lives -= 1
    # start explosie
# Explosie afspelen
explosion.pos = (ship.x, ship.y)
explosion.image = 'explosion_1'
explosion_frame = 1
explosion_timer = 5
explosion_active = True
ship.visible = False
# Game over scherm
if game_over:
    screen.draw.text("GAME OVER", center=(WIDTH/2, HEIGHT/2),
                     color="red", fontsize=60)
# Levens tonen
screen.draw.text(f"Lives: {lives}", (10, 40), color="red", fontsize=24)