Menu
CoddyTech

Breakout Paddle

Part of the Projects section of Coddy's Godot journey. Lesson 1 of 33.

In this chapter you build Breakout: a paddle, a ball, bricks, a score, lives and a way to win. The game runs after every step, so press Play often.

The game has three scripts, each in its own tab: paddle.gd, ball.gd and main.gd for the rest of the game. They start almost empty.

First, the paddle slides left and right on the keys. Input.get_axis gives -1 while Left is held, 1 for Right and 0 for neither.

func _physics_process(delta):
	var direction = Input.get_axis("move_left", "move_right")
	position.x += direction * SPEED * delta

Multiplying by delta makes SPEED a number of pixels per second.

challenge icon

Challenge

Easy

In paddle.gd:

  1. Add const SPEED = 400 at the top.
  2. In _physics_process, move the paddle left and right with move_left and move_right, at SPEED pixels per second.

Try it yourself

extends CharacterBody2D

func _physics_process(delta):
	pass
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Projects

Practice on your own: Godot playground