Paddle-Ball/scenes/main.gd
HomeMadeGames Studio facc1dac5a Paddle-Ball 1.01
2024-07-16 23:00:08 -04:00

28 lines
551 B
GDScript

extends Sprite2D
var score := [0, 0]# 0:Player, 1: CPU
# Speed at which the paddles move.
const PADDLE_SPEED : int = 500
# goal sound
@onready var scorePlayerSound = $scorePlayer
@onready var scoreCpuSound = $scoreCPU
func _on_ball_timer_timeout():
$Ball.new_ball()
func _on_score_left_body_entered(body):
score [1] += 1
$Hud/CPUScore.text = str(score[1])
scoreCpuSound.play()
$ballTimer.start()
func _on_score_right_body_entered(body):
score [0] += 1
$Hud/PlayerScore.text = str(score[0])
$ballTimer.start()
scorePlayerSound.play()