7-17-25 @ 3:55am

This commit is contained in:
2025-07-17 03:55:30 -04:00
parent c5795028f0
commit 3884c07811
23 changed files with 371 additions and 103 deletions

View File

@@ -3,9 +3,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
public partial class Actor : Node
public partial class Actor : Sprite2D
{
public bool _available, _hovered, _selected;
public bool _available = false, _hovered = false, _selected = false;
public int _health, _healthMax;
public CollisionShape2D _startArea;
public List<Cue> _cues = new();
public Cue _selectedCue = null;
@@ -17,34 +18,40 @@ public partial class Actor : Node
public Sprite2D _tempBallSprite = new();
public static Actor Create(string SCENENAME)
public static Actor _Create()
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/" + SCENENAME + ".tscn");
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/actor.tscn");
Actor newActor = scene.Instantiate<Actor>();
return newActor;
}
newActor.Texture = GD.Load<Texture2D>("res://art/ness.png");
public override void _Ready()
{
Ball newBall = Ball.Create("ball", 0);
_balls.Add(newBall);
newBall = Ball.Create("ball", 1);
_balls.Add(newBall);
Ball newBall = Ball._Create(0);
newActor._balls.Add(newBall);
newBall = Ball._Create(0);
newActor._balls.Add(newBall);
Cue newCue = Cue.Create("cue");
AddChild(newCue);
_cues.Add(newCue);
for (int i = 0; i < _cues.Count; i++)
Cue newCue = Cue._Create();
newActor.AddChild(newCue);
newActor._cues.Add(newCue);
for (int i = 0; i < newActor._cues.Count; i++)
{
_cues[i].Shoot += OnCueShoot;
newActor._cues[i].Shoot += newActor.OnCueShoot;
}
_ballBag = new(_balls);
newActor._ballBag = new(newActor._balls);
newActor._health = 10;
newActor._healthMax = newActor._health;
ActorPanel newActorPanel = ActorPanel._Create(newActor);
newActor.AddChild(newActorPanel);
return newActor;
}
public override void _Process(double DELTA_)
{
if (_ballBag.Count > 0)
if (_ballBag.Count > 0 && _selected)
{
if (_heldBall == null)
{
@@ -71,7 +78,7 @@ public partial class Actor : Node
{
_startArea = Globals.Instance._currentBattle.GetNode<Table>("Table").GetNode<Area2D>("PlayerStartArea").GetNode<CollisionShape2D>("CollisionShape2D");
}
_tempBallSprite.Position = new Vector2(Math.Min(Math.Max(mousePosition.X, _startArea.GlobalPosition.X - ((RectangleShape2D)(_startArea.Shape)).Size.X / 2), _startArea.GlobalPosition.X + ((RectangleShape2D)(_startArea.Shape)).Size.X / 2), Math.Min(Math.Max(mousePosition.Y, _startArea.GlobalPosition.Y - ((RectangleShape2D)(_startArea.Shape)).Size.Y / 2), _startArea.GlobalPosition.Y + ((RectangleShape2D)(_startArea.Shape)).Size.Y / 2));
if (Input.IsActionJustReleased("left_click"))
{
@@ -133,7 +140,7 @@ public partial class Actor : Node
//public void ResetCueBall()
//{
//_cueBall = Ball.Create("ball", 0, _startPosition);
//_cueBall = Ball._Create("ball", 0, _startPosition);
//_cueBall.SetName("CueBall");
//AddChild(_cueBall);
//Texture2D image = GD.Load<Texture2D>("res://art/cue_ball.png");

36
Gameplay/ActorPanel.cs Normal file
View File

@@ -0,0 +1,36 @@
using Godot;
using System;
public partial class ActorPanel : Panel
{
public static ActorPanel _Create(Actor ACTOR)
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/actor_panel.tscn");
ActorPanel newActorPanel = scene.Instantiate<ActorPanel>();
newActorPanel.SetSprite(ACTOR.Texture);
newActorPanel.SetMax(ACTOR._healthMax);
newActorPanel.SetValue(ACTOR._health);
newActorPanel.SetPosition(new Vector2(1500, 0));
return newActorPanel;
}
public void SetPosition(Vector2 POSITION)
{
Position = POSITION;
}
public void SetSprite(Texture2D TEXTURE)
{
GetNode<Sprite2D>("Image").Texture = TEXTURE;
}
public void SetValue(int VALUE)
{
GetNode<Node2D>("Health").GetNode<RichTextLabel>("Value").Text = VALUE.ToString();
GetNode<Node2D>("Health").GetNode<ProgressBar>("Bar").Value = VALUE;
}
public void SetMax(int MAX)
{
GetNode<Node2D>("Health").GetNode<RichTextLabel>("Max").Text = MAX.ToString();
GetNode<Node2D>("Health").GetNode<ProgressBar>("Bar").MaxValue = MAX;
}
}

View File

@@ -0,0 +1 @@
uid://c4ekvurl6q7jn

View File

@@ -4,12 +4,13 @@ using System.Data;
public partial class Ball : RigidBody2D
{
public bool _placed, _potted, _available, _hovered, _selected, _aimed, _moving;
public bool _placed = false, _potted = false, _available = false, _hovered = false, _selected = false, _aimed = false, _moving = false;
public int _defense, _defenseMax;
public float _moveThreshold = 5.0f;
public static Ball Create(string SCENENAME, int NUMBER)
public static Ball _Create(int NUMBER)
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/"+SCENENAME+".tscn");
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/ball.tscn");
Ball newBall = scene.Instantiate<Ball>();
string fileName;
if (NUMBER == 0)
@@ -25,15 +26,6 @@ public partial class Ball : RigidBody2D
return newBall;
}
public override void _Ready()
{
_available = true;
_hovered = false;
_selected = false;
_aimed = false;
_moving = false;
}
public override void _Process(double DELTA_)
{
if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold)

View File

@@ -9,24 +9,41 @@ public partial class Battle : Node
public bool _current;
public Vector2 _startPosition = new Vector2(890, 340);
public Player _player;
public Player _computer;
public Player _turn;
public List<Sprite2D> _potted = new();
public List<Ball> _balls;
public override void _Ready()
public List<Ball> _balls = new();
public Table _table;
public static Battle _Create()
{
_player = GetNode<Player>("Player");
Start();
List<Area2D> pockets = GetNode<Table>("Table").GetChildren()
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/battle.tscn");
Battle newBattle = scene.Instantiate<Battle>();
Player newPlayer = Player._Create();
newBattle._player = newPlayer;
newBattle.AddChild(newPlayer);
Table newTable = Table._Create();
newTable.Position = Globals.Instance._screenCenter;
newBattle._table = newTable;
List<Area2D> pockets = newBattle._table.GetChildren()
.Where(n => n.GetName().ToString().ToLower().Contains("pocket"))
.Select(n => (Area2D)n)
.ToList<Area2D>();
for (int i = 0; i < pockets.Count; i++)
{
pockets[i].BodyEntered += PottedBall;
pockets[i].BodyEntered += newBattle.PottedBall;
}
newBattle.AddChild(newTable);
return newBattle;
}
public override void _Ready()
{
_balls = GetTree().GetNodesInGroup("balls").Select(b => (Ball)b).ToList<Ball>();
Start();
}
public override void _Process(double DELTA_)
@@ -37,21 +54,22 @@ public partial class Battle : Node
public void GenerateBalls()
{
int count = 1;
int rows = 5;
int columns = 0;
int diameter = 36;
Table table = GetNode<Table>("Table");
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < rows; j++)
for (int j = 0; j <= columns; j++)
{
Vector2 position = new Vector2(250 + (i*(diameter)), 267 + (j*(diameter)) + (i*(diameter / 2)));
Ball ball = Ball.Create("ball", count);
Vector2 position = new Vector2(table.GlobalPosition.X - (i * (diameter / 2)) + (j * (diameter)), table.GlobalPosition.Y - table.Texture.GetSize().Y / 4 - (i * diameter));
Ball ball = Ball._Create(count);
ball.Place(position);
AddChild(ball);
count += 1;
}
rows -= 1;
columns += 1;
}
}
@@ -83,10 +101,10 @@ public partial class Battle : Node
{
return;
}
if (BODY == _player._actor._selectedBall)
if (BODY == _player._selectedActor._selectedBall)
{
_player._actor._selectedBall._potted = true;
_player._actor._selectedBall._placed = false;
_player._selectedActor._selectedBall._potted = true;
_player._selectedActor._selectedBall._placed = false;
}
else
{

View File

@@ -11,9 +11,9 @@ public partial class Cue : Sprite2D
Vector2 _direction;
public ProgressBar _progressBar;
public static Cue Create(string SCENENAME)
public static Cue _Create()
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/"+SCENENAME+".tscn");
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/cue.tscn");
Cue newCue = scene.Instantiate<Cue>();
Texture2D image = GD.Load<Texture2D>("res://art/cue.png");
newCue.Texture = image;

View File

@@ -6,7 +6,10 @@ public partial class Globals : Node
public static Globals Instance;
public bool _anyMovement;
public Vector2 _screenSize;
public Vector2 _screenCenter;
public Battle _currentBattle;
public override void _Ready()
{

View File

@@ -5,7 +5,11 @@ public partial class Main : Node
{
public override void _Ready()
{
Globals.Instance._screenSize = GetViewport().GetVisibleRect().Size;
Globals.Instance._screenCenter = new Vector2(Globals.Instance._screenSize.X / 2, Globals.Instance._screenSize.Y / 2);
Battle newBattle = Battle._Create();
Globals.Instance._currentBattle = newBattle;
AddChild(newBattle);
}
public override void _Process(double DELTA_)

View File

@@ -1,23 +1,28 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class Player : Node
{
public bool _available, _selected;
public Actor _actor;
public Battle _currentBattle;
public override void _Ready()
{
_actor = Actor.Create("actor");
AddChild(_actor);
}
public override void _Process(double DELTA_)
{
}
public Actor _selectedActor;
public List<Actor> _actors = new();
public static Player _Create()
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/player.tscn");
Player newPlayer = scene.Instantiate<Player>();
Actor newActor = Actor._Create();
newPlayer._actors.Add(newActor);
newPlayer.AddChild(newActor);
return newPlayer;
}
public override void _Process(double DELTA_)
{
}
}

View File

@@ -3,10 +3,7 @@ using System;
public partial class PowerBar : ProgressBar
{
public override void _Ready()
{
}
public override void _Process(double DELTA_)
{

View File

@@ -4,5 +4,11 @@ using System;
public partial class Table : Sprite2D
{
public static Table _Create()
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/table.tscn");
Table newTable = scene.Instantiate<Table>();
return newTable;
}
}

View File

@@ -2,7 +2,5 @@
[ext_resource type="Script" uid="uid://b4mr2vn8mw6r4" path="res://Gameplay/Actor.cs" id="1_hr3hk"]
[node name="Actor" type="Node"]
[node name="Actor" type="Sprite2D"]
script = ExtResource("1_hr3hk")
[node name="StartPosition" type="Marker2D" parent="."]

89
Gameplay/actor_panel.tscn Normal file
View File

@@ -0,0 +1,89 @@
[gd_scene load_steps=5 format=3 uid="uid://8kv00jc35dma"]
[ext_resource type="Script" uid="uid://c4ekvurl6q7jn" path="res://Gameplay/ActorPanel.cs" id="1_dg1wx"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e1ofl"]
bg_color = Color(1, 1, 1, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mmnuv"]
bg_color = Color(0.259294, 0.259294, 0.259294, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dg1wx"]
bg_color = Color(0.6, 1, 0.6, 1)
[node name="ActorPanel" type="Panel"]
anchors_preset = -1
offset_left = -100.0
offset_top = -150.0
offset_right = 100.0
offset_bottom = 150.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_e1ofl")
script = ExtResource("1_dg1wx")
[node name="RichTextLabel" type="RichTextLabel" parent="."]
layout_mode = 0
offset_right = 207.0
offset_bottom = 40.0
theme_override_colors/default_color = Color(0, 0, 0, 1)
text = "Actor Name"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Image" type="Sprite2D" parent="."]
position = Vector2(100, 75)
[node name="Health" type="Node2D" parent="."]
position = Vector2(100, 150)
[node name="Name" type="RichTextLabel" parent="Health"]
offset_left = -80.0
offset_top = -26.0
offset_bottom = -1.0
theme_override_colors/default_color = Color(0, 0, 0, 1)
text = "Health"
vertical_alignment = 1
metadata/_edit_use_anchors_ = true
[node name="Max" type="RichTextLabel" parent="Health"]
offset_top = -26.0
offset_right = 80.0
offset_bottom = -1.0
theme_override_colors/default_color = Color(0, 0, 0, 1)
text = "000"
horizontal_alignment = 2
vertical_alignment = 1
metadata/_edit_use_anchors_ = true
[node name="Separator" type="RichTextLabel" parent="Health"]
offset_top = -26.0
offset_right = 50.0
offset_bottom = -1.0
theme_override_colors/default_color = Color(0, 0, 0, 1)
text = "/
"
horizontal_alignment = 2
vertical_alignment = 1
metadata/_edit_use_anchors_ = true
[node name="Value" type="RichTextLabel" parent="Health"]
offset_top = -26.0
offset_right = 40.0
offset_bottom = -1.0
theme_override_colors/default_color = Color(0, 0, 0, 1)
text = "000"
horizontal_alignment = 2
vertical_alignment = 1
metadata/_edit_use_anchors_ = true
[node name="Bar" type="ProgressBar" parent="Health"]
offset_left = -80.0
offset_top = -3.0
offset_right = 81.0
offset_bottom = 4.0
theme_override_styles/background = SubResource("StyleBoxFlat_mmnuv")
theme_override_styles/fill = SubResource("StyleBoxFlat_dg1wx")
step = 1.0
show_percentage = false
metadata/_edit_use_anchors_ = true

View File

@@ -1,27 +1,6 @@
[gd_scene load_steps=5 format=3 uid="uid://5ymxo45j4ryt"]
[gd_scene load_steps=2 format=3 uid="uid://5ymxo45j4ryt"]
[ext_resource type="Script" uid="uid://0c1u4l8lu07h" path="res://Gameplay/Battle.cs" id="1_i431l"]
[ext_resource type="PackedScene" uid="uid://dsprg4uahkylm" path="res://Gameplay/table.tscn" id="2_6t8i5"]
[ext_resource type="PackedScene" uid="uid://cdaxqopr35lll" path="res://Gameplay/player.tscn" id="2_ogveh"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tivnh"]
bg_color = Color(0.111197, 0.111197, 0.111197, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
[node name="Battle" type="Node" groups=["battles"]]
script = ExtResource("1_i431l")
[node name="Table" parent="." instance=ExtResource("2_6t8i5")]
position = Vector2(357, 539)
[node name="Player" parent="." instance=ExtResource("2_ogveh")]
[node name="PottedPanel" type="Panel" parent="."]
offset_left = 694.0
offset_top = 123.0
offset_right = 815.0
offset_bottom = 1003.0
theme_override_styles/panel = SubResource("StyleBoxFlat_tivnh")

View File

@@ -1,9 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://yqtgkxjjexag"]
[gd_scene load_steps=2 format=3 uid="uid://yqtgkxjjexag"]
[ext_resource type="Script" uid="uid://v6ovq4snxruc" path="res://Gameplay/Main.cs" id="1_0xm2m"]
[ext_resource type="PackedScene" uid="uid://5ymxo45j4ryt" path="res://Gameplay/battle.tscn" id="3_vkc8e"]
[node name="Main" type="Node"]
script = ExtResource("1_0xm2m")
[node name="Battle" parent="." instance=ExtResource("3_vkc8e")]

BIN
art/jeff.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

34
art/jeff.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c6eui3f3rgcd7"
path="res://.godot/imported/jeff.png-5d89b47d50f05d86f96544842e596d2b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/jeff.png"
dest_files=["res://.godot/imported/jeff.png-5d89b47d50f05d86f96544842e596d2b.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

BIN
art/ness.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

34
art/ness.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://djf4xoheoxq8j"
path="res://.godot/imported/ness.png-a622ea535e2011d0b2b7179ab9a56990.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/ness.png"
dest_files=["res://.godot/imported/ness.png-a622ea535e2011d0b2b7179ab9a56990.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

BIN
art/paula.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

34
art/paula.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bcjfn7km102yj"
path="res://.godot/imported/paula.png-1324567e16dda0b6556a8cda98993e45.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/paula.png"
dest_files=["res://.godot/imported/paula.png-1324567e16dda0b6556a8cda98993e45.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

BIN
art/poo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

34
art/poo.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bjfe0tmumvsmi"
path="res://.godot/imported/poo.png-53bba34069cd30827409c19e31039eb5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/poo.png"
dest_files=["res://.godot/imported/poo.png-53bba34069cd30827409c19e31039eb5.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