Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Battle Pong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Frederic Aust
Battle Pong
Commits
c94988b4
Commit
c94988b4
authored
Dec 20, 2020
by
Frederic Aust
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Battle Pong/Ball.gd
+7
-5
7 additions, 5 deletions
Battle Pong/Ball.gd
Battle Pong/Ball.tscn
+5
-3
5 additions, 3 deletions
Battle Pong/Ball.tscn
Battle Pong/Main.tscn
+34
-0
34 additions, 0 deletions
Battle Pong/Main.tscn
Battle Pong/Player.tscn
+1
-0
1 addition, 0 deletions
Battle Pong/Player.tscn
with
47 additions
and
8 deletions
Battle Pong/Ball.gd
+
7
−
5
View file @
c94988b4
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Battle Pong/Ball.tscn
+
5
−
3
View file @
c94988b4
...
...
@@ -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 )
This diff is collapsed.
Click to expand it.
Battle Pong/Main.tscn
+
34
−
0
View file @
c94988b4
...
...
@@ -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"]
This diff is collapsed.
Click to expand it.
Battle Pong/Player.tscn
+
1
−
0
View file @
c94988b4
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment