Can now pick up items

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-13 20:27:38 +01:00
parent bca8d10964
commit 026db920b3
7 changed files with 358 additions and 40 deletions

View File

@@ -1,16 +1,15 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:wolf_dart/classes/linear_coordinates.dart';
import 'package:wolf_dart/classes/matrix.dart';
import 'package:wolf_dart/features/entities/entity.dart';
import 'package:wolf_dart/features/player/player.dart';
import 'package:wolf_dart/features/renderer/color_palette.dart';
class RaycasterPainter extends CustomPainter {
final Matrix<int> map;
final List<Matrix<int>> textures;
final LinearCoordinates player;
final double playerAngle;
final Player player;
final double fov;
final Map<String, double> doorOffsets;
final List<Matrix<int>> sprites;
@@ -20,7 +19,6 @@ class RaycasterPainter extends CustomPainter {
required this.map,
required this.textures,
required this.player,
required this.playerAngle,
required this.fov,
required this.doorOffsets,
required this.sprites,
@@ -44,8 +42,8 @@ class RaycasterPainter extends CustomPainter {
// The 1D Z-Buffer
List<double> zBuffer = List.filled(screenWidth, 0.0);
double dirX = math.cos(playerAngle);
double dirY = math.sin(playerAngle);
double dirX = math.cos(player.angle);
double dirY = math.sin(player.angle);
double planeX = -dirY * math.tan(fov / 2);
double planeY = dirX * math.tan(fov / 2);
@@ -275,8 +273,8 @@ class RaycasterPainter extends CustomPainter {
if (side == 1) texNum += 1;
}
if (side == 0 && math.cos(playerAngle) > 0) texX = 63 - texX;
if (side == 1 && math.sin(playerAngle) < 0) texX = 63 - texX;
if (side == 0 && math.cos(player.angle) > 0) texX = 63 - texX;
if (side == 1 && math.sin(player.angle) < 0) texX = 63 - texX;
double startY = drawStart.toDouble();
double stepY = wallHeight / 64.0;
@@ -307,6 +305,6 @@ class RaycasterPainter extends CustomPainter {
@override
bool shouldRepaint(covariant RaycasterPainter oldDelegate) {
return oldDelegate.player != player ||
oldDelegate.playerAngle != playerAngle;
oldDelegate.player.angle != player.angle;
}
}