-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of a pixellated graphics renderer
- Loading branch information
1 parent
6fe1280
commit b6d1f9b
Showing
17 changed files
with
154 additions
and
135 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
namespace Aurora.Common.Tests; | ||
|
||
public sealed class InverseKinematicsSystem : ModSystem | ||
{ | ||
public sealed class Segment | ||
{ | ||
public Vector2 Start; | ||
public Vector2 End; | ||
|
||
public float Angle; | ||
public float Length; | ||
|
||
public Segment(Vector2 start, float angle, float length) | ||
{ | ||
Start = start; | ||
Angle = angle; | ||
Length = length; | ||
CalculateEnd(); | ||
} | ||
|
||
public void CalculateEnd() | ||
{ | ||
var direction = Angle.ToRotationVector2() * Length; | ||
End = Start + direction; | ||
} | ||
|
||
public void Follow(Vector2 target) | ||
{ | ||
var toTarget = target - Start; | ||
Angle = (float)Math.Atan2(toTarget.Y, toTarget.X); // Calculate angle towards the target | ||
CalculateEnd(); | ||
} | ||
|
||
public void UpdateStart(Vector2 newStart) | ||
{ | ||
Start = newStart; | ||
CalculateEnd(); | ||
} | ||
|
||
public void Draw() | ||
{ | ||
Utils.DrawLine( | ||
Main.spriteBatch, | ||
Start, | ||
End, | ||
Color.White, | ||
Color.White, | ||
4f | ||
); | ||
} | ||
} | ||
|
||
private Segment upperArm; | ||
private Segment forearm; | ||
|
||
public override void Load() | ||
{ | ||
base.Load(); | ||
On_Main.DrawInfernoRings += On_MainOnDrawInfernoRings; | ||
|
||
|
||
|
||
} | ||
|
||
public override void PostUpdateDusts() { | ||
base.PostUpdateDusts(); | ||
|
||
Vector2 startPos = new Vector2(0f, 100f); | ||
|
||
float upperArmLength = 50f; | ||
float forearmLength = 40f; | ||
|
||
upperArm ??= new Segment(Main.LocalPlayer.Center - startPos, 0f, upperArmLength); | ||
forearm ??= new Segment(Main.LocalPlayer.Center - startPos, 0f, forearmLength); | ||
} | ||
|
||
private void On_MainOnDrawInfernoRings(On_Main.orig_DrawInfernoRings orig, Main self) | ||
{ | ||
orig(self); | ||
|
||
if (forearm is null || upperArm is null) { | ||
return; | ||
} | ||
|
||
// Get the local player | ||
Player player = Main.LocalPlayer; | ||
|
||
// Set the player's center as the starting position of the upper arm | ||
Vector2 playerCenter = player.Center; | ||
|
||
// Get the cursor position as the target | ||
Vector2 cursorPosition = Main.MouseWorld; | ||
|
||
// Update the arm segments to follow the cursor | ||
upperArm.Follow(cursorPosition); | ||
forearm.Follow(upperArm.Start); // Upper arm should follow forearm's start | ||
|
||
// Update the starting position of the forearm based on the upper arm | ||
upperArm.UpdateStart(playerCenter); | ||
forearm.UpdateStart(upperArm.End); | ||
|
||
// Draw the arm segments | ||
upperArm.Draw(); | ||
forearm.Draw(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Aurora.Content.Items.Scarlet; | ||
|
||
public class ScarletPlayerDrawLayer | ||
{ | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Aurora.Core.Graphics; | ||
|
||
public class PixellatedRenderer | ||
{ | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace Aurora.Common.Physics; | ||
|
||
public sealed class Segment | ||
{ | ||
public Vector2 Start; | ||
public Vector2 End; | ||
|
||
public float Length; | ||
public float Rotation; | ||
|
||
public Segment(Vector2 start, float length, float rotation = 0f) { | ||
Start = start; | ||
|
||
Length = length; | ||
Rotation = rotation; | ||
|
||
End = Start + Rotation.ToRotationVector2() * Length; | ||
} | ||
|
||
public void Follow(Vector2 position) { | ||
End = Start + Rotation.ToRotationVector2() * Length; | ||
|
||
Rotation = Start.AngleTo(position); | ||
|
||
var direction = position - Start; | ||
|
||
direction = direction.SafeNormalize(Vector2.Zero) * Length; | ||
direction *= -1; | ||
|
||
Start = position + direction; | ||
} | ||
|
||
public void Draw() { | ||
Utils.DrawLine(Main.spriteBatch, Start, End, Color.White, Color.White, 10f); | ||
} | ||
} |