Reorganized files

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-13 23:10:39 +01:00
parent 3086e5a8f4
commit a4bc6f8520
6 changed files with 15 additions and 14 deletions

View File

@@ -4,8 +4,8 @@ import 'package:wolf_dart/features/renderer/color_palette.dart';
class WeaponPainter extends CustomPainter {
final List<List<int>> sprite;
// 1. Initialize a reusable Paint object and disable anti-aliasing
// to keep the pixels perfectly sharp and chunky.
// Initialize a reusable Paint object and disable anti-aliasing to keep the
// pixels perfectly sharp and chunky.
final Paint _paint = Paint()
..isAntiAlias = false
..style = PaintingStyle.fill;
@@ -14,7 +14,8 @@ class WeaponPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
// Calculate width and height separately in case the container isn't a perfect square
// Calculate width and height separately in case the container isn't a
// perfect square
double pixelWidth = size.width / 64;
double pixelHeight = size.height / 64;
@@ -30,8 +31,8 @@ class WeaponPainter extends CustomPainter {
Rect.fromLTWH(
x * pixelWidth,
y * pixelHeight,
pixelWidth +
0.5, // 2. Add a tiny 0.5 overlap to completely eliminate visual seams
// Add a tiny 0.5 overlap to completely eliminate visual seams
pixelWidth + 0.5,
pixelHeight + 0.5,
),
_paint,
@@ -43,7 +44,7 @@ class WeaponPainter extends CustomPainter {
@override
bool shouldRepaint(covariant WeaponPainter oldDelegate) {
// 3. ONLY repaint if the actual animation frame (sprite) has changed!
// ONLY repaint if the actual animation frame (sprite) has changed!
// This saves massive amounts of CPU when the player is just walking around.
return oldDelegate.sprite != sprite;
}