Fixed sprite lookups

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-13 18:56:43 +01:00
parent bf8d9d7eb1
commit 827d858f0f
10 changed files with 51 additions and 35 deletions

View File

@@ -1,10 +1,10 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:wolf_dart/classes/color_palette.dart';
import 'package:wolf_dart/classes/linear_coordinates.dart';
import 'package:wolf_dart/classes/matrix.dart';
import 'package:wolf_dart/classes/sprite.dart';
import 'package:wolf_dart/features/renderer/color_palette.dart';
class RaycasterPainter extends CustomPainter {
final Matrix<int> map;
@@ -209,10 +209,8 @@ class RaycasterPainter extends CustomPainter {
// THE Z-BUFFER CHECK!
// Only draw if the sprite is closer to the camera than the wall at this pixel column
if (transformY < zBuffer[stripe]) {
int texX = ((stripe - drawStartX) * 64 / spriteWidth).toInt().clamp(
0,
63,
);
double texXDouble = (stripe - drawStartX) * 64 / spriteWidth;
int texX = texXDouble.toInt().clamp(0, 63);
double startY = (size.height / 2) - (spriteHeight / 2);
double stepY = spriteHeight / 64.0;