TutorialsFirst game

Tutorial: Your First Game

You will build a small paddle-and-ball loop with movement, collision, score text, and a win condition.

Set up the frame

from conjure import *
 
init_window(360, 640, "Paddle Ball")
set_target_fps(60)
 
paddle_x = 140
ball_x = 180
ball_y = 120
ball_dx = 3
ball_dy = 4
score = 0

Update player and ball

Add keyboard controls with KEY_LEFT and KEY_RIGHT. Move the ball each frame, bounce it off the walls, and increase the score when it reaches the paddle.

Draw the frame

while not window_should_close():
    if is_key_down(KEY_LEFT):
        paddle_x -= 5
    if is_key_down(KEY_RIGHT):
        paddle_x += 5
 
    ball_x += ball_dx
    ball_y += ball_dy
 
    if ball_x < 20 or ball_x > 340:
        ball_dx *= -1
    if ball_y < 20:
        ball_dy *= -1
 
    begin_drawing()
    clear_background(WHITE)
    draw_rectangle(paddle_x, 560, 80, 16, BLUE)
    draw_circle(ball_x, ball_y, 16, RED)
    draw_text(f"Score: {score}", 18, 18, 22, BLACK)
    end_drawing()

What next

Add sound effects, save the best score with save data, then publish with the publishing guide.