Add menu system and scene navigation
The changes include: - Moving script files to scripts/ directory - Creating Start menu scene with Play/Quit buttons - Adding scene switching between menu and gameplay - Creating theme for menu buttons - Adding ESC key to return to menu
This commit is contained in:
parent
83ff6ef14d
commit
49988ae674
14 changed files with 202 additions and 6 deletions
25
Paddle.gd
25
Paddle.gd
|
|
@ -1,25 +0,0 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
const SPEED: float = 350.0
|
||||
|
||||
@export var player_id: int
|
||||
@export var score_label: Label
|
||||
var score: int = 0
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed('up-%d' % player_id):
|
||||
velocity = Vector2(0, -SPEED)
|
||||
if event.is_action_pressed( 'down-%d' % player_id):
|
||||
velocity = Vector2(0, SPEED)
|
||||
if event.is_action_released('up-%d' % player_id) or \
|
||||
event.is_action_released('down-%d' % player_id):
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
func increment_score():
|
||||
# score one point
|
||||
score += 1
|
||||
# update the UI label
|
||||
score_label.text = '%02d' % score
|
||||
Loading…
Add table
Add a link
Reference in a new issue