mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-06 16:00:08 +01:00
Update all Pong demos to Godot 3.1.2 and conform to style guides
This commit is contained in:
@@ -2,17 +2,12 @@ using Godot;
|
||||
|
||||
public class Ball : Area2D
|
||||
{
|
||||
private const int BallSpeed = 100;
|
||||
private const int DefaultSpeed = 100;
|
||||
|
||||
public Vector2 direction = Vector2.Left;
|
||||
|
||||
private Vector2 _initialPos;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Position = _initialPos;
|
||||
direction = Vector2.Left;
|
||||
}
|
||||
private float _speed = DefaultSpeed;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -21,6 +16,14 @@ public class Ball : Area2D
|
||||
|
||||
public override void _Process(float delta)
|
||||
{
|
||||
Position += BallSpeed * delta * direction;
|
||||
_speed += delta * 2;
|
||||
Position += _speed * delta * direction;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
direction = Vector2.Left;
|
||||
Position = _initialPos;
|
||||
_speed = DefaultSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ extents = Vector2( 320, 10 )
|
||||
|
||||
[node name="Pong" type="Node2D"]
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
margin_right = 640.0
|
||||
margin_bottom = 400.0
|
||||
color = Color( 0.141176, 0.152941, 0.164706, 1 )
|
||||
|
||||
[node name="Left" type="Area2D" parent="."]
|
||||
position = Vector2( 67.6285, 192.594 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
@@ -37,6 +37,7 @@ left_move_down={
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
left_move_up={
|
||||
@@ -44,6 +45,7 @@ left_move_up={
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
right_move_down={
|
||||
|
||||
Reference in New Issue
Block a user