adding in some example pegs and their actions. organizing folders, still working on pathing for some reason it won't move sometimes, and causes the looping to break

This commit is contained in:
2026-06-26 02:36:01 -04:00
parent fc32baa071
commit 350d2bc4d1
33 changed files with 366 additions and 165 deletions
+63
View File
@@ -0,0 +1,63 @@
using System.Collections.Generic;
using Godot;
public partial class Ball : RigidBody2D
{
[Signal]
public delegate void HitEventHandler(Node NODE);
[Signal]
public delegate void BucketEnteredEventHandler();
public bool _hovered = false;
public int _healthChange = -1, _hits = 0;
public Vector2 _speed;
public Path2D _predictionPath;
public Commander _commanderOwner;
public override void _Ready()
{
base._Ready();
_predictionPath = GetNode<Path2D>("PredictedPath");
}
public void Act(Node BODY)
{
EmitSignal(SignalName.Hit, BODY);
if (BODY is Peg peg)
{
peg.ChangeHealth(_healthChange, _commanderOwner);
_hits++;
}
}
public override void _PhysicsProcess(double delta)
{
base._PhysicsProcess(delta);
if (_speed != Vector2.Zero){
LinearVelocity = _speed;
_speed = Vector2.Zero;
}
}
public void DrawPath(List<Vector2> POINTS)
{
_predictionPath.Curve.ClearPoints();
for (int i = 0; i < POINTS.Count; i++)
{
_predictionPath.Curve.AddPoint(POINTS[i]);
}
}
public void EnteredBucket()
{
EmitSignal(SignalName.BucketEntered);
}
public void Shoot(Vector2 FORCE){
_speed = FORCE;
GravityScale = 1;
}
}