Refactor coordinate system
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:wolf_dart/classes/linear_coordinates.dart';
|
||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
||||
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
|
||||
import 'package:wolf_dart/features/entities/entity.dart';
|
||||
|
||||
@@ -49,12 +49,12 @@ class Dog extends Enemy {
|
||||
@override
|
||||
void update({
|
||||
required int elapsedMs,
|
||||
required LinearCoordinates player,
|
||||
required Coordinate2D playerPosition,
|
||||
required bool Function(int x, int y) isWalkable,
|
||||
required void Function(int damage) onDamagePlayer,
|
||||
}) {
|
||||
if (state == EntityState.idle) {
|
||||
if (hasLineOfSight(player, isWalkable)) {
|
||||
if (hasLineOfSight(playerPosition, isWalkable)) {
|
||||
state = EntityState.patrolling;
|
||||
lastActionTime = elapsedMs;
|
||||
}
|
||||
@@ -65,8 +65,8 @@ class Dog extends Enemy {
|
||||
state == EntityState.shooting) {
|
||||
// "Shooting" here means biting
|
||||
|
||||
double dx = player.x - x;
|
||||
double dy = player.y - y;
|
||||
double dx = playerPosition.x - x;
|
||||
double dy = playerPosition.y - y;
|
||||
double distance = math.sqrt(dx * dx + dy * dy);
|
||||
double angleToPlayer = math.atan2(dy, dx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user