-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleviathan.cpp
More file actions
46 lines (38 loc) · 1.33 KB
/
leviathan.cpp
File metadata and controls
46 lines (38 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Created by wizzy on 3/31/2026.
//
#include "leviathan.h"
#include <iostream>
#include <raymath.h>
Leviathan::Leviathan(const std::vector<std::unique_ptr<Fish> > *allFish, float x, float y, float width_limit, float height_limit) : Fish(width_limit, height_limit) {
position = Vector2( x, y );
allFishPointer = allFish;
checkpoint = -1;
}
void Leviathan::GatherInstructions() {
// Move segment towards next checkpoint in path
// Limit speed until checkpoint 0
if (checkpoint < 0) {
acceleration = Vector2Normalize(path[0] - position);
velocity = Vector2Normalize(velocity) * 400;
// Checkpoint 0 reached
if (std::abs(Vector2Length(path[0] - position)) < 100) {
checkpoint = 1;
velocity = { 0, 0 };
acceleration = { 0, 0 };
}
} else {
acceleration = Vector2Normalize(path[checkpoint] - position);
}
// Move onto next checkpoint when reached
if (std::abs(Vector2Length(path[checkpoint] - position)) < 600) {
checkpoint++;
}
if (checkpoint == path.size()) checkpoint = 0;
// Respawn anything nearby
for (int i = 0; i < 125; i++) {
if (std::abs(Vector2Length(position - (*allFishPointer)[i]->position)) < 200) {
(*allFishPointer)[i]->Respawn(width_limit, height_limit);
}
}
}