diff --git a/assets/fonts/Cherry_Bomb_One/CherryBombOne-Regular.ttf b/assets/fonts/Cherry_Bomb_One/CherryBombOne-Regular.ttf new file mode 100644 index 0000000..c78f8e0 Binary files /dev/null and b/assets/fonts/Cherry_Bomb_One/CherryBombOne-Regular.ttf differ diff --git a/assets/fonts/Cherry_Bomb_One/CherryBombOne-Regular.ttf.import b/assets/fonts/Cherry_Bomb_One/CherryBombOne-Regular.ttf.import new file mode 100644 index 0000000..807b7bf --- /dev/null +++ b/assets/fonts/Cherry_Bomb_One/CherryBombOne-Regular.ttf.import @@ -0,0 +1,34 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://b5rg388cars1d" +path="res://.godot/imported/CherryBombOne-Regular.ttf-69a1c8c0f152dad07f82e5dadd3492db.fontdata" + +[deps] + +source_file="res://assets/fonts/Cherry_Bomb_One/CherryBombOne-Regular.ttf" +dest_files=["res://.godot/imported/CherryBombOne-Regular.ttf-69a1c8c0f152dad07f82e5dadd3492db.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/assets/fonts/Cherry_Bomb_One/OFL.txt b/assets/fonts/Cherry_Bomb_One/OFL.txt new file mode 100644 index 0000000..955e2b0 --- /dev/null +++ b/assets/fonts/Cherry_Bomb_One/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2019 The Cherry Bomb Project Authors (https://github.com/satsuyako/CherryBomb) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/project.godot b/project.godot index 82bac04..352301b 100644 --- a/project.godot +++ b/project.godot @@ -11,9 +11,9 @@ config_version=5 [application] config/name="Rps-Demo" -config/features=PackedStringArray("4.2", "Forward Plus") +run/main_scene="res://src/title_screen/title_screen.tscn" +config/features=PackedStringArray("4.3", "Forward Plus") run/max_fps=60 -config/icon="res://icon.svg" [debug] @@ -38,3 +38,8 @@ movie_writer/movie_file="demos/demo.avi" [editor_plugins] enabled=PackedStringArray("res://addons/format_on_save/plugin.cfg", "res://addons/gdlint_plugin/plugin.cfg") + +[gui] + +theme/custom="res://ui.theme" +theme/custom_font="res://assets/fonts/Cherry_Bomb_One/CherryBombOne-Regular.ttf" diff --git a/src/game/game.gd b/src/game/game.gd new file mode 100644 index 0000000..dde2bd7 --- /dev/null +++ b/src/game/game.gd @@ -0,0 +1 @@ +class_name Game extends Control diff --git a/src/game/game.tscn b/src/game/game.tscn new file mode 100644 index 0000000..f92c2fc --- /dev/null +++ b/src/game/game.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=4 format=3 uid="uid://d0d6xpa4ma7wd"] + +[ext_resource type="Shader" path="res://src/shaders/balatro_bg.gdshader" id="1_defdw"] +[ext_resource type="Script" path="res://src/game/game.gd" id="1_kepju"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_h23fw"] +shader = ExtResource("1_defdw") +shader_parameter/polar_coordinates = false +shader_parameter/polar_center = Vector2(0.5, 0.5) +shader_parameter/polar_zoom = 1.0 +shader_parameter/polar_repeat = 1.0 +shader_parameter/spin_rotation = -90.0 +shader_parameter/spin_speed = 2.0 +shader_parameter/offset = Vector2(0, 0) +shader_parameter/colour_1 = Color(1, 1, 0.9, 1) +shader_parameter/colour_2 = Color(1, 0.5, 0.991667, 1) +shader_parameter/colour_3 = Color(0.67, 1, 0.56, 1) +shader_parameter/contrast = 2.0 +shader_parameter/spin_amount = 0.36 +shader_parameter/pixel_filter = 300.0 + +[node name="Game" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_kepju") + +[node name="ColorRect" type="ColorRect" parent="."] +material = SubResource("ShaderMaterial_h23fw") +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/src/shaders/balatro_bg.gdshader b/src/shaders/balatro_bg.gdshader new file mode 100644 index 0000000..f4ea2fd --- /dev/null +++ b/src/shaders/balatro_bg.gdshader @@ -0,0 +1,71 @@ +shader_type canvas_item; +//I DONT OWN THIS i just took it directly from balatros source code teehee +//and then converted it into godots shader language myself +//shoutouts localthunk, buy balatro + +uniform bool polar_coordinates = false; //cool polar coordinates effect +uniform vec2 polar_center = vec2(0.5); +uniform float polar_zoom = 1.; +uniform float polar_repeat = 1.; + +uniform highp float spin_rotation; +uniform highp float spin_speed = 1; +uniform highp vec2 offset = vec2(0., 0.); +uniform highp vec4 colour_1 : source_color; +uniform highp vec4 colour_2 : source_color; +uniform highp vec4 colour_3 : source_color; +uniform highp float contrast = 2.; +uniform highp float spin_amount = 0.36; +uniform highp float pixel_filter = 700.; +#define SPIN_EASE 1.0 + + +vec4 effect(vec2 screenSize, vec2 screen_coords){ + //Convert to UV coords (0-1) and floor for pixel effect + highp float pixel_size = length(screenSize.xy) / pixel_filter; + highp vec2 uv = (floor(screen_coords.xy*(1./pixel_size))*pixel_size - 0.5*screenSize.xy)/length(screenSize.xy) - offset; + highp float uv_len = length(uv); + + //Adding in a center swirl, changes with time. Only applies meaningfully if the 'spin amount' is a non-zero number + highp float speed = (spin_rotation*SPIN_EASE*0.2) + 302.2; + highp float new_pixel_angle = (atan(uv.y, uv.x)) + speed - SPIN_EASE*20.*(1.*spin_amount*uv_len + (1. - 1.*spin_amount)); + highp vec2 mid = (screenSize.xy/length(screenSize.xy))/2.; + uv = (vec2((uv_len * cos(new_pixel_angle) + mid.x), (uv_len * sin(new_pixel_angle) + mid.y)) - mid); + + //Now add the paint effect to the swirled UV + uv *= 30.; + speed = TIME*(spin_speed); + highp vec2 uv2 = vec2(uv.x+uv.y); + + for(int i=0; i < 5; i++) { + uv2 += sin(max(uv.x, uv.y)) + uv; + uv += 0.5*vec2(cos(5.1123314 + 0.353*uv2.y + speed*0.131121),sin(uv2.x - 0.113*speed)); + uv -= 1.0*cos(uv.x + uv.y) - 1.0*sin(uv.x*0.711 - uv.y); + } + + //Make the paint amount range from 0 - 2 + highp float contrast_mod = (0.25*contrast + 0.5*spin_amount + 1.2); + highp float paint_res = min(2., max(0.,length(uv)*(0.035)*contrast_mod)); + highp float c1p = max(0.,1. - contrast_mod*abs(1.-paint_res)); + highp float c2p = max(0.,1. - contrast_mod*abs(paint_res)); + highp float c3p = 1. - min(1., c1p + c2p); + + + highp vec4 ret_col = (0.3/contrast)*colour_1 + (1. - 0.3/contrast)*(colour_1*c1p + colour_2*c2p + vec4(c3p*colour_3.rgb, c3p*colour_1.a)); + return ret_col; +} + +vec2 polar_coords(vec2 uv, vec2 center, float zoom, float repeat){ + vec2 dir = uv - center; + float radius = length(dir) * 2.0; + float angle = atan(dir.y , dir.x) * 1.0 / (PI * 2.0); + return mod(vec2(radius * zoom, angle * repeat), 1.0); +} + +void fragment() { + vec2 polarCoords = UV; + if (polar_coordinates){ + polarCoords = polar_coords(UV.xy, polar_center, polar_zoom, polar_repeat); + } + COLOR *= effect(TEXTURE_PIXEL_SIZE, polarCoords); +} diff --git a/src/title_screen/title_screen.gd b/src/title_screen/title_screen.gd new file mode 100644 index 0000000..e9194b6 --- /dev/null +++ b/src/title_screen/title_screen.gd @@ -0,0 +1,53 @@ +extends Control + +const MAX_CLIENTS = 2 + +@export var game_scene: PackedScene + +@onready var main_menu: VBoxContainer = %MainMenu +@onready var host_menu: VBoxContainer = %HostMenu +@onready var join_menu: VBoxContainer = %JoinMenu + +@onready var host_port_input: SpinBox = %HostPortInput +@onready var hostname_input: LineEdit = %HostnameInput +@onready var join_port_input: SpinBox = %JoinPortInput + + +func quit() -> void: + get_tree().quit() + + +func show_host_menu() -> void: + main_menu.hide() + join_menu.hide() + host_menu.show() + + +func show_join_menu() -> void: + main_menu.hide() + host_menu.hide() + join_menu.show() + + +func show_main_menu() -> void: + host_menu.hide() + join_menu.hide() + main_menu.show() + + +func start_host_lobby() -> void: + var game: Game = game_scene.instantiate() + var peer := ENetMultiplayerPeer.new() + peer.create_server(host_port_input.value, MAX_CLIENTS) + add_sibling(game) + game.multiplayer.multiplayer_peer = peer + queue_free() + + +func join_lobby() -> void: + var game: Game = game_scene.instantiate() + var peer := ENetMultiplayerPeer.new() + peer.create_client(hostname_input.text, join_port_input.value) + add_sibling(game) + game.multiplayer.multiplayer_peer = peer + queue_free() diff --git a/src/title_screen/title_screen.tscn b/src/title_screen/title_screen.tscn new file mode 100644 index 0000000..378e3e2 --- /dev/null +++ b/src/title_screen/title_screen.tscn @@ -0,0 +1,196 @@ +[gd_scene load_steps=5 format=3 uid="uid://n7a1ch8ck0p4"] + +[ext_resource type="Script" path="res://src/title_screen/title_screen.gd" id="1_yksqe"] +[ext_resource type="PackedScene" uid="uid://d0d6xpa4ma7wd" path="res://src/game/game.tscn" id="2_2uwxn"] +[ext_resource type="Shader" path="res://src/shaders/balatro_bg.gdshader" id="2_hejxs"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_7xgym"] +shader = ExtResource("2_hejxs") +shader_parameter/polar_coordinates = false +shader_parameter/polar_center = Vector2(0.5, 0.5) +shader_parameter/polar_zoom = 1.0 +shader_parameter/polar_repeat = 1.0 +shader_parameter/spin_rotation = 0.0 +shader_parameter/spin_speed = 2.0 +shader_parameter/offset = Vector2(0, 0) +shader_parameter/colour_1 = Color(1, 1, 0.9, 1) +shader_parameter/colour_2 = Color(1, 1, 0.5, 1) +shader_parameter/colour_3 = Color(0.56, 0.809333, 1, 1) +shader_parameter/contrast = 2.0 +shader_parameter/spin_amount = 0.36 +shader_parameter/pixel_filter = 300.0 + +[node name="TitleScreen" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_yksqe") +game_scene = ExtResource("2_2uwxn") + +[node name="ColorRect" type="ColorRect" parent="."] +material = SubResource("ShaderMaterial_7xgym") +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Title" type="Label" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_top = 0.3 +anchor_right = 0.5 +anchor_bottom = 0.3 +offset_left = -437.0 +offset_top = -47.0 +offset_right = 437.0 +offset_bottom = 47.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 64 +text = "Network Rock-Paper-Scissors" + +[node name="Menu" type="Control" parent="."] +layout_mode = 1 +anchor_left = 0.5 +anchor_top = 0.6 +anchor_right = 0.5 +anchor_bottom = 0.6 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MainMenu" type="VBoxContainer" parent="Menu"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -75.0 +offset_top = -88.0 +offset_right = 75.0 +offset_bottom = 88.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 4 + +[node name="Host" type="Button" parent="Menu/MainMenu"] +layout_mode = 2 +text = "Host Lobby" + +[node name="Join" type="Button" parent="Menu/MainMenu"] +layout_mode = 2 +text = "Join Lobby" + +[node name="Quit" type="Button" parent="Menu/MainMenu"] +layout_mode = 2 +text = "Quit" + +[node name="HostMenu" type="VBoxContainer" parent="Menu"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -77.5 +offset_top = -58.0 +offset_right = 77.5 +offset_bottom = 58.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 4 + +[node name="HBoxContainer" type="HBoxContainer" parent="Menu/HostMenu"] +layout_mode = 2 + +[node name="Label" type="Label" parent="Menu/HostMenu/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "Port:" + +[node name="HostPortInput" type="SpinBox" parent="Menu/HostMenu/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +min_value = 1024.0 +max_value = 65535.0 +value = 8383.0 +alignment = 2 + +[node name="Start" type="Button" parent="Menu/HostMenu"] +layout_mode = 2 +text = "Start Lobby" + +[node name="Cancel" type="Button" parent="Menu/HostMenu"] +layout_mode = 2 +text = "Cancel +" + +[node name="JoinMenu" type="VBoxContainer" parent="Menu"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -62.0 +offset_top = -58.0 +offset_right = 62.0 +offset_bottom = 58.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 4 + +[node name="HostnameInput" type="LineEdit" parent="Menu/JoinMenu"] +unique_name_in_owner = true +layout_mode = 2 +text = "localhost" +placeholder_text = "hostname" +alignment = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="Menu/JoinMenu"] +layout_mode = 2 + +[node name="Label" type="Label" parent="Menu/JoinMenu/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "Port:" + +[node name="JoinPortInput" type="SpinBox" parent="Menu/JoinMenu/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +min_value = 1024.0 +max_value = 65535.0 +value = 8383.0 +alignment = 2 + +[node name="Connect" type="Button" parent="Menu/JoinMenu"] +layout_mode = 2 +text = "Connect +" + +[node name="Cancel" type="Button" parent="Menu/JoinMenu"] +layout_mode = 2 +text = "Cancel +" + +[connection signal="pressed" from="Menu/MainMenu/Host" to="." method="show_host_menu"] +[connection signal="pressed" from="Menu/MainMenu/Join" to="." method="show_join_menu"] +[connection signal="pressed" from="Menu/MainMenu/Quit" to="." method="quit"] +[connection signal="pressed" from="Menu/HostMenu/Start" to="." method="start_host_lobby"] +[connection signal="pressed" from="Menu/HostMenu/Cancel" to="." method="show_main_menu"] +[connection signal="pressed" from="Menu/JoinMenu/Connect" to="." method="join_lobby"] +[connection signal="pressed" from="Menu/JoinMenu/Cancel" to="." method="show_main_menu"] diff --git a/ui.theme b/ui.theme new file mode 100644 index 0000000..e94403a Binary files /dev/null and b/ui.theme differ