commit no. 5

This commit is contained in:
2026-05-29 10:51:25 -04:00
parent 617c6cc233
commit facb2e227e
27 changed files with 348 additions and 87 deletions
View File

Before

Width:  |  Height:  |  Size: 1017 B

After

Width:  |  Height:  |  Size: 1017 B

@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://nwj4n7if8kqd"
path="res://.godot/imported/circle25r.png-c9fb4b684a66f0e267203a51f53bbccb.ctex"
path="res://.godot/imported/circle25r.png-46081a6a20364337907fce72e91acb21.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://circle25r.png"
dest_files=["res://.godot/imported/circle25r.png-c9fb4b684a66f0e267203a51f53bbccb.ctex"]
source_file="res://Art/circle25r.png"
dest_files=["res://.godot/imported/circle25r.png-46081a6a20364337907fce72e91acb21.ctex"]
[params]
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://32m5teus1cjj"
path="res://.godot/imported/tower.png-1ce12b6368f31409eabfb5a04a69654e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Art/tower.png"
dest_files=["res://.godot/imported/tower.png-1ce12b6368f31409eabfb5a04a69654e.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
+26 -26
View File
@@ -5,43 +5,38 @@ public partial class Commander : Sprite2D
{
[Signal]
public delegate void TurnDoneEventHandler();
public bool _aiming = false;
public int _health = 10;
public PackedScene _attackScene = GD.Load<PackedScene>("res://Attack.tscn");
public Attack _currentAttack;
public Attack _attack;
public override void _Process(double delta)
{
base._Process(delta);
if (_currentAttack != null)
if (_attack != null)
{
if (Input.IsActionJustPressed("leftClick")){
if (_currentAttack._hovered){
_aiming = true;
}
}
if (_aiming){
Vector2 offset = (_currentAttack.GlobalPosition - GetGlobalMousePosition()) * 500;
if (Input.IsActionJustReleased("leftClick")){
ShootCurrentAttack(offset);
}
}
if (_currentAttack.Position.Y > GetViewportRect().Size.Y + 50){
_currentAttack.QueueFree();
_currentAttack = null;
EmitSignal(SignalName.TurnDone);
if (_attack.Position.Y > GetViewportRect().Size.Y + 50)
{
_attack.QueueFree();
_attack = null;
}
}
}
public void StartTurn()
{
if (_currentAttack == null){
}
public void LoadAttack()
{
if (_attack == null)
{
GD.Print("Loading attack");
_currentAttack = _attackScene.Instantiate<Attack>();
_currentAttack._commanderOwner = this;
_currentAttack.GravityScale = 0;
AddChild(_currentAttack);
_attack = _attackScene.Instantiate<Attack>();
_attack._commanderOwner = this;
_attack.GravityScale = 0;
AddChild(_attack);
}
}
@@ -56,8 +51,13 @@ public partial class Commander : Sprite2D
}
public void ShootCurrentAttack(Vector2 FORCE){
GD.Print("Shooting attack");
_currentAttack.Shoot(FORCE);
_aiming = false;
_attack.Shoot(FORCE);
}
public void UnloadAttack()
{
_attack.QueueFree();
}
}
+1 -3
View File
@@ -8,13 +8,11 @@ public partial class Enemy : StaticBody2D
public int _damage = 1, _health = 2;
public Vector2 _speed = Vector2.Up, _range = Vector2.Up;
public float _movement = 0;
public GridMap2D _grid;
public GridMarker _gridMarker;
public Commander _commander;
public override void _PhysicsProcess(double delta)
{
base._PhysicsProcess(delta);
}
public void Attack(Commander COMMANDER)
@@ -40,6 +38,6 @@ public partial class Enemy : StaticBody2D
public void TakeTurn()
{
PlaceOrMove(_grid._gridMarkers[(int)(_gridMarker._address.Y + _speed.Y)][(int)(_gridMarker._address.X + _speed.X)]);
// PlaceOrMove(_gridMarker._gridMarkers[(int)(_gridMarker._address.Y + _speed.Y)][(int)(_gridMarker._address.X + _speed.X)]);
}
}
+28
View File
@@ -0,0 +1,28 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class EnemyController : TurnController
{
public PackedScene _enemyScene = GD.Load<PackedScene>("res://Enemy.tscn");
public List<Enemy> _enemies = new();
public void AddEnemy()
{
Enemy newEnemy = _enemyScene.Instantiate<Enemy>();
// newEnemy.PlaceOrMove(_grid._gridMarkers.Last()[_rng.Next(_grid._gridMarkers.Last().Count)]);
// newEnemy._commander = _commander;
// newEnemy._grid = _grid;
_enemies.Add(newEnemy);
AddChild(newEnemy);
}
public override void StartTurn()
{
}
public void Initiate()
{
}
}
+1
View File
@@ -0,0 +1 @@
uid://brsi76xcgx3et
+36 -8
View File
@@ -1,36 +1,64 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
public partial class GridMap2D : Node2D
{
[Export]
public bool _showMarkers = true;
public int _cellSize = 16;
public Vector2 _sizeInPixels, _sizeInCells;
public Area2D _playArea;
public GridMarker _gridMarker;
public List<StaticBody2D> _leftEdges = new(), _rightEdges = new();
public List<List<GridMarker>> _gridMarkers = new();
public override void _Ready()
{
base._Ready();
_playArea = GetNode<Area2D>("PlayArea");
StaticBody2D firstOnLeft = GetNode<StaticBody2D>("LeftEdge1");
StaticBody2D firstOnRight = GetNode<StaticBody2D>("RightEdge1");
_leftEdges.Add(firstOnLeft);
_rightEdges.Add(firstOnRight);
CollisionShape2D firstOnLeftBounds = firstOnLeft.GetNode<CollisionShape2D>("Bounds");
CollisionShape2D firstOnRightBounds = firstOnRight.GetNode<CollisionShape2D>("Bounds");
_gridMarker = GetNode<GridMarker>("GridMarker");
CollisionShape2D bounds = _playArea.GetNode<CollisionShape2D>("Bounds");
int gridCellsX = (int)bounds.Shape.GetRect().Size.X / _cellSize, gridCellsY = (int)bounds.Shape.GetRect().Size.Y / _cellSize;
for (int i = 0; i < gridCellsY; i++)
CollisionShape2D playAreaBounds = _playArea.GetNode<CollisionShape2D>("Bounds");
_sizeInPixels = new Vector2((int)playAreaBounds.Shape.GetRect().Size.X, (int)playAreaBounds.Shape.GetRect().Size.Y);
_sizeInCells = new Vector2(_sizeInPixels.X / _cellSize, _sizeInPixels.Y / _cellSize);
for (int i = 0; i < _sizeInCells.Y; i++)
{
_gridMarkers.Add([]);
for (int j = 0; j < gridCellsX; j++)
for (int j = 0; j < _sizeInCells.X; j++)
{
GridMarker newGridMarker = (GridMarker)_gridMarker.Duplicate();
newGridMarker._address = new Vector2(j, i);
newGridMarker.Position = new Vector2(_playArea.Position.X - bounds.Shape.GetRect().Size.X / 2 + (j+.5f)*_cellSize, _playArea.Position.Y - bounds.Shape.GetRect().Size.Y / 2 + (i+.5f)*_cellSize);
newGridMarker.Modulate = new Color(((i+j)%2 == 0 ? "#ffffff" : "#000000")+(_showMarkers ? "ff" : "00"));
newGridMarker.Position = new Vector2(_playArea.Position.X - playAreaBounds.Shape.GetRect().Size.X / 2 + (j+.5f)*_cellSize, _playArea.Position.Y - playAreaBounds.Shape.GetRect().Size.Y / 2 + (i+.5f)*_cellSize);
_gridMarkers[i].Add(newGridMarker);
AddChild(newGridMarker);
}
}
int leftEdgeSectionSizeY = (int)firstOnLeftBounds.Shape.GetRect().Size.Y, rightEdgeSectionSizeY = (int)firstOnRightBounds.Shape.GetRect().Size.Y;
int leftEdgeSectionsCount = (int)_sizeInPixels.Y / leftEdgeSectionSizeY, rightEdgeSectionsCount = (int)_sizeInPixels.Y / rightEdgeSectionSizeY;
for (int i = 1; i < leftEdgeSectionsCount; i++)
{
StaticBody2D newLeftSection = (StaticBody2D)firstOnLeft.Duplicate();
newLeftSection.Position += new Vector2(0, leftEdgeSectionSizeY * i);
_leftEdges.Add(newLeftSection);
AddChild(newLeftSection);
}
for (int i = 1; i < rightEdgeSectionsCount; i++)
{
StaticBody2D newRightSection = (StaticBody2D)firstOnRight.Duplicate();
newRightSection.Position += new Vector2(0, rightEdgeSectionSizeY * i);
_rightEdges.Add(newRightSection);
AddChild(newRightSection);
}
_gridMarker.QueueFree();
}
}
+18 -31
View File
@@ -5,21 +5,27 @@ using System.Linq;
public partial class Main : Node
{
public bool _isCommanderTurn = true;
public Commander _commander;
public GridMap2D _grid;
public PackedScene _enemyScene = GD.Load<PackedScene>("res://Enemy.tscn");
public List<Enemy> _enemies = new();
public PlayerController _playerController;
public EnemyController _enemyController;
public TurnController _turnController;
public Random _rng = new();
public override void _Ready()
{
base._Ready();
_commander = GetNode<Commander>("Commander");
_grid = GetNode<GridMap2D>("GridMap2D");
_commander.GlobalPosition = _grid.GlobalPosition;
_commander.TurnDone += ChangeTurn;
AddEnemy();
_commander.StartTurn();
_playerController = GetNode<PlayerController>("PlayerController");
_enemyController = GetNode<EnemyController>("EnemyController");
_playerController._grid = _grid;
_enemyController._grid = _grid;
_playerController.TurnDone += ChangeTurn;
_enemyController.TurnDone += ChangeTurn;
_enemyController.Initiate();
_playerController.SetUpTowers();
ChangeTurn();
}
public override void _Process(double delta)
@@ -33,33 +39,14 @@ public partial class Main : Node
public void ChangeTurn()
{
_isCommanderTurn = !_isCommanderTurn;
if (_isCommanderTurn)
if (_turnController != _playerController)
{
GD.Print("Starting Commander turn");
_commander.StartTurn();
_playerController.StartTurn();
}
else
{
GD.Print("Starting Enemy turn");
for (int i = 0; i < _enemies.Count; i++)
{
_enemies[i].TakeTurn();
}
AddEnemy();
ChangeTurn();
_enemyController.StartTurn();
}
}
public void AddEnemy()
{
Enemy newEnemy = _enemyScene.Instantiate<Enemy>();
newEnemy.TurnDone += ChangeTurn;
newEnemy.PlaceOrMove(_grid._gridMarkers.Last()[_rng.Next(_grid._gridMarkers.Last().Count)]);
newEnemy._commander = _commander;
newEnemy._grid = _grid;
_enemies.Add(newEnemy);
AddChild(newEnemy);
}
}
+41
View File
@@ -0,0 +1,41 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class PlayerController : TurnController
{
public PackedScene _commanderScene = GD.Load<PackedScene>("res://Commander.tscn");
public List<Tower> _towers = new();
public override void _Ready()
{
base._Ready();
}
public void SetUpTowers(int TOWER_COUNT = 8)
{
Tower tower = GetNode<Tower>("Tower1");
Vector2 towerPositionCorrection = tower._area.GetNode<CollisionShape2D>("Bounds").Shape.GetRect().Size / 2 * (Vector2.Right + Vector2.Up);
float spaceBetweenTowers = _grid._sizeInPixels.X / (TOWER_COUNT - 1);
tower.Position = _grid.Position - _grid._sizeInPixels / 2 + towerPositionCorrection;
_towers.Add(tower);
for (int i = 1; i < TOWER_COUNT; i++)
{
Tower newTower = (Tower)tower.Duplicate();
newTower.Position += new Vector2(spaceBetweenTowers * i - towerPositionCorrection.X * i / (TOWER_COUNT - 1) * 2, 0);
_towers.Add(newTower);
AddChild(newTower);
}
Commander newCommander = _commanderScene.Instantiate<Commander>();
_towers[3]._commander = newCommander;
_towers[3].AddChild(newCommander);
}
public override void StartTurn()
{
}
}
+1
View File
@@ -0,0 +1 @@
uid://cfohujgs5dygx
+51
View File
@@ -0,0 +1,51 @@
using Godot;
using System;
public partial class Tower : Sprite2D
{
public bool _hovered, _aiming;
public Commander _commander;
public Area2D _area;
public override void _Ready()
{
base._Ready();
_area = GetNode<Area2D>("Area");
}
public override void _Process(double delta)
{
base._Process(delta);
if (Input.IsActionJustPressed("leftClick"))
{
if (_hovered)
{
_aiming = true;
_commander.LoadAttack();
}
}
if (_aiming)
{
if (Input.IsActionJustReleased("rightClick"))
{
Vector2 offset = (GlobalPosition - GetGlobalMousePosition()) * 500;
_commander.ShootCurrentAttack(offset);
_aiming = false;
}
else if (Input.IsActionJustReleased("leftClick"))
{
_commander.UnloadAttack();
_aiming = false;
}
}
}
public void OnMouseEntered(){
_hovered = true;
}
public void OnMouseExited(){
_hovered = true;
}
}
+1
View File
@@ -0,0 +1 @@
uid://b2gj1526x4ix1
+14
View File
@@ -0,0 +1,14 @@
using Godot;
using System;
public partial class TurnController : Node2D
{
[Signal]
public delegate void TurnDoneEventHandler();
public GridMap2D _grid;
public virtual void StartTurn()
{
}
}
+1
View File
@@ -0,0 +1 @@
uid://b5h6v6w5h76cg
+3 -3
View File
@@ -1,13 +1,12 @@
[gd_scene format=3 uid="uid://cevk7yax5tvej"]
[ext_resource type="Script" uid="uid://dm2gyxmgwbmg8" path="res://Attack.cs" id="1_63pi1"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://circle25r.png" id="2_hqc8w"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_hqc8w"]
[sub_resource type="CircleShape2D" id="CircleShape2D_7yfhp"]
radius = 25.0
radius = 14.0
[node name="Attack" type="RigidBody2D" unique_id=1225359241]
scale = Vector2(0.56, 0.56)
input_pickable = true
contact_monitor = true
max_contacts_reported = 100
@@ -17,6 +16,7 @@ script = ExtResource("1_63pi1")
shape = SubResource("CircleShape2D_7yfhp")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1583277900]
scale = Vector2(0.56, 0.56)
texture = ExtResource("2_hqc8w")
[connection signal="body_entered" from="." to="." method="TakeAction"]
+1 -1
View File
@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://c78e3u1owgiek"]
[ext_resource type="Script" uid="uid://b2kj0rc3g1hkm" path="res://Commander.cs" id="1_4flbx"]
[ext_resource type="Script" path="res://Commander.cs" id="1_4flbx"]
[node name="Commander" type="Sprite2D" unique_id=1378094015]
script = ExtResource("1_4flbx")
+2 -2
View File
@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://bpce6ise18ks"]
[gd_scene format=3 uid="uid://drt7w0eqp13tu"]
[ext_resource type="Script" uid="uid://dfba4vq6jv0a6" path="res://Enemy.cs" id="1_4gyqm"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://circle25r.png" id="1_7k104"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="1_7k104"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
bounce = 0.5
+6
View File
@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://c6b188d2a20eq"]
[ext_resource type="Script" uid="uid://brsi76xcgx3et" path="res://EnemyController.cs" id="1_tkpyo"]
[node name="EnemyController" type="Node2D" unique_id=197453707]
script = ExtResource("1_tkpyo")
+25
View File
@@ -6,6 +6,15 @@
[sub_resource type="RectangleShape2D" id="RectangleShape2D_q4dkg"]
size = Vector2(1600, 800)
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7h2rc"]
bounce = 0.4
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7h2rc"]
size = Vector2(400, 16)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fjt81"]
size = Vector2(400, 16)
[node name="GridMap2D" type="Node2D" unique_id=1123610167]
script = ExtResource("1_lq4m8")
@@ -14,4 +23,20 @@ script = ExtResource("1_lq4m8")
[node name="Bounds" type="CollisionShape2D" parent="PlayArea" unique_id=1902214362]
shape = SubResource("RectangleShape2D_q4dkg")
[node name="LeftEdge1" type="StaticBody2D" parent="." unique_id=1883047200]
physics_material_override = SubResource("PhysicsMaterial_7h2rc")
[node name="Bounds" type="CollisionShape2D" parent="LeftEdge1" unique_id=1546734575]
position = Vector2(-1000, -392)
shape = SubResource("RectangleShape2D_7h2rc")
debug_color = Color(0.98836404, 0, 0.30800217, 0.41960785)
[node name="RightEdge1" type="StaticBody2D" parent="." unique_id=258284814]
physics_material_override = SubResource("PhysicsMaterial_7h2rc")
[node name="Bounds" type="CollisionShape2D" parent="RightEdge1" unique_id=773927888]
position = Vector2(1000, -392)
shape = SubResource("RectangleShape2D_fjt81")
debug_color = Color(0.9882353, 0, 0.30980393, 0.41960785)
[node name="GridMarker" parent="." unique_id=1390656323 instance=ExtResource("2_gc0wv")]
-5
View File
@@ -1,11 +1,6 @@
[gd_scene format=3 uid="uid://bxqhci3fya80t"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://circle25r.png" id="1_0j65c"]
[ext_resource type="Script" uid="uid://cob0pwghnubxa" path="res://GridMarker.cs" id="1_u0re5"]
[node name="GridMarker" type="Marker2D" unique_id=1390656323]
script = ExtResource("1_u0re5")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1491405727]
scale = Vector2(0.1, 0.1)
texture = ExtResource("1_0j65c")
+7 -5
View File
@@ -1,14 +1,16 @@
[gd_scene format=3 uid="uid://dcp7p6al4i0b7"]
[ext_resource type="Script" uid="uid://cg1m762ed04kv" path="res://Main.cs" id="1_ig7tw"]
[ext_resource type="PackedScene" uid="uid://c78e3u1owgiek" path="res://commander.tscn" id="2_0xm2m"]
[ext_resource type="PackedScene" uid="uid://la8pwcc0tjuu" path="res://grid_map_2d.tscn" id="3_h2yge"]
[ext_resource type="PackedScene" uid="uid://c6b188d2a20eq" path="res://enemy_controller.tscn" id="4_1bvp3"]
[ext_resource type="PackedScene" uid="uid://b7kvx7p0b2086" path="res://player_controller.tscn" id="4_lquwl"]
[node name="Main" type="Node" unique_id=535208469]
script = ExtResource("1_ig7tw")
[node name="Commander" parent="." unique_id=203629164 instance=ExtResource("2_0xm2m")]
[node name="GridMap2D" parent="." unique_id=1123610167 instance=ExtResource("3_h2yge")]
position = Vector2(960, 510)
_showMarkers = false
position = Vector2(960, 600)
[node name="EnemyController" parent="." unique_id=1894449838 instance=ExtResource("4_1bvp3")]
[node name="PlayerController" parent="." unique_id=364781168 instance=ExtResource("4_lquwl")]
+9
View File
@@ -0,0 +1,9 @@
[gd_scene format=3 uid="uid://b7kvx7p0b2086"]
[ext_resource type="Script" uid="uid://cfohujgs5dygx" path="res://PlayerController.cs" id="1_lvefo"]
[ext_resource type="PackedScene" uid="uid://d06n7p75u130s" path="res://tower.tscn" id="2_f0yg5"]
[node name="PlayerController" type="Node2D" unique_id=317732890]
script = ExtResource("1_lvefo")
[node name="Tower1" parent="." unique_id=1315831332 instance=ExtResource("2_f0yg5")]
+5
View File
@@ -37,6 +37,11 @@ escape={
"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":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
rightClick={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(109, 18),"global_position":Vector2(118, 66),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}
[physics]
+22
View File
@@ -0,0 +1,22 @@
[gd_scene format=3 uid="uid://d06n7p75u130s"]
[ext_resource type="Script" uid="uid://b2gj1526x4ix1" path="res://Tower.cs" id="1_k1sas"]
[ext_resource type="Texture2D" uid="uid://32m5teus1cjj" path="res://Art/tower.png" id="1_vedim"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vedim"]
size = Vector2(50, 99)
[node name="Tower" type="Sprite2D" unique_id=1315831332]
self_modulate = Color(0, 0, 0, 1)
texture = ExtResource("1_vedim")
script = ExtResource("1_k1sas")
[node name="Area" type="Area2D" parent="." unique_id=620986087]
[node name="Bounds" type="CollisionShape2D" parent="Area" unique_id=1639875880]
position = Vector2(0, 0.5)
shape = SubResource("RectangleShape2D_vedim")
debug_color = Color(0.6411928, 0.52469516, 0, 0.41960785)
[connection signal="mouse_entered" from="Area" to="." method="OnMouseEntered"]
[connection signal="mouse_exited" from="Area" to="." method="OnMouseExited"]
+6
View File
@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://cgqc3wcgqn3q5"]
[ext_resource type="Script" uid="uid://b5h6v6w5h76cg" path="res://TurnController.cs" id="1_yctlu"]
[node name="TurnController" type="Node2D" unique_id=197453707]
script = ExtResource("1_yctlu")