commit
a035b749e5
|
|
@ -0,0 +1,4 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Normalize EOL for all files that Git considers text files.
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Godot 4+ specific ignores
|
||||||
|
.godot/
|
||||||
|
/android/
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=5
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="Pong v1"
|
||||||
|
run/main_scene="uid://bbjstb404m82i"
|
||||||
|
config/features=PackedStringArray("4.7", "GL Compatibility")
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/window_width_override=4608
|
||||||
|
window/size/window_height_override=2592
|
||||||
|
window/stretch/mode="canvas_items"
|
||||||
|
|
||||||
|
[file_customization]
|
||||||
|
|
||||||
|
folder_colors={
|
||||||
|
"res://res/": "red",
|
||||||
|
"res://scene/": "blue",
|
||||||
|
"res://scripts/": "green"
|
||||||
|
}
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
|
||||||
|
3d/physics_engine="Jolt Physics"
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
textures/canvas_textures/default_texture_filter=0
|
||||||
|
rendering_device/driver.windows="d3d12"
|
||||||
|
renderer/rendering_method="gl_compatibility"
|
||||||
|
renderer/rendering_method.mobile="gl_compatibility"
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 121 B |
|
|
@ -0,0 +1,40 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://da8abrotmo5ak"
|
||||||
|
path="res://.godot/imported/ball.png-5185ee4583a020e7d5eee4c0e66e0b9f.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://res/ball.png"
|
||||||
|
dest_files=["res://.godot/imported/ball.png-5185ee4583a020e7d5eee4c0e66e0b9f.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 101 B |
|
|
@ -0,0 +1,40 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bm7l6nkjhoalt"
|
||||||
|
path="res://.godot/imported/tennis_racket.png-11d683821eebafa96add1a4cb6453c45.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://res/tennis_racket.png"
|
||||||
|
dest_files=["res://.godot/imported/tennis_racket.png-11d683821eebafa96add1a4cb6453c45.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
[gd_scene format=3 uid="uid://bbjstb404m82i"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dfyo1afvep6t6" path="res://scripts/Main.gd" id="1_qr3af"]
|
||||||
|
[ext_resource type="Script" uid="uid://cqsd7fd7uxl02" path="res://scripts/ball.gd" id="2_qr3af"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://da8abrotmo5ak" path="res://res/ball.png" id="3_s0gh3"]
|
||||||
|
[ext_resource type="Script" uid="uid://gqr2e4p78fj0" path="res://scripts/plank_right.gd" id="4_qr3af"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bm7l6nkjhoalt" path="res://res/tennis_racket.png" id="5_dajfr"]
|
||||||
|
[ext_resource type="Script" uid="uid://unjro3ilrl38" path="res://scripts/plank_left.gd" id="6_qr3af"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_j8iw7"]
|
||||||
|
radius = 3.0
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bfdcr"]
|
||||||
|
size = Vector2(2, 16)
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_j8iw7"]
|
||||||
|
size = Vector2(2, 16)
|
||||||
|
|
||||||
|
[node name="Main" type="Node2D" unique_id=1753431167 node_paths=PackedStringArray("ball", "score_label")]
|
||||||
|
script = ExtResource("1_qr3af")
|
||||||
|
ball = NodePath("Ball")
|
||||||
|
score_label = NodePath("ScoreLabel")
|
||||||
|
|
||||||
|
[node name="Ball" type="CharacterBody2D" parent="." unique_id=1987649111]
|
||||||
|
position = Vector2(576, 324)
|
||||||
|
scale = Vector2(2, 2)
|
||||||
|
script = ExtResource("2_qr3af")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Ball" unique_id=1376160524]
|
||||||
|
texture_filter = 1
|
||||||
|
texture = ExtResource("3_s0gh3")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ball" unique_id=1355308215]
|
||||||
|
shape = SubResource("CircleShape2D_j8iw7")
|
||||||
|
|
||||||
|
[node name="SchlaegerRechts" type="CharacterBody2D" parent="." unique_id=757473239]
|
||||||
|
position = Vector2(1092, 324)
|
||||||
|
scale = Vector2(2, 5)
|
||||||
|
motion_mode = 1
|
||||||
|
script = ExtResource("4_qr3af")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="SchlaegerRechts" unique_id=120109385]
|
||||||
|
texture_filter = 1
|
||||||
|
texture = ExtResource("5_dajfr")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="SchlaegerRechts" unique_id=396129192]
|
||||||
|
shape = SubResource("RectangleShape2D_bfdcr")
|
||||||
|
|
||||||
|
[node name="SchlaegerLinks" type="CharacterBody2D" parent="." unique_id=339062000]
|
||||||
|
position = Vector2(60, 324)
|
||||||
|
scale = Vector2(2, 5)
|
||||||
|
motion_mode = 1
|
||||||
|
script = ExtResource("6_qr3af")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="SchlaegerLinks" unique_id=295421432]
|
||||||
|
texture_filter = 1
|
||||||
|
texture = ExtResource("5_dajfr")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="SchlaegerLinks" unique_id=297131425]
|
||||||
|
shape = SubResource("RectangleShape2D_j8iw7")
|
||||||
|
|
||||||
|
[node name="ScoreLabel" type="Label" parent="." unique_id=1588816466]
|
||||||
|
offset_left = 519.0
|
||||||
|
offset_top = 216.0
|
||||||
|
offset_right = 633.0
|
||||||
|
offset_bottom = 266.0
|
||||||
|
theme_override_font_sizes/font_size = 36
|
||||||
|
text = "Punkt!"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="." unique_id=966032468]
|
||||||
|
position = Vector2(576, 324)
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@export var ball: CharacterBody2D
|
||||||
|
@export var score_label: Label
|
||||||
|
|
||||||
|
var score_links : int = 0
|
||||||
|
var score_rechts : int = 0
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
# Automatischer Fallback, falls im Inspektor die Zuweisung vergessen wurde
|
||||||
|
if not ball: ball = $Ball
|
||||||
|
if not score_label: score_label = $ScoreLabel
|
||||||
|
update_score_display()
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
# Prüfen, ob der Ball links aus dem Bildschirm fliegt
|
||||||
|
if ball.global_position.x < 0:
|
||||||
|
score_rechts += 1
|
||||||
|
update_score_display()
|
||||||
|
ball.reset_ball()
|
||||||
|
|
||||||
|
# Prüfen, ob der Ball rechts aus dem Bildschirm fliegt
|
||||||
|
elif ball.global_position.x > 1152:
|
||||||
|
score_links += 1
|
||||||
|
update_score_display()
|
||||||
|
ball.reset_ball()
|
||||||
|
|
||||||
|
func update_score_display() -> void:
|
||||||
|
if score_label:
|
||||||
|
score_label.text = str(score_links) + " : " + str(score_rechts)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dfyo1afvep6t6
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
@export var START_SPEED = 300.0
|
||||||
|
@export var SPEED_INCREMENT = 20.0
|
||||||
|
|
||||||
|
var current_speed = START_SPEED
|
||||||
|
var direction = Vector2.ZERO
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
reset_ball()
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
# Bewegt den Ball und handhabt die Kollisionen mit den Schlägern
|
||||||
|
var collision = move_and_collide(direction * current_speed * delta)
|
||||||
|
|
||||||
|
if collision:
|
||||||
|
direction = direction.bounce(collision.get_normal())
|
||||||
|
current_speed += SPEED_INCREMENT
|
||||||
|
|
||||||
|
# Abprallen an den horizontalen Rändern (oben und unten)
|
||||||
|
if global_position.y < 0 or global_position.y > 648:
|
||||||
|
direction.y *= -1
|
||||||
|
|
||||||
|
func reset_ball() -> void:
|
||||||
|
# Startet exakt in der Mitte des 1152x648 Bildschirms
|
||||||
|
global_position = Vector2(576, 324)
|
||||||
|
current_speed = START_SPEED
|
||||||
|
|
||||||
|
# Zufällige Richtung nach links oder rechts starten
|
||||||
|
var x_dir = 1 if randf() > 0.5 else -1
|
||||||
|
var y_dir = randf_range(-0.5, 0.5)
|
||||||
|
direction = Vector2(x_dir, y_dir).normalized()
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cqsd7fd7uxl02
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
const SPEED = 500.0
|
||||||
|
|
||||||
|
func _physics_process(_delta: float) -> void:
|
||||||
|
var direction = 0
|
||||||
|
if Input.is_key_pressed(KEY_S):
|
||||||
|
direction += 1
|
||||||
|
if Input.is_key_pressed(KEY_W):
|
||||||
|
direction -= 1
|
||||||
|
|
||||||
|
velocity.y = direction * SPEED
|
||||||
|
move_and_slide()
|
||||||
|
|
||||||
|
# Begrenzung (angepasst an größere Schläger)
|
||||||
|
global_position.y = clamp(global_position.y, 54, 594)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://unjro3ilrl38
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
const SPEED = 400.0
|
||||||
|
|
||||||
|
func _physics_process(_delta: float) -> void:
|
||||||
|
var direction = 0
|
||||||
|
if Input.is_action_pressed("ui_down"):
|
||||||
|
direction += 1 # Nach unten
|
||||||
|
if Input.is_action_pressed("ui_up"):
|
||||||
|
direction -= 1 # Nach oben
|
||||||
|
|
||||||
|
velocity.y = direction * SPEED
|
||||||
|
move_and_slide()
|
||||||
|
|
||||||
|
# Begrenzt den Schläger, damit er nicht aus dem Bildschirm fliegt
|
||||||
|
global_position.y = clamp(global_position.y, 54, 594)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://gqr2e4p78fj0
|
||||||
Loading…
Reference in New Issue