Menu
CoddyTech

Breakout Paddle

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

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

Move the paddle with the keys.

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

Press Play and hold Left or Right: the paddle slides along the bottom. Then Check.

Try it yourself

extends CharacterBody2D

func _physics_process(delta):
	pass

All lessons in Projects

Practice on your own: Godot playground