pongodot

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

commit ac12d83be524afdb368ac84ce86cbc7ebd5ed54f
parent 1464c1ff5590329b597b9c5170b0431e3148aaf7
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Mon, 11 Nov 2019 06:13:33 -0500

Updated textures, background, window bounds

Diffstat:
MBall.gd | 12++++++++----
MBall.tscn | 15++++++++++++---
MGame.tscn | 52+++++++++++++++++++++++++++++++++++++++-------------
MGoal.tscn | 3+--
MPaddle.tscn | 16+++++++++++++---
ASprites/System6-Slice.aseprite | 0
ASprites/System6-Slice.png | 0
ASprites/System6-Slice.png.import | 34++++++++++++++++++++++++++++++++++
ASprites/bg-01.aseprite | 0
ASprites/bg-01.png | 0
ASprites/bg-01.png.import | 34++++++++++++++++++++++++++++++++++
Mproject.godot | 4++--
12 files changed, 143 insertions(+), 27 deletions(-)

diff --git a/Ball.gd b/Ball.gd @@ -2,6 +2,8 @@ extends KinematicBody2D export var _speed = 10 var _dir = Vector2(1, 1) +var _radius = 0 + func _ready(): reset() @@ -12,12 +14,14 @@ func _physics_process(delta): if collision: print(collision.collider.name) _dir = _dir.bounce(collision.normal) - if position.x >= get_viewport().size.x or position.x < 0: + if position.x >= get_viewport().size.x - _radius or position.x < _radius: _dir.x *= -1 - if position.y >= get_viewport().size.y or position.y < 0: + if position.y >= get_viewport().size.y - _radius or position.y < _radius: _dir.y *= -1 func reset(): _dir = _dir.normalized() - position = get_viewport().size / 2- \ No newline at end of file + position = get_viewport().size / 2 + var shape = $CollisionShape2D.shape as CircleShape2D + _radius = shape.radius+ \ No newline at end of file diff --git a/Ball.tscn b/Ball.tscn @@ -1,16 +1,25 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://Ball.gd" type="Script" id=1] -[ext_resource path="res://Assets/Sprites/Ball.png" type="Texture" id=2] +[ext_resource path="res://Sprites/System6-Slice.png" type="Texture" id=2] [sub_resource type="CircleShape2D" id=1] -radius = 16.0 [node name="Ball" type="KinematicBody2D"] script = ExtResource( 1 ) -[node name="Sprite" type="Sprite" parent="."] +[node name="NinePatchRect" type="NinePatchRect" parent="."] +margin_left = -10.0 +margin_top = -10.0 +margin_right = 10.0 +margin_bottom = 10.0 texture = ExtResource( 2 ) +patch_margin_left = 6 +patch_margin_top = 6 +patch_margin_right = 6 +patch_margin_bottom = 6 +axis_stretch_horizontal = 2 +axis_stretch_vertical = 2 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) diff --git a/Game.tscn b/Game.tscn @@ -1,30 +1,56 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=7 format=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] +[ext_resource path="res://Sprites/bg-01.png" type="Texture" id=2] +[ext_resource path="res://Ball.tscn" type="PackedScene" id=3] +[ext_resource path="res://Paddle.tscn" type="PackedScene" id=4] +[ext_resource path="res://Goal.tscn" type="PackedScene" id=5] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 256, 2 ) [node name="Game" type="Node2D"] script = ExtResource( 1 ) game_score = 3 -[node name="Ball" parent="." instance=ExtResource( 2 )] -position = Vector2( 320, 240 ) +[node name="Background" type="TextureRect" parent="."] +margin_right = 512.0 +margin_bottom = 342.0 +texture = ExtResource( 2 ) +stretch_mode = 2 + +[node name="Ball" parent="." instance=ExtResource( 3 )] +position = Vector2( 256, 171 ) _speed = 128 -[node name="Paddle 1" parent="." instance=ExtResource( 3 )] -position = Vector2( 40, 240 ) +[node name="Paddle 1" parent="." instance=ExtResource( 4 )] +position = Vector2( 26, 171 ) _speed = 64 -[node name="Goal 1" parent="." instance=ExtResource( 4 )] +[node name="Goal 1" parent="." instance=ExtResource( 5 )] +position = Vector2( 504, 171 ) -[node name="Paddle 2" parent="." instance=ExtResource( 3 )] -position = Vector2( 600, 240 ) +[node name="Paddle 2" parent="." instance=ExtResource( 4 )] +position = Vector2( 486, 171 ) _speed = 64 _player = "p2" -[node name="Goal 2" parent="." instance=ExtResource( 4 )] -position = Vector2( 12, 240 ) +[node name="Goal 2" parent="." instance=ExtResource( 5 )] +position = Vector2( 8, 171 ) + +[node name="PaddleBounds" type="StaticBody2D" parent="."] +editor/display_folded = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="PaddleBounds"] +position = Vector2( 256, -2 ) +shape = SubResource( 1 ) + +[node name="PaddleBounds2" type="StaticBody2D" parent="."] +editor/display_folded = true +position = Vector2( 0, 346 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="PaddleBounds2"] +position = Vector2( 256, -2 ) +shape = SubResource( 1 ) [connection signal="body_entered" from="Goal 1" to="." method="_on_Goal_1_body_entered"] [connection signal="body_entered" from="Goal 2" to="." method="_on_Goal_2_body_entered"] diff --git a/Goal.tscn b/Goal.tscn @@ -1,10 +1,9 @@ [gd_scene load_steps=2 format=2] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 12, 240 ) +extents = Vector2( 8, 171 ) [node name="Goal" type="Area2D"] -position = Vector2( 628, 240 ) __meta__ = { "_edit_group_": true } diff --git a/Paddle.tscn b/Paddle.tscn @@ -1,16 +1,26 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://Paddle.gd" type="Script" id=1] -[ext_resource path="res://Assets/Sprites/Paddle.png" type="Texture" id=2] +[ext_resource path="res://Sprites/System6-Slice.png" type="Texture" id=2] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 16, 64 ) +extents = Vector2( 10, 60 ) [node name="Paddle" type="KinematicBody2D"] script = ExtResource( 1 ) -[node name="Sprite" type="Sprite" parent="."] +[node name="NinePatchRect" type="NinePatchRect" parent="."] +margin_left = -10.0 +margin_top = -60.0 +margin_right = 10.0 +margin_bottom = 60.0 texture = ExtResource( 2 ) +patch_margin_left = 6 +patch_margin_top = 6 +patch_margin_right = 6 +patch_margin_bottom = 6 +axis_stretch_horizontal = 2 +axis_stretch_vertical = 2 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) diff --git a/Sprites/System6-Slice.aseprite b/Sprites/System6-Slice.aseprite Binary files differ. diff --git a/Sprites/System6-Slice.png b/Sprites/System6-Slice.png Binary files differ. diff --git a/Sprites/System6-Slice.png.import b/Sprites/System6-Slice.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/System6-Slice.png-24aedbe7743d7799ba54c724004f0e44.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/System6-Slice.png" +dest_files=[ "res://.import/System6-Slice.png-24aedbe7743d7799ba54c724004f0e44.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Sprites/bg-01.aseprite b/Sprites/bg-01.aseprite Binary files differ. diff --git a/Sprites/bg-01.png b/Sprites/bg-01.png Binary files differ. diff --git a/Sprites/bg-01.png.import b/Sprites/bg-01.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/bg-01.png-e8ad572a0853ba4e35bae544be6d2bdb.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/bg-01.png" +dest_files=[ "res://.import/bg-01.png-e8ad572a0853ba4e35bae544be6d2bdb.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot @@ -21,8 +21,8 @@ config/icon="res://icon.png" [display] -window/size/width=640 -window/size/height=480 +window/size/width=512 +window/size/height=342 window/stretch/mode="viewport" window/stretch/aspect="keep"