pongodot

Tinkering with Godot, remaking pong
git clone git://git.hellocld.com/pongodot
Log | Files | Refs

commit 3081e3b383196d0f6111eeb074571329020095e7
parent 0fcd8f961333ade99874e8cc876cf660ae248703
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Tue,  5 Nov 2019 02:03:01 -0500

Began scene layout, added some elements

- Added a Goal scene for getting score stuff
- Duplicated the paddles and goals in the Game scene
- Added a named enum identifier for the paddles to help with input

Diffstat:
AGame.gd | 7+++++++
MGame.tscn | 27++++++++++++++++++++-------
AGoal.tscn | 13+++++++++++++
MPaddle.gd | 3+++
Mproject.godot | 2+-
5 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/Game.gd b/Game.gd @@ -0,0 +1,6 @@ +extends Node2D + + + +func _on_Goal_body_entered(body): + print("Body " + body.name + " entered")+ \ No newline at end of file diff --git a/Game.tscn b/Game.tscn @@ -1,13 +1,26 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=5 format=2] -[ext_resource path="res://Ball.tscn" type="PackedScene" id=1] -[ext_resource path="res://Paddle.tscn" type="PackedScene" id=2] +[ext_resource path="res://Game.gd" type="Script" id=1] +[ext_resource path="res://Ball.tscn" type="PackedScene" id=2] +[ext_resource path="res://Paddle.tscn" type="PackedScene" id=3] +[ext_resource path="res://Goal.tscn" type="PackedScene" id=4] [node name="Node2D" type="Node2D"] +script = ExtResource( 1 ) -[node name="Ball" parent="." instance=ExtResource( 1 )] -position = Vector2( 55, 50 ) +[node name="Ball" parent="." instance=ExtResource( 2 )] +position = Vector2( 320, 240 ) +_speed = 128 + +[node name="Paddle 1" parent="." instance=ExtResource( 3 )] +position = Vector2( 40, 240 ) +_speed = 64 + +[node name="Paddle 2" parent="." instance=ExtResource( 3 )] +position = Vector2( 600, 240 ) _speed = 64 -[node name="Paddle" parent="." instance=ExtResource( 2 )] -position = Vector2( 333.107, 245.815 ) +[node name="Goal 2" parent="." instance=ExtResource( 4 )] + +[node name="Goal 1" parent="." instance=ExtResource( 4 )] +position = Vector2( 12, 240 ) diff --git a/Goal.tscn b/Goal.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=2 format=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 12, 240 ) + +[node name="Goal" type="Area2D"] +position = Vector2( 628, 240 ) +__meta__ = { +"_edit_group_": true +} + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) diff --git a/Paddle.gd b/Paddle.gd @@ -2,6 +2,9 @@ extends KinematicBody2D export var _speed = 32 +enum player {P1, P2} +export (player) var _player + func _physics_process(delta): var vec = Vector2(0, 0); if Input.is_action_pressed("ui_up"): diff --git a/project.godot b/project.godot @@ -23,7 +23,7 @@ config/icon="res://icon.png" window/size/width=640 window/size/height=480 -window/stretch/mode="2d" +window/stretch/mode="viewport" window/stretch/aspect="keep" [rendering]