From 7f653386792ee4048ecb9ac69aaf3a8e7091b0d9 Mon Sep 17 00:00:00 2001 From: cojoedmo Date: Mon, 4 Aug 2025 02:42:51 -0400 Subject: [PATCH] 8-4-25 @ 2:42 am --- BallReturn.cs | 7 + BallReturn.cs.uid | 1 + Gameplay/Ball.cs | 44 +++--- Gameplay/BallSprite.cs | 9 +- Gameplay/Battle.cs | 5 +- Gameplay/ComputerManager.cs | 20 +-- Gameplay/Main.cs | 2 + Gameplay/Manager.cs | 27 ++-- Gameplay/ManagerPanel.cs | 8 +- Gameplay/PlayerManager.cs | 271 +++++++++++++++++++++--------------- Gameplay/manager_panel.tscn | 104 +++----------- Rack.cs | 10 ++ Rack.cs.uid | 1 + ball_return.tscn | 13 ++ rack.tscn | 85 +++++++++++ 15 files changed, 357 insertions(+), 250 deletions(-) create mode 100644 BallReturn.cs create mode 100644 BallReturn.cs.uid create mode 100644 Rack.cs create mode 100644 Rack.cs.uid create mode 100644 ball_return.tscn create mode 100644 rack.tscn diff --git a/BallReturn.cs b/BallReturn.cs new file mode 100644 index 0000000..d25cb9f --- /dev/null +++ b/BallReturn.cs @@ -0,0 +1,7 @@ +using Godot; +using System; + +public partial class BallReturn : Panel +{ + public int _returnCount = 0; +} diff --git a/BallReturn.cs.uid b/BallReturn.cs.uid new file mode 100644 index 0000000..83d12e6 --- /dev/null +++ b/BallReturn.cs.uid @@ -0,0 +1 @@ +uid://bbcrvn06t2aem diff --git a/Gameplay/Ball.cs b/Gameplay/Ball.cs index c0fbf8a..181e9e6 100644 --- a/Gameplay/Ball.cs +++ b/Gameplay/Ball.cs @@ -5,20 +5,19 @@ using System.Runtime; public partial class Ball : RigidBody2D { [Signal] - public delegate void OnHoverEventHandler(Ball HOVEREDBALL, bool TF); + public delegate void OnHoverEventHandler(Ball THIS, bool HOVERED); [Signal] - public delegate void OnCollisionEventHandler(Ball TARGET); + public delegate void OnCollisionEventHandler(Ball THIS, Ball TARGET); [Signal] - public delegate void OnLaunchEventHandler(); + public delegate void OnLaunchEventHandler(Ball THIS); [Signal] - public delegate void OnMovementEventHandler(); - [Signal] - public delegate void OnStopEventHandler(); + public delegate void OnMovementEventHandler(Ball THIS, bool MOVING); - public int _ownerId; public bool _active = false, _placed = false, _potted = false, _available = false, _hovered = false, _selected = false, _aimed = false, _launched = false, _moving = false, _isCue = false; - public Vector2I _rackPosition = new Vector2I(0, 0); public float _moveThreshold = 5.0f; + public string _imagePath = null; + public Vector2I _rackPosition = new Vector2I(0, 0); + public Manager _owner = null; public override void _Process(double DELTA_) { @@ -29,6 +28,7 @@ public partial class Ball : RigidBody2D { ProcessOnStop(); _moving = false; + EmitSignal(SignalName.OnMovement, this, false); if (_launched) { _launched = false; @@ -41,21 +41,7 @@ public partial class Ball : RigidBody2D if (!_moving) { _moving = true; - } - } - - if (Globals.Instance._anyMovement) - { - if (_available) - { - _available = false; - } - } - else - { - if (!_available) - { - _available = true; + EmitSignal(SignalName.OnMovement, this, true); } } } @@ -76,6 +62,7 @@ public partial class Ball : RigidBody2D public void SetSprite(string PATH) { + _imagePath = PATH; GetNode("Image").Texture = GD.Load(PATH); } @@ -93,7 +80,7 @@ public partial class Ball : RigidBody2D if (_active) { _hovered = true; - + EmitSignal(SignalName.OnHover, this, true); } } @@ -102,6 +89,7 @@ public partial class Ball : RigidBody2D if (_active) { _hovered = false; + EmitSignal(SignalName.OnHover, this, false); } } @@ -124,7 +112,7 @@ public partial class Ball : RigidBody2D public virtual void ProcessOnCollision(Ball TARGET) { - EmitSignal(SignalName.OnCollision, TARGET); + EmitSignal(SignalName.OnCollision, this, TARGET); } // public virtual void ProcessOnCreation() @@ -155,12 +143,12 @@ public partial class Ball : RigidBody2D public virtual void ProcessOnLaunch() { _launched = true; - EmitSignal(SignalName.OnLaunch); + EmitSignal(SignalName.OnLaunch, this); } public virtual void ProcessOnMovement() { - EmitSignal(SignalName.OnMovement); + } // public virtual void ProcessOnRemove() @@ -175,7 +163,7 @@ public partial class Ball : RigidBody2D public virtual void ProcessOnStop() { - EmitSignal(SignalName.OnStop); + } // public virtual void ProcessOnTurnEnd() diff --git a/Gameplay/BallSprite.cs b/Gameplay/BallSprite.cs index 270e3e7..ebaa5fc 100644 --- a/Gameplay/BallSprite.cs +++ b/Gameplay/BallSprite.cs @@ -3,10 +3,15 @@ using System; public partial class BallSprite : Area2D { + [Signal] + public delegate void OnHoverEventHandler(BallSprite THIS, bool HOVERED); + [Signal] + public delegate void OnUnhoverEventHandler(); public bool _active = false, _hovered = false, _held = false; - public int _ownerId; public string _imagePath; public Vector2 _rackPosition = new Vector2(0, 0); + public Manager _owner = null; + public void SetSprite(string PATH) { _imagePath = PATH; @@ -18,6 +23,7 @@ public partial class BallSprite : Area2D if (_active) { _hovered = true; + EmitSignal(SignalName.OnHover, this, true); } } @@ -26,6 +32,7 @@ public partial class BallSprite : Area2D if (_active) { _hovered = false; + EmitSignal(SignalName.OnHover, this, false); } } } diff --git a/Gameplay/Battle.cs b/Gameplay/Battle.cs index 685c4b3..b21ade9 100644 --- a/Gameplay/Battle.cs +++ b/Gameplay/Battle.cs @@ -93,17 +93,18 @@ public partial class Battle : Node if (c > 0) { Vector2 position = new Vector2(table.GlobalPosition.X - (r * (diameter / 2)) + ((c - 1) * diameter), table.GlobalPosition.Y - table.Texture.GetSize().Y / 4 - (r * diameter)); - if (PLAYER._id == rackBall._ownerId) + if (PLAYER == rackBall._owner) { PLAYER.PlaceBall(rackBall, position); } - if (COMPUTER._id == rackBall._ownerId) + if (COMPUTER == rackBall._owner) { COMPUTER.PlaceBall(rackBall, position); } } } // PLAYER.PotBall(); + PLAYER.SetRack(); } } diff --git a/Gameplay/ComputerManager.cs b/Gameplay/ComputerManager.cs index fcb2b79..befc6ab 100644 --- a/Gameplay/ComputerManager.cs +++ b/Gameplay/ComputerManager.cs @@ -5,7 +5,6 @@ using System.Linq; public partial class ComputerManager : Manager { - public int _id = 1; public List _initialRackPositions = [ new Vector2I(2, 3), @@ -19,28 +18,31 @@ public partial class ComputerManager : Manager ]; public override void _Ready() { + base._Ready(); Ball newBall; BallSprite newBallSprite; - for (int i = 8; i <= 15; i++) + for (int i = 0; i < 8; i++) { newBall = _ballScene.Instantiate(); - newBall.SetSprite("res://art/ball_" + i + ".png"); - newBall._rackPosition = _initialRackPositions[i - 8]; - newBall._ownerId = _id; + newBall.SetSprite("res://art/ball_" + (i+8) + ".png"); + newBall._rackPosition = _initialRackPositions[i]; + newBall._owner = this; _balls.Add(newBall); newBallSprite = _ballSpriteScene.Instantiate(); - newBallSprite.SetSprite("res://art/ball_" + i + ".png"); - newBallSprite._rackPosition = _initialRackPositions[i - 8]; - newBallSprite._ownerId = _id; + newBallSprite.SetSprite(newBall._imagePath); + newBallSprite._rackPosition = _initialRackPositions[i]; + newBallSprite._owner = this; _ballSprites.Add(newBallSprite); } } public override void Start() { - + } + + } diff --git a/Gameplay/Main.cs b/Gameplay/Main.cs index 9645520..21788d8 100644 --- a/Gameplay/Main.cs +++ b/Gameplay/Main.cs @@ -15,6 +15,8 @@ public partial class Main : Node _currentBattle = GetNode("Battle"); _player = GetNode("Player"); _computer = GetNode("Computer"); + _player._opponent = _computer; + _computer._opponent = _player; _currentBattle.Start(_player, _computer); _player.Start(); diff --git a/Gameplay/Manager.cs b/Gameplay/Manager.cs index 4f2ad96..082e3fe 100644 --- a/Gameplay/Manager.cs +++ b/Gameplay/Manager.cs @@ -7,14 +7,15 @@ using System.Linq; public partial class Manager : Node { public bool _dead, _ready; - public int _health = 10, _healthMax, _placeLimit = 8; + public int _ballsMoving = 0, _health = 10, _healthMax, _placeLimit = 8; public string _imagePath; + public Node _selectedNode = null; + public CollisionShape2D _startArea; public Cue _cue; - public List _workers = new(); + public Manager _opponent; public List _balls = new(); public List _ballSprites = new(); - public Ball _selectedBall = null; - public CollisionShape2D _startArea; + public List _workers = new(); // PACKED SCENES @@ -28,6 +29,7 @@ public partial class Manager : Node { _healthMax = _health; _cue = GetNode("Cue"); + _cue.Doff(); } public virtual void ChangeHealth(int CHANGE) @@ -84,13 +86,18 @@ public partial class Manager : Node private void OnCueShoot(Vector2 IMPULSE) { - if (_selectedBall != null && _selectedBall._placed) + if (_selectedNode is Ball) { - _selectedBall.GetNode("Ball").ApplyCentralImpulse(IMPULSE); - _selectedBall._selected = false; - _selectedBall.Launch(); - _selectedBall = null; - _cue.Doff(); + Ball selectedBall = (Ball)_selectedNode; + if (selectedBall != null && selectedBall._placed) + { + selectedBall.ApplyCentralImpulse(IMPULSE); + selectedBall._selected = false; + selectedBall.Launch(); + _selectedNode = null; + selectedBall = null; + _cue.Doff(); + } } } } diff --git a/Gameplay/ManagerPanel.cs b/Gameplay/ManagerPanel.cs index bfb2e12..f4026d3 100644 --- a/Gameplay/ManagerPanel.cs +++ b/Gameplay/ManagerPanel.cs @@ -4,8 +4,14 @@ using System; public partial class ManagerPanel : Panel { public bool _hovered = false; - public int _returnCount = 0; + public void SetManager(Manager MANAGER) + { + SetPosition(new Vector2(100, 150)); + SetSprite(MANAGER._imagePath); + SetValue(MANAGER._health); + SetMax(MANAGER._healthMax); + } public void SetPosition(Vector2 POSITION) { Position = POSITION; diff --git a/Gameplay/PlayerManager.cs b/Gameplay/PlayerManager.cs index 99f8879..5001e0b 100644 --- a/Gameplay/PlayerManager.cs +++ b/Gameplay/PlayerManager.cs @@ -1,11 +1,11 @@ using Godot; using System; using System.Collections.Generic; +using System.IO; using System.Linq; public partial class PlayerManager : Manager { - public int _id = 0; public List _initialRackPositions = [ new Vector2I(0, 1), @@ -17,112 +17,129 @@ public partial class PlayerManager : Manager new Vector2I(1, 3), new Vector2I(2, 4) ]; - public Ball _hoveredBall = null; - public BallSprite _hoveredBallSprite = null; - public BallSprite _heldBallSprite = null; - public Worker _hoveredWorker = null; + // denoted by c1r1 notation where (3,1) translates to row 1 column 3 + // column 0 represents the ball return where the row represents its order in the return, + // (0,0) denotes a ball that is not on the screen + // numbers should increase from top to bottom and left to right from the player's perspective + public Node _hoveredNode = null; public ManagerPanel _managerPanel = null; - public Panel _ballReturn = null; + public BallReturn _ballReturn = null; + public Rack _rack = null; public override void _Ready() { + base._Ready(); SetSprite("res://art/ness.png"); _managerPanel = GetNode("Panel"); - _managerPanel.SetPosition(new Vector2(100, 150)); - _managerPanel.SetSprite(_imagePath); - _managerPanel.SetValue(_health); - _managerPanel.SetMax(_healthMax); - _ballReturn = _managerPanel.GetNode("BallReturn"); - GD.Print(_ballReturn.GlobalPosition); + _ballReturn = _managerPanel.GetNode("BallReturn"); + _rack = _managerPanel.GetNode("Rack"); Ball newBall; newBall = _ballScene.Instantiate(); newBall.SetSprite("res://art/cue_ball.png"); newBall._rackPosition = _initialRackPositions[0]; - newBall._ownerId = _id; + newBall._owner = this; + newBall.OnHover += SetHovered; + newBall.OnMovement += MovingChange; _balls.Add(newBall); BallSprite newBallSprite; newBallSprite = _ballSpriteScene.Instantiate(); - newBallSprite.SetSprite("res://art/cue_ball.png"); + newBallSprite.SetSprite(newBall._imagePath); newBallSprite._rackPosition = _initialRackPositions[0]; - newBallSprite._ownerId = _id; + newBallSprite._owner = this; + newBallSprite.OnHover += SetHovered; _ballSprites.Add(newBallSprite); - + for (int i = 1; i <= 7; i++) { newBall = _ballScene.Instantiate(); newBall.SetSprite("res://art/ball_" + i + ".png"); newBall._rackPosition = _initialRackPositions[i]; - newBall._ownerId = _id; + newBall._owner = this; + newBall.OnHover += SetHovered; + newBall.OnMovement += MovingChange; _balls.Add(newBall); newBallSprite = _ballSpriteScene.Instantiate(); - newBallSprite.SetSprite("res://art/ball_" + i + ".png"); + newBallSprite.SetSprite(newBall._imagePath); newBallSprite._rackPosition = _initialRackPositions[i]; - newBallSprite._ownerId = _id; + _rack.SetSprite((int)newBallSprite._rackPosition.Y, (int)newBallSprite._rackPosition.X, newBallSprite._imagePath); + newBallSprite._owner = this; + newBallSprite.OnHover += SetHovered; _ballSprites.Add(newBallSprite); } + _managerPanel.SetManager(this); } public override void _Process(double DELTA_) { - if (_ready) + if (_ballsMoving == 0 && _opponent._ballsMoving == 0) { - if ((_selectedBall == null || _selectedBall != _hoveredBall) && (_hoveredBall?._available ?? false)) + if (_ready) { - if (Input.IsActionJustReleased("left_click")) + if (_hoveredNode is Ball || _selectedNode is Ball) { - _selectedBall = _hoveredBall; - _selectedBall._selected = true; - _cue.Don(_selectedBall.Position); - } - } - else if (Input.IsActionJustReleased("right_click")) - { - _selectedBall._selected = false; - _selectedBall = null; - _cue.Doff(); - } - else if (_hoveredBall == null) - { - if (Input.IsActionJustReleased("left_click") && _selectedBall != null && _cue._power == 0) - { - _selectedBall._selected = false; - _selectedBall = null; - _cue.Doff(); - } - } - } - else - { - if (_heldBallSprite != null) - { - Vector2 mousePosition = GetViewport().GetMousePosition(); - _heldBallSprite.Position = mousePosition; - if (Input.IsActionJustReleased("left_click")) - { - Ball ball = _balls.Single(b => b._rackPosition == _heldBallSprite._rackPosition); - PlaceBall(ball, mousePosition); - _heldBallSprite = null; - if (_balls.Where(b => b._placed).ToList().Count >= _placeLimit) + if ((Ball)_selectedNode == null || ((Ball)_selectedNode != _hoveredNode && _hoveredNode is Ball)) { - _ready = true; + if (Input.IsActionJustReleased("left_click")) + { + _selectedNode = (Ball)_hoveredNode; + ((Ball)_selectedNode)._selected = true; + _cue.Don(((Ball)_selectedNode).Position); + } + } + else if (Input.IsActionJustReleased("right_click")) + { + ((Ball)_selectedNode)._selected = false; + _selectedNode = null; + _cue.Doff(); + } + else if (_hoveredNode == null) + { + if (Input.IsActionJustReleased("left_click") && (Ball)_selectedNode != null && _cue._power == 0) + { + ((Ball)_selectedNode)._selected = false; + _selectedNode = null; + _cue.Doff(); + } } } } else { - if (Input.IsActionJustReleased("left_click")) + if (_hoveredNode is BallSprite || _selectedNode is BallSprite) { - _heldBallSprite = _hoveredBallSprite; + + if (_selectedNode != null) + { + Vector2 mousePosition = GetViewport().GetMousePosition(); + ((BallSprite)_selectedNode).Position = mousePosition; + if (Input.IsActionJustReleased("left_click")) + { + Ball ball = _balls.Single(b => b._rackPosition == ((BallSprite)_hoveredNode)._rackPosition); + PlaceBall(ball, mousePosition); + _hoveredNode = null; + _selectedNode = null; + if (_balls.Where(b => b._placed).ToList().Count >= _placeLimit) + { + _ready = true; + } + } + } + else + { + if (Input.IsActionJustReleased("left_click")) + { + _selectedNode = (BallSprite)_hoveredNode; + } + } } } } - } public override void ChangeHealth(int CHANGE) @@ -131,6 +148,90 @@ public partial class PlayerManager : Manager GetNode("Panel").SetValue(_health); } + public void MovingChange(Ball BALL, bool MOVING) + { + if (MOVING) + { + _ballsMoving++; + } + else + { + _ballsMoving--; + } + } + + public override void PlaceBall(Ball BALL, Vector2 POSITION) + { + base.PlaceBall(BALL, POSITION); + BallSprite ballSprite = _ballSprites.Single(s => s._rackPosition == BALL._rackPosition); + + ballSprite._active = false; + if (GetChildren().Contains(ballSprite)) + { + RemoveChild(ballSprite); + } + _ballReturn._returnCount = _balls.Where(b => b._potted).ToList().Count; + } + + public override void PotBall(Ball BALL) + { + base.PotBall(BALL); + + BallSprite ballSprite = _ballSprites.Single(s => s._rackPosition == BALL._rackPosition); + int pottedCount = _ballReturn._returnCount; + ballSprite.Position = new Vector2(_ballReturn.GlobalPosition.X + _ballReturn.Size.X / 2, _ballReturn.GlobalPosition.Y + 50 * (pottedCount + 1)); + + + ballSprite._active = true; + if (!GetChildren().Contains(ballSprite)) + { + AddChild(ballSprite); + } + _ballReturn._returnCount = _balls.Where(b=>b._potted).ToList().Count; + } + + public void SetHovered(Node NODE, bool HOVERED) + { + if (HOVERED) + { + if (_hoveredNode == null) + { + if (NODE is Ball) + { + _hoveredNode = (Ball)NODE; + } + else if (NODE is BallSprite) + { + _hoveredNode = (BallSprite)NODE; + } + } + } + else + { + _hoveredNode = null; + } + } + + public void SetRack() + { + for (int i = 0; i < _ballSprites.Count; i++) + { + if ((int)_ballSprites[i]._rackPosition.Y > 0 && (int)_ballSprites[i]._rackPosition.X > 0) + { + _rack.SetSprite((int)_ballSprites[i]._rackPosition.Y, (int)_ballSprites[i]._rackPosition.X, _ballSprites[i]._imagePath); + } + } + for (int i = 0; i < _opponent._ballSprites.Count; i++) + { + if ((int)_opponent._ballSprites[i]._rackPosition.Y > 0 && (int)_opponent._ballSprites[i]._rackPosition.X > 0) + { + + _rack.SetSprite((int)_opponent._ballSprites[i]._rackPosition.Y, (int)_opponent._ballSprites[i]._rackPosition.X, _opponent._ballSprites[i]._imagePath); + } + } + + } + public override void Start() { @@ -142,56 +243,4 @@ public partial class PlayerManager : Manager // // _ballSprites[i].AddChild(_ballSprites[i]); // } } - - public void HoverBall(Ball BALL, bool HOVERED) - { - if (HOVERED) - { - if (_hoveredBall == null) - { - _hoveredBall = BALL; - } - } - else - { - if (_hoveredBall == BALL) - { - _hoveredBall = null; - } - } - - } - - public override void PlaceBall(Ball BALL, Vector2 POSITION) - { - - base.PlaceBall(BALL, POSITION); - BallSprite ballSprite = _ballSprites.Single(s => s._rackPosition == BALL._rackPosition); - - ballSprite._active = false; - if (GetChildren().Contains(ballSprite)) - { - RemoveChild(ballSprite); - } - _managerPanel._returnCount = _balls.Where(b=>b._potted).ToList().Count; - } - - public override void PotBall(Ball BALL) - { - base.PotBall(BALL); - - BallSprite ballSprite = _ballSprites.Single(s => s._rackPosition == BALL._rackPosition); - int pottedCount = _managerPanel._returnCount; - GD.Print(_ballReturn.GlobalPosition); - ballSprite.Position = new Vector2(_ballReturn.GlobalPosition.X + _ballReturn.Size.X / 2, _ballReturn.GlobalPosition.Y + 50 * (pottedCount + 1)); - - - ballSprite._active = true; - if (!GetChildren().Contains(ballSprite)) - { - AddChild(ballSprite); - GD.Print(ballSprite.Position); - } - _managerPanel._returnCount = _balls.Where(b=>b._potted).ToList().Count; - } } diff --git a/Gameplay/manager_panel.tscn b/Gameplay/manager_panel.tscn index 9240116..124af5d 100644 --- a/Gameplay/manager_panel.tscn +++ b/Gameplay/manager_panel.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=9 format=3 uid="uid://8kv00jc35dma"] [ext_resource type="Script" uid="uid://c4ekvurl6q7jn" path="res://Gameplay/ManagerPanel.cs" id="1_8n1hc"] -[ext_resource type="Texture2D" uid="uid://cgnwfc387vche" path="res://art/rack.png" id="2_sx67n"] -[ext_resource type="Texture2D" uid="uid://ck4ta2f0ofjs0" path="res://art/cue_ball.png" id="3_2t778"] +[ext_resource type="PackedScene" uid="uid://cudhpkje2ax2g" path="res://rack.tscn" id="2_20uuj"] +[ext_resource type="PackedScene" uid="uid://bfxav1txgaxo5" path="res://ball_return.tscn" id="3_sx67n"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e1ofl"] bg_color = Color(1, 1, 1, 1) @@ -120,14 +120,6 @@ theme_override_styles/fill = SubResource("StyleBoxFlat_dg1wx") step = 1.0 show_percentage = false -[node name="BallReturn" type="Panel" parent="."] -layout_mode = 0 -offset_left = 475.0 -offset_right = 550.0 -offset_bottom = 800.0 -mouse_filter = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_j2own") - [node name="Team" type="Panel" parent="."] layout_mode = 0 offset_top = 150.0 @@ -148,6 +140,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_058dj") position = Vector2(25, 25) [node name="T2" type="Panel" parent="Team"] +layout_mode = 0 offset_left = 88.0 offset_top = 25.0 offset_right = 138.0 @@ -158,6 +151,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_058dj") position = Vector2(25, 25) [node name="T3" type="Panel" parent="Team"] +layout_mode = 0 offset_left = 163.0 offset_top = 25.0 offset_right = 213.0 @@ -168,6 +162,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_058dj") position = Vector2(25, 25) [node name="T4" type="Panel" parent="Team"] +layout_mode = 0 offset_left = 238.0 offset_top = 25.0 offset_right = 288.0 @@ -178,6 +173,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_058dj") position = Vector2(25, 25) [node name="T5" type="Panel" parent="Team"] +layout_mode = 0 offset_left = 13.0 offset_top = 100.0 offset_right = 63.0 @@ -188,6 +184,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_058dj") position = Vector2(25, 25) [node name="T6" type="Panel" parent="Team"] +layout_mode = 0 offset_left = 88.0 offset_top = 100.0 offset_right = 138.0 @@ -198,6 +195,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_058dj") position = Vector2(25, 25) [node name="T7" type="Panel" parent="Team"] +layout_mode = 0 offset_left = 163.0 offset_top = 100.0 offset_right = 213.0 @@ -208,6 +206,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_058dj") position = Vector2(25, 25) [node name="T8" type="Panel" parent="Team"] +layout_mode = 0 offset_left = 238.0 offset_top = 100.0 offset_right = 288.0 @@ -217,85 +216,14 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_058dj") [node name="Image" type="Sprite2D" parent="Team/T8"] position = Vector2(25, 25) -[node name="Rack" type="Sprite2D" parent="."] -position = Vector2(313, 175) -texture = ExtResource("2_sx67n") -centered = false +[node name="Rack" parent="." instance=ExtResource("2_20uuj")] +position = Vector2(14, 312) +scale = Vector2(3.384, 3.384) -[node name="B15" type="Sprite2D" parent="Rack"] -position = Vector2(62.5, 90) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B14" type="Sprite2D" parent="Rack"] -position = Vector2(73.125, 71) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B13" type="Sprite2D" parent="Rack"] -position = Vector2(51.875, 71) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B12" type="Sprite2D" parent="Rack"] -position = Vector2(83.75, 52) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B11" type="Sprite2D" parent="Rack"] -position = Vector2(62.5, 52) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B10" type="Sprite2D" parent="Rack"] -position = Vector2(41.25, 52) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B9" type="Sprite2D" parent="Rack"] -position = Vector2(94.875, 33) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B8" type="Sprite2D" parent="Rack"] -position = Vector2(73.125, 33) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B7" type="Sprite2D" parent="Rack"] -position = Vector2(51.875, 33) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B6" type="Sprite2D" parent="Rack"] -position = Vector2(30.125, 33) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B5" type="Sprite2D" parent="Rack"] -position = Vector2(105, 14) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B4" type="Sprite2D" parent="Rack"] -position = Vector2(83.75, 14) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B3" type="Sprite2D" parent="Rack"] -position = Vector2(62.5, 14) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B2" type="Sprite2D" parent="Rack"] -position = Vector2(41.25, 14) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") - -[node name="B1" type="Sprite2D" parent="Rack"] -position = Vector2(20, 14) -scale = Vector2(0.5, 0.5) -texture = ExtResource("3_2t778") +[node name="BallReturn" parent="." instance=ExtResource("3_sx67n")] +layout_mode = 0 +offset_left = 475.0 +offset_right = 550.0 [connection signal="mouse_entered" from="." to="." method="OnMouseEntered"] [connection signal="mouse_exited" from="." to="." method="OnMouseExited"] diff --git a/Rack.cs b/Rack.cs new file mode 100644 index 0000000..0d2c76a --- /dev/null +++ b/Rack.cs @@ -0,0 +1,10 @@ +using Godot; +using System; + +public partial class Rack : Sprite2D +{ + public void SetSprite(int ROW, int COLUMN, string IMAGEPATH) + { + GetNode("R" + ROW).GetNode("C" + COLUMN).SetSprite(IMAGEPATH); + } +} diff --git a/Rack.cs.uid b/Rack.cs.uid new file mode 100644 index 0000000..f2853ff --- /dev/null +++ b/Rack.cs.uid @@ -0,0 +1 @@ +uid://blwghh5lu3w3r diff --git a/ball_return.tscn b/ball_return.tscn new file mode 100644 index 0000000..5da9e57 --- /dev/null +++ b/ball_return.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=3 format=3 uid="uid://bfxav1txgaxo5"] + +[ext_resource type="Script" uid="uid://bbcrvn06t2aem" path="res://BallReturn.cs" id="1_omsmb"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3x8cv"] +bg_color = Color(0.501407, 0.501406, 0.501406, 1) + +[node name="BallReturn" type="Panel"] +offset_right = 75.0 +offset_bottom = 800.0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_3x8cv") +script = ExtResource("1_omsmb") diff --git a/rack.tscn b/rack.tscn new file mode 100644 index 0000000..8f6e523 --- /dev/null +++ b/rack.tscn @@ -0,0 +1,85 @@ +[gd_scene load_steps=4 format=3 uid="uid://cudhpkje2ax2g"] + +[ext_resource type="Texture2D" uid="uid://cgnwfc387vche" path="res://art/rack.png" id="1_re2um"] +[ext_resource type="Script" uid="uid://blwghh5lu3w3r" path="res://Rack.cs" id="2_tsiik"] +[ext_resource type="PackedScene" uid="uid://tmer0me1qpaa" path="res://Gameplay/ball_sprite.tscn" id="3_ydd72"] + +[node name="Rack" type="Sprite2D"] +texture = ExtResource("1_re2um") +centered = false +script = ExtResource("2_tsiik") + +[node name="R1" type="Node2D" parent="."] +position = Vector2(0, 4) + +[node name="C1" parent="R1" instance=ExtResource("3_ydd72")] +position = Vector2(18, 11) +scale = Vector2(0.6, 0.6) + +[node name="C2" parent="R1" instance=ExtResource("3_ydd72")] +position = Vector2(40.25, 11) +scale = Vector2(0.6, 0.6) + +[node name="C3" parent="R1" instance=ExtResource("3_ydd72")] +position = Vector2(62.5, 11) +scale = Vector2(0.6, 0.6) + +[node name="C4" parent="R1" instance=ExtResource("3_ydd72")] +position = Vector2(84.75, 11) +scale = Vector2(0.6, 0.6) + +[node name="C5" parent="R1" instance=ExtResource("3_ydd72")] +position = Vector2(107, 11) +scale = Vector2(0.6, 0.6) + +[node name="R2" type="Node2D" parent="."] +position = Vector2(0, 4) + +[node name="C1" parent="R2" instance=ExtResource("3_ydd72")] +position = Vector2(30, 30) +scale = Vector2(0.6, 0.6) + +[node name="C2" parent="R2" instance=ExtResource("3_ydd72")] +position = Vector2(51.5, 30) +scale = Vector2(0.6, 0.6) + +[node name="C3" parent="R2" instance=ExtResource("3_ydd72")] +position = Vector2(73.5, 30) +scale = Vector2(0.6, 0.6) + +[node name="C4" parent="R2" instance=ExtResource("3_ydd72")] +position = Vector2(96, 30) +scale = Vector2(0.6, 0.6) + +[node name="R3" type="Node2D" parent="."] +position = Vector2(0, 4) + +[node name="C1" parent="R3" instance=ExtResource("3_ydd72")] +position = Vector2(41, 49) +scale = Vector2(0.6, 0.6) + +[node name="C2" parent="R3" instance=ExtResource("3_ydd72")] +position = Vector2(63, 49) +scale = Vector2(0.6, 0.6) + +[node name="C3" parent="R3" instance=ExtResource("3_ydd72")] +position = Vector2(85, 49) +scale = Vector2(0.6, 0.6) + +[node name="R4" type="Node2D" parent="."] +position = Vector2(0, 4) + +[node name="C1" parent="R4" instance=ExtResource("3_ydd72")] +position = Vector2(52, 68) +scale = Vector2(0.6, 0.6) + +[node name="C2" parent="R4" instance=ExtResource("3_ydd72")] +position = Vector2(74, 68) +scale = Vector2(0.6, 0.6) + +[node name="R5" type="Node2D" parent="."] +position = Vector2(0, 4) + +[node name="C1" parent="R5" instance=ExtResource("3_ydd72")] +position = Vector2(63, 87) +scale = Vector2(0.6, 0.6)