Skip to content
Snippets Groups Projects
Commit c94988b4 authored by Frederic Aust's avatar Frederic Aust
Browse files

Ball wird nun richtig von den Wänden reflektiert und die Spielfeldmarkierung wurde hinzugefügt

parent dc6697ca
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,8 @@ extends RigidBody2D
# Declare member variables here.
export var speed = 200
export var speed = 300
var ball_size
var playing = false
var dx =100
var dy =0
......@@ -28,15 +29,15 @@ func _physics_process(delta):
func ball_hit_paddle():
dx *= -1
dy = rand_range(-y_range, y_range)
if speed < 300:
speed += 5
if y_range < 200:
y_range += 5
func change_dy_on_wall_hit():
if self.position.y <= 0:
if self.position.y <= 0+ball_size.y:
dy = rand_range(0, y_range)
if self.position.y >= 600:
if self.position.y >= 600-ball_size.y:
dy = rand_range(-y_range, 0)
func set_playing(_playing):
......@@ -46,3 +47,4 @@ func start(pos):
position = pos
show()
$CollisionShape2D.disabled = false
ball_size =$CollisionShape2D.shape.extents
......@@ -22,11 +22,13 @@ gravity_scale = 0.0
script = ExtResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( -1, -1 )
scale = Vector2( 2, 2 )
position = Vector2( -3, -3 )
scale = Vector2( 6, 6 )
frames = SubResource( 1 )
frame = 1
speed_scale = 2.0
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( -3.8147e-06, -0.132433 )
scale = Vector2( 3, 3 )
shape = SubResource( 2 )
......@@ -57,5 +57,39 @@ position = Vector2( 52, 300 )
is_player_one = false
[node name="PlayerOne" parent="." instance=ExtResource( 1 )]
[node name="ColorRect2" type="ColorRect" parent="."]
margin_right = 1024.0
margin_bottom = 4.0
color = Color( 1, 0, 0, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ColorRect3" type="ColorRect" parent="."]
margin_top = 596.0
margin_right = 1024.0
margin_bottom = 600.0
color = Color( 1, 0, 0, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ColorRect4" type="ColorRect" parent="."]
margin_right = 4.0
margin_bottom = 600.0
color = Color( 1, 0, 0, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ColorRect5" type="ColorRect" parent="."]
margin_left = 1020.0
margin_right = 1024.0
margin_bottom = 600.0
color = Color( 1, 0, 0, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="hit" from="PlayerTwo" to="." method="_on_PlayerTwo_hit"]
[connection signal="hit" from="PlayerOne" to="." method="_on_PlayerOne_hit"]
......@@ -27,6 +27,7 @@ position = Vector2( -1.5, 0 )
scale = Vector2( 3, 6 )
frames = SubResource( 1 )
animation = "wave"
frame = 2
speed_scale = 2.0
playing = true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment