diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b13897a Binary files /dev/null and b/.DS_Store differ diff --git a/assets/.DS_Store b/assets/.DS_Store new file mode 100644 index 0000000..9c31f2e Binary files /dev/null and b/assets/.DS_Store differ diff --git a/assets/sprites/RedChip.png b/assets/sprites/RedChip.png new file mode 100644 index 0000000..fcb24f4 Binary files /dev/null and b/assets/sprites/RedChip.png differ diff --git a/assets/sprites/RedChip.png.import b/assets/sprites/RedChip.png.import new file mode 100644 index 0000000..c1b219c --- /dev/null +++ b/assets/sprites/RedChip.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ckmfi0cjgxgyk" +path="res://.godot/imported/RedChip.png-87cfb9e74b846c07f18c0c7fe300f504.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/RedChip.png" +dest_files=["res://.godot/imported/RedChip.png-87cfb9e74b846c07f18c0c7fe300f504.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/sprites/YellowChip.png b/assets/sprites/YellowChip.png new file mode 100644 index 0000000..807e118 Binary files /dev/null and b/assets/sprites/YellowChip.png differ diff --git a/assets/sprites/YellowChip.png.import b/assets/sprites/YellowChip.png.import new file mode 100644 index 0000000..ceaac22 --- /dev/null +++ b/assets/sprites/YellowChip.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://qy30emdgrk7o" +path="res://.godot/imported/YellowChip.png-a8245744c0582bab34b9b96583a57ec0.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/YellowChip.png" +dest_files=["res://.godot/imported/YellowChip.png-a8245744c0582bab34b9b96583a57ec0.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/connect4-moderator-observer.csproj b/connect4-moderator-observer.csproj new file mode 100644 index 0000000..a405fc3 --- /dev/null +++ b/connect4-moderator-observer.csproj @@ -0,0 +1,8 @@ + + + net8.0 + net9.0 + true + connect4moderatorobserver + + \ No newline at end of file diff --git a/connect4-moderator-observer.sln b/connect4-moderator-observer.sln new file mode 100644 index 0000000..7623db8 --- /dev/null +++ b/connect4-moderator-observer.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "connect4-moderator-observer", "connect4-moderator-observer.csproj", "{686613AA-A1E3-40F7-8924-9B4FF0746A6F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {686613AA-A1E3-40F7-8924-9B4FF0746A6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {686613AA-A1E3-40F7-8924-9B4FF0746A6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {686613AA-A1E3-40F7-8924-9B4FF0746A6F}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {686613AA-A1E3-40F7-8924-9B4FF0746A6F}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {686613AA-A1E3-40F7-8924-9B4FF0746A6F}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {686613AA-A1E3-40F7-8924-9B4FF0746A6F}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/project.godot b/project.godot index e745b7c..2e4428e 100644 --- a/project.godot +++ b/project.godot @@ -11,5 +11,14 @@ config_version=5 [application] config/name="connect4-moderator-observer" -config/features=PackedStringArray("4.5", "Forward Plus") +run/main_scene="uid://cr8fi0e4r88s8" +config/features=PackedStringArray("4.5", "C#", "Forward Plus") config/icon="res://icon.svg" + +[dotnet] + +project/assembly_name="connect4-moderator-observer" + +[rendering] + +textures/canvas_textures/default_texture_filter=0 diff --git a/scenes/board_screen.tscn b/scenes/board_screen.tscn new file mode 100644 index 0000000..58470c6 --- /dev/null +++ b/scenes/board_screen.tscn @@ -0,0 +1,26 @@ +[gd_scene load_steps=4 format=3 uid="uid://m542qwlp7hl7"] + +[ext_resource type="Script" uid="uid://dg5jt0o0r0v3r" path="res://scripts/BoardScreen.cs" id="1_b3w8x"] +[ext_resource type="PackedScene" uid="uid://d1wr0v5ht8vqb" path="res://scenes/button_small.tscn" id="1_tbc1w"] + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_b3w8x"] + +[node name="BoardScreen" type="Node2D"] +script = ExtResource("1_b3w8x") + +[node name="StaticBody2D" type="StaticBody2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] +shape = SubResource("WorldBoundaryShape2D_b3w8x") + +[node name="SpwnRed" parent="." instance=ExtResource("1_tbc1w")] +offset_left = 512.0 +offset_top = -324.0 +offset_right = 576.0 +offset_bottom = -292.0 + +[node name="SpwnYlw" parent="." instance=ExtResource("1_tbc1w")] +offset_left = 512.0 +offset_top = -292.0 +offset_right = 576.0 +offset_bottom = -260.0 diff --git a/scenes/button_small.tscn b/scenes/button_small.tscn index ef6d90d..e8e1ebd 100644 --- a/scenes/button_small.tscn +++ b/scenes/button_small.tscn @@ -17,22 +17,24 @@ atlas = ExtResource("2_q2stu") region = Rect2(8, 0, 32, 16) [node name="ButtonSmall" type="TextureButton"] -offset_top = -16.0 +offset_left = -32.0 +offset_top = -32.0 offset_right = 32.0 texture_normal = SubResource("AtlasTexture_6ptbq") texture_pressed = SubResource("AtlasTexture_06p6p") texture_hover = SubResource("AtlasTexture_q2stu") +stretch_mode = 4 script = ExtResource("2_06p6p") [node name="Label" type="Label" parent="."] layout_mode = 0 -offset_left = 1.0 -offset_top = 5.0 -offset_right = 31.0 -offset_bottom = 13.0 +offset_left = 2.0 +offset_top = 9.0 +offset_right = 62.0 +offset_bottom = 25.0 theme_override_colors/font_color = Color(2.7723312e-05, 0.60865843, 0.9772685, 1) theme_override_fonts/font = ExtResource("3_dxjfy") -theme_override_font_sizes/font_size = 8 +theme_override_font_sizes/font_size = 16 text = "TEMP" horizontal_alignment = 1 diff --git a/scenes/create_join_room.tscn b/scenes/create_join_room.tscn index 26899e4..912287a 100644 --- a/scenes/create_join_room.tscn +++ b/scenes/create_join_room.tscn @@ -4,16 +4,15 @@ [ext_resource type="Script" uid="uid://b1ogflafdte71" path="res://scripts/create_join_room.gd" id="1_k6yuv"] [node name="CreateJoinRoom" type="Node2D"] +position = Vector2(0, 42) script = ExtResource("1_k6yuv") [node name="JoinGameButton" parent="." instance=ExtResource("1_4km6l")] -offset_left = -16.0 -offset_top = 12.0 -offset_right = 16.0 -offset_bottom = 28.0 +offset_top = 17.0 +offset_bottom = 49.0 +metadata/_edit_use_anchors_ = true [node name="CreateGameButton" parent="." instance=ExtResource("1_4km6l")] -offset_left = -16.0 -offset_top = 40.0 -offset_right = 16.0 -offset_bottom = 56.0 +offset_top = 85.0 +offset_bottom = 117.0 +metadata/_edit_use_anchors_ = true diff --git a/scenes/game.tscn b/scenes/game.tscn index db00a15..5e243ed 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,12 +1,15 @@ -[gd_scene load_steps=2 format=3 uid="uid://cr8fi0e4r88s8"] +[gd_scene load_steps=3 format=3 uid="uid://cr8fi0e4r88s8"] [ext_resource type="PackedScene" uid="uid://cct663hb47yka" path="res://scenes/create_join_room.tscn" id="1_uwrxv"] +[ext_resource type="PackedScene" uid="uid://m542qwlp7hl7" path="res://scenes/board_screen.tscn" id="2_yqjtg"] [node name="Game" type="Node2D"] [node name="GameManager" type="Node" parent="."] [node name="Camera2D" type="Camera2D" parent="."] -zoom = Vector2(5, 5) [node name="CreateJoinRoom" parent="." instance=ExtResource("1_uwrxv")] +visible = false + +[node name="BoardScreen" parent="." instance=ExtResource("2_yqjtg")] diff --git a/scenes/red_chip.tscn b/scenes/red_chip.tscn new file mode 100644 index 0000000..65ad0de --- /dev/null +++ b/scenes/red_chip.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=3 format=3 uid="uid://b4tujjdhmk4h"] + +[ext_resource type="Texture2D" uid="uid://ckmfi0cjgxgyk" path="res://assets/sprites/RedChip.png" id="1_qsflu"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_tfypd"] +radius = 12.0415945 + +[node name="RedChip" type="RigidBody2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_qsflu") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_tfypd") diff --git a/scenes/yellow_chip.tscn b/scenes/yellow_chip.tscn new file mode 100644 index 0000000..16554c0 --- /dev/null +++ b/scenes/yellow_chip.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=3 format=3 uid="uid://lruk652t0xe5"] + +[ext_resource type="Texture2D" uid="uid://qy30emdgrk7o" path="res://assets/sprites/YellowChip.png" id="1_eu0sq"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_epi6l"] +radius = 12.0 + +[node name="YellowChip" type="RigidBody2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_eu0sq") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_epi6l") diff --git a/scripts/BoardScreen.cs b/scripts/BoardScreen.cs new file mode 100644 index 0000000..7e9f46d --- /dev/null +++ b/scripts/BoardScreen.cs @@ -0,0 +1,91 @@ +using Godot; +using System; +using System.Collections; +using System.Collections.Generic; + +public partial class BoardScreen : Node2D { + private const string RED_CHIP_PATH = "res://scenes/red_chip.tscn"; + private const string YELLOW_CHIP_PATH = "res://scenes/yellow_chip.tscn"; + private const int CHIP_SIZE = 24; + private const int CHIP_PADDING = 2; + private const int INIT_OFFSET = -(CHIP_SIZE + CHIP_PADDING) * 7 / 2; + + private TextureButton spwnRed; + private TextureButton spwnYlw; + private PackedScene redChip; + private PackedScene ylwChip; + + private RigidBody2D[,] chips = new RigidBody2D[6, 7]; // 6 rows 7 cols | 0, 0 is top left + + // Called when the node enters the scene tree for the first time. + public override void _Ready() { + spwnRed = GetNode("SpwnRed"); + spwnYlw = GetNode("SpwnYlw"); + + spwnRed.GetNode