From a67377318385cb5e9fe9a302d269eeec3402436b Mon Sep 17 00:00:00 2001 From: rain caliber <66094781+s-downpour@users.noreply.github.com> Date: Mon, 3 Feb 2025 00:08:50 -0600 Subject: [PATCH] first commit --- .editorconfig | 4 ++++ .gitattributes | 2 ++ .gitignore | 3 +++ assets/ball.png | Bin 0 -> 205 bytes assets/ball.png.import | 34 +++++++++++++++++++++++++++ assets/bumper.png | Bin 0 -> 402 bytes assets/bumper.png.import | 34 +++++++++++++++++++++++++++ assets/flipper.png | Bin 0 -> 204 bytes assets/flipper.png.import | 34 +++++++++++++++++++++++++++ icon.svg | 1 + icon.svg.import | 37 ++++++++++++++++++++++++++++++ main.tscn | 18 +++++++++++++++ pinball/ball.gd | 9 ++++++++ pinball/ball.gd.uid | 1 + pinball/ball.tscn | 19 +++++++++++++++ pinball/bumper.tscn | 8 +++++++ pinball/flipper.gd | 35 ++++++++++++++++++++++++++++ pinball/flipper.gd.uid | 1 + pinball/flipper.tscn | 15 ++++++++++++ pinball/table.tscn | 3 +++ project.godot | 47 ++++++++++++++++++++++++++++++++++++++ 21 files changed, 305 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 assets/ball.png create mode 100644 assets/ball.png.import create mode 100644 assets/bumper.png create mode 100644 assets/bumper.png.import create mode 100644 assets/flipper.png create mode 100644 assets/flipper.png.import create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 main.tscn create mode 100644 pinball/ball.gd create mode 100644 pinball/ball.gd.uid create mode 100644 pinball/ball.tscn create mode 100644 pinball/bumper.tscn create mode 100644 pinball/flipper.gd create mode 100644 pinball/flipper.gd.uid create mode 100644 pinball/flipper.tscn create mode 100644 pinball/table.tscn create mode 100644 project.godot diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/assets/ball.png b/assets/ball.png new file mode 100644 index 0000000000000000000000000000000000000000..1791beb800d523e456869ce10d7bb64724c1abd7 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4mJh`h9ms@x)~T47>k44ofy`glX=O&z|ijL z;us<^wYC2s=V1c@mgi0PnD+Y|sJ+2ECu&0WR;hqr0xbKPvJyTAD74uWt#6I|R_4pp zFoi{-L1N>*hZa2y8{RYP-8R_XQ8V#PiNnX7^nm zpF8zLtX58)yZpZRUjBzKq9z5MDH8MepxL$iiCx=s9hC~^HYNKYpRS$O3=9kmp00i_ I>zopr0C+l0VgLXD literal 0 HcmV?d00001 diff --git a/assets/ball.png.import b/assets/ball.png.import new file mode 100644 index 0000000..1797cc9 --- /dev/null +++ b/assets/ball.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://mucscwsbmfoq" +path="res://.godot/imported/ball.png-ca93c4f2e7b7f8325cbd933673092ff4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ball.png" +dest_files=["res://.godot/imported/ball.png-ca93c4f2e7b7f8325cbd933673092ff4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/bumper.png b/assets/bumper.png new file mode 100644 index 0000000000000000000000000000000000000000..186089cb1ea1372934495f1a0b6a95ea84824a8b GIT binary patch literal 402 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}jKx9jP7LeL$-HD>VD#~H zaSVxQeLLN@sM$cEHC%3&fmXq6r+uvA9sFlGceI8sIohgrWyu7yj&?D_=1$EYv%VVr zs^-^OE5ggXG~->?B=|f4Gyy>fi^PQt#$6_JRj7 z2X;0TGqSeY?##RVd_U($$JYnS%v@}^>+C$H+Fm^Ra^r(P{-^GpkM>AsNOm?+TvvK1 zE&9jj=Wp*j#PA#J4s-eQZl*o^t}LC?-a4 z&w2!%>-gUkZmFo5p2lausXpWAZ9}azv-^G5-_6)_cuwJieViaCp+r z>UaB%@34GWbu2{k!v)6mQ~$d%f15Ckr6j5&(rxSCcvJ4@`X{Qtxd(AEl>U@+;m;qlP-g%s+Xo5TP(xnre6&`M_8_XI`;SKB>8h;`k|~J=T \ No newline at end of file diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..0193e3c --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c8mo17gcly66y" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/main.tscn b/main.tscn new file mode 100644 index 0000000..2295a6e --- /dev/null +++ b/main.tscn @@ -0,0 +1,18 @@ +[gd_scene format=3 uid="uid://bgc35bo4ej4l1"] + +[node name="main" type="Node2D"] + +[node name="SubViewport" type="SubViewport" parent="."] +size = Vector2i(1080, 1920) + +[node name="SafeArea" type="Control" parent="SubViewport"] +layout_mode = 3 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_right = 900.0 +offset_bottom = 1600.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/pinball/ball.gd b/pinball/ball.gd new file mode 100644 index 0000000..21e6bbe --- /dev/null +++ b/pinball/ball.gd @@ -0,0 +1,9 @@ +extends RigidBody2D + +func _ready() -> void: + mass = 1.0 + gravity_scale = 1.0 + physics_material_override.bounce = 0.8 + linear_damp = 0.1 + contact_monitor = true + max_contacts_reported = 4 \ No newline at end of file diff --git a/pinball/ball.gd.uid b/pinball/ball.gd.uid new file mode 100644 index 0000000..e1d5c6d --- /dev/null +++ b/pinball/ball.gd.uid @@ -0,0 +1 @@ +uid://by01oc4lqlma4 diff --git a/pinball/ball.tscn b/pinball/ball.tscn new file mode 100644 index 0000000..5b92d1f --- /dev/null +++ b/pinball/ball.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=5 format=3 uid="uid://bri6gyx0bp87t"] + +[ext_resource type="Texture2D" uid="uid://mucscwsbmfoq" path="res://assets/ball.png" id="1_qbdsi"] +[ext_resource type="Script" uid="uid://by01oc4lqlma4" path="res://pinball/ball.gd" id="1_qu1p4"] + +[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_s64ax"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_o681m"] +radius = 4.0 + +[node name="Ball" type="RigidBody2D"] +physics_material_override = SubResource("PhysicsMaterial_s64ax") +script = ExtResource("1_qu1p4") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_o681m") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_qbdsi") diff --git a/pinball/bumper.tscn b/pinball/bumper.tscn new file mode 100644 index 0000000..ffe81e5 --- /dev/null +++ b/pinball/bumper.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://b4mlc72u3danp"] + +[ext_resource type="Texture2D" uid="uid://bjkqwg7x8boun" path="res://assets/bumper.png" id="1_gph4f"] + +[node name="Bumper" type="Node2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_gph4f") diff --git a/pinball/flipper.gd b/pinball/flipper.gd new file mode 100644 index 0000000..9d18c84 --- /dev/null +++ b/pinball/flipper.gd @@ -0,0 +1,35 @@ +extends RigidBody2D + +@export var flip_strength: float = 50.0 +@export var rest_strength: float = 20.0 +@export var right_flipper: bool = false + +var rest_angle: float = 0.0 +var flipped_angle: float = -60.0 #deg + +func _ready() -> void: + gravity_scale = 0.0 + freeze = false + + if right_flipper: + flipped_angle *= -1 + rest_angle *= -1 + + rotation_degrees = rest_angle + +func _input(event: InputEvent) -> void: + if right_flipper and event.is_action_pressed("right_flipper"): + flip() + elif !right_flipper and event.is_action_pressed("left_flipper"): + flip() + + if right_flipper and event.is_action_released("right_flipper"): + rest() + elif !right_flipper and event.is_action_released("left_flipper"): + rest() + +func flip() -> void: + angular_velocity = flip_strength + +func rest() -> void: + angular_velocity = -rest_strength \ No newline at end of file diff --git a/pinball/flipper.gd.uid b/pinball/flipper.gd.uid new file mode 100644 index 0000000..3e530ae --- /dev/null +++ b/pinball/flipper.gd.uid @@ -0,0 +1 @@ +uid://fnuonblf0vk2 diff --git a/pinball/flipper.tscn b/pinball/flipper.tscn new file mode 100644 index 0000000..a33eeef --- /dev/null +++ b/pinball/flipper.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://idjf5lor2py2"] + +[ext_resource type="Texture2D" uid="uid://b1r22t327pigo" path="res://assets/flipper.png" id="1_duuhy"] + +[sub_resource type="ConcavePolygonShape2D" id="ConcavePolygonShape2D_duuhy"] + +[node name="Flipper" type="RigidBody2D"] + +[node name="Flipper" type="Sprite2D" parent="."] +position = Vector2(-26, -3) +texture = ExtResource("1_duuhy") +offset = Vector2(26, 3) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("ConcavePolygonShape2D_duuhy") diff --git a/pinball/table.tscn b/pinball/table.tscn new file mode 100644 index 0000000..bd54f4e --- /dev/null +++ b/pinball/table.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://2bnojgnoj8df"] + +[node name="Table" type="Node2D"] diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..4e894bd --- /dev/null +++ b/project.godot @@ -0,0 +1,47 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="pinballatro" +config/features=PackedStringArray("4.4", "Forward Plus") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=270 +window/size/viewport_height=480 +window/size/window_width_override=540 +window/size/window_height_override=960 +window/stretch/mode="viewport" +window/stretch/aspect="keep_width" +window/stretch/scale_mode="integer" +window/handheld/orientation=1 + +[input] + +left_flipper={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +] +} +right_flipper={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":79,"key_label":0,"unicode":111,"location":0,"echo":false,"script":null) +] +} + +[rendering] + +textures/canvas_textures/default_texture_filter=0 +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" +textures/decals/filter=0 +textures/light_projectors/filter=0