pongodot

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

commit 56c52355e05f06d902d8ba70a86063bea055fe3d
parent 75a3fb032ea74d5ba3a825e25b92ea847a326a28
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Tue, 12 Nov 2019 20:42:50 -0500

Added main menu(s). Ball accellerates after every ten paddle hits

Diffstat:
MBall.gd | 10+++++++---
AMainMenu.gd | 24++++++++++++++++++++++++
AMainMenu.tscn | 194+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AStyles/Button-Default.tres | 11+++++++++++
Mproject.godot | 4++--
5 files changed, 238 insertions(+), 5 deletions(-)

diff --git a/Ball.gd b/Ball.gd @@ -3,7 +3,7 @@ extends KinematicBody2D export var _speed = 10 var _dir = Vector2(1, 1) var _radius = 0 - +var _hits = 0 func _ready(): reset() @@ -12,6 +12,9 @@ func _ready(): func _physics_process(delta): var collision = move_and_collide(_dir * _speed * delta) if collision: + _hits += 1 + if _hits % 10 == 0: + _speed += 2 print(collision.collider.name) $AnimationPlayer.play("Boop") _dir = _dir.bounce(collision.normal) @@ -25,4 +28,5 @@ func reset(): _dir = _dir.normalized() position = get_viewport().size / 2 var shape = $CollisionShape2D.shape as CircleShape2D - _radius = shape.radius- \ No newline at end of file + _radius = shape.radius + _hits = 0+ \ No newline at end of file diff --git a/MainMenu.gd b/MainMenu.gd @@ -0,0 +1,24 @@ +extends Node2D + + +func _ready(): + $Menu.visible = true + $About.visible = false + + +func _on_Help_pressed(): + $Menu.visible = false + $About.visible = true + + +func _on_Play_pressed(): + get_tree().change_scene("res://Game.tscn") + + +func _on_Quit_pressed(): + get_tree().quit() + + +func _on_Back_pressed(): + $About.visible = false + $Menu.visible = true diff --git a/MainMenu.tscn b/MainMenu.tscn @@ -0,0 +1,194 @@ +[gd_scene load_steps=12 format=2] + +[ext_resource path="res://MainMenu.gd" type="Script" id=1] +[ext_resource path="res://Sprites/bg-01.png" type="Texture" id=2] +[ext_resource path="res://Sprites/System6-UI-Slice.png" type="Texture" id=3] +[ext_resource path="res://Styles/Button-Default.tres" type="StyleBox" id=4] +[ext_resource path="res://Sprites/System6-Slice2.png" type="Texture" id=5] +[ext_resource path="res://Fonts/Chicago.ttf" type="DynamicFontData" id=6] + +[sub_resource type="StyleBoxTexture" id=1] +texture = ExtResource( 5 ) +region_rect = Rect2( 0, 0, 16, 16 ) +margin_left = 6.0 +margin_right = 6.0 +margin_top = 6.0 +margin_bottom = 6.0 + +[sub_resource type="DynamicFont" id=2] +size = 12 +font_data = ExtResource( 6 ) + +[sub_resource type="DynamicFont" id=5] +size = 96 +outline_color = Color( 0, 0, 0, 1 ) +font_data = ExtResource( 6 ) + +[sub_resource type="DynamicFont" id=3] +size = 32 +outline_color = Color( 0, 0, 0, 1 ) +font_data = ExtResource( 6 ) + +[sub_resource type="DynamicFont" id=4] +size = 12 +outline_color = Color( 0, 0, 0, 1 ) +extra_spacing_bottom = 4 +font_data = ExtResource( 6 ) + +[node name="MainMenu" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Background" type="TextureRect" parent="."] +margin_right = 512.0 +margin_bottom = 342.0 +texture = ExtResource( 2 ) +stretch_mode = 2 + +[node name="Menu" type="NinePatchRect" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = 64.0 +margin_top = 64.0 +margin_right = 448.0 +margin_bottom = 280.0 +texture = ExtResource( 3 ) +patch_margin_left = 4 +patch_margin_top = 12 +patch_margin_right = 4 +patch_margin_bottom = 4 +axis_stretch_horizontal = 2 +axis_stretch_vertical = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="Menu"] +editor/display_folded = true +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = -51.0 +margin_bottom = -19.0 +alignment = 1 + +[node name="Help" type="Button" parent="Menu/HBoxContainer"] +margin_left = 44.0 +margin_right = 140.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 96, 0 ) +custom_styles/hover = ExtResource( 4 ) +custom_styles/pressed = SubResource( 1 ) +custom_styles/normal = ExtResource( 4 ) +custom_fonts/font = SubResource( 2 ) +custom_colors/font_color_disabled = Color( 0, 0, 0, 1 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) +custom_colors/font_color_pressed = Color( 1, 1, 1, 1 ) +text = "Help" + +[node name="Play" type="Button" parent="Menu/HBoxContainer"] +margin_left = 144.0 +margin_right = 240.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 96, 0 ) +custom_styles/hover = ExtResource( 4 ) +custom_styles/pressed = SubResource( 1 ) +custom_styles/normal = ExtResource( 4 ) +custom_fonts/font = SubResource( 2 ) +custom_colors/font_color_disabled = Color( 0, 0, 0, 1 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) +custom_colors/font_color_pressed = Color( 1, 1, 1, 1 ) +text = "Play" + +[node name="Quit" type="Button" parent="Menu/HBoxContainer"] +margin_left = 244.0 +margin_right = 340.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 96, 0 ) +custom_styles/hover = ExtResource( 4 ) +custom_styles/pressed = SubResource( 1 ) +custom_styles/normal = ExtResource( 4 ) +custom_fonts/font = SubResource( 2 ) +custom_colors/font_color_disabled = Color( 0, 0, 0, 1 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) +custom_colors/font_color_pressed = Color( 1, 1, 1, 1 ) +text = "Quit" + +[node name="Title" type="Label" parent="Menu"] +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +margin_top = -79.0 +margin_bottom = 31.0 +custom_fonts/font = SubResource( 5 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +text = "P.NG" +align = 1 +valign = 1 + +[node name="About" type="NinePatchRect" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = 64.0 +margin_top = 64.0 +margin_right = 448.0 +margin_bottom = 280.0 +texture = ExtResource( 3 ) +patch_margin_left = 4 +patch_margin_top = 12 +patch_margin_right = 4 +patch_margin_bottom = 4 +axis_stretch_horizontal = 2 +axis_stretch_vertical = 2 + +[node name="Back" type="Button" parent="About"] +margin_left = 144.0 +margin_top = 165.0 +margin_right = 240.0 +margin_bottom = 197.0 +rect_min_size = Vector2( 96, 0 ) +custom_styles/hover = ExtResource( 4 ) +custom_styles/pressed = SubResource( 1 ) +custom_styles/normal = ExtResource( 4 ) +custom_fonts/font = SubResource( 2 ) +custom_colors/font_color_disabled = Color( 0, 0, 0, 1 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) +custom_colors/font_color_pressed = Color( 1, 1, 1, 1 ) +text = "Back" + +[node name="Title" type="Label" parent="About"] +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +margin_top = -97.0 +margin_bottom = -57.0 +custom_fonts/font = SubResource( 3 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +text = "About P.NG" +align = 1 +valign = 1 +clip_text = true + +[node name="Copy" type="Label" parent="About"] +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +margin_top = -54.0 +margin_bottom = 48.0 +custom_fonts/font = SubResource( 4 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +text = "First to 3 points wins! +W/S - Player 1 Up/Down +Up/Down Arrows - Player 2 Up/Down +Created in Godot by CLD." +align = 1 +valign = 1 +clip_text = true +[connection signal="pressed" from="Menu/HBoxContainer/Help" to="." method="_on_Help_pressed"] +[connection signal="pressed" from="Menu/HBoxContainer/Play" to="." method="_on_Play_pressed"] +[connection signal="pressed" from="Menu/HBoxContainer/Quit" to="." method="_on_Quit_pressed"] +[connection signal="pressed" from="About/Back" to="." method="_on_Back_pressed"] diff --git a/Styles/Button-Default.tres b/Styles/Button-Default.tres @@ -0,0 +1,11 @@ +[gd_resource type="StyleBoxTexture" load_steps=2 format=2] + +[ext_resource path="res://Sprites/System6-Slice1.png" type="Texture" id=1] + +[resource] +texture = ExtResource( 1 ) +region_rect = Rect2( 0, 0, 16, 16 ) +margin_left = 6.0 +margin_right = 6.0 +margin_top = 6.0 +margin_bottom = 6.0 diff --git a/project.godot b/project.godot @@ -15,8 +15,8 @@ _global_script_class_icons={ [application] -config/name="pongodot" -run/main_scene="res://Game.tscn" +config/name="P.NG" +run/main_scene="res://MainMenu.tscn" config/icon="res://icon.png" [display]