-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameAI.cpp
More file actions
40 lines (33 loc) · 1.31 KB
/
GameAI.cpp
File metadata and controls
40 lines (33 loc) · 1.31 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
#include <galaxy-explorer/GameAI.hpp>
#include <galaxy-explorer/MyAIData.hpp>
#include <SFML/Graphics.hpp>
GameAI::GameAI(const GameInfo& game_info, sf::RenderTarget* debug_rt)
{
this->debug_rt = debug_rt;
this->game_info = game_info;
this->asteroid_observer = AsteroidsObserver(this);
this->my_game_ai = new MyAIData();
// customState().debug_on = false;
}
GameAI::~GameAI() {
delete my_game_ai;
}
SuggestedAction GameAI::suggestAction(const ShipState& ship_state) {
debug_rt->clear(sf::Color::Transparent);
if (customState().debug_on) {
if (not asteroidsObserver().asteroids().isEmpty()) {
const sf::IntRect first_ast_hb = asteroidsObserver().asteroids().front().getCurrentHitbox();
sf::RectangleShape ast_rect(sf::Vector2f(first_ast_hb.width, first_ast_hb.height));
ast_rect.setPosition(first_ast_hb.left, first_ast_hb.top);
ast_rect.setOutlineThickness(33.0f); // if lines are too thin, they won't show up sometimes
ast_rect.setOutlineColor(sf::Color::Yellow);
ast_rect.setFillColor(sf::Color::Transparent);
debug_rt->draw(ast_rect);
}
}
// return SimpleActions::NO_CHANGE;
return SimpleActions::START_YAWING_CW;
// return SimpleActions::START_YAWING_ACW;
// return SimpleActions::STOP_YAWING_AND_FIRE;
// return SuggestedAction{ SuggestedAction::YawingClockwise, SuggestedAction::FiringTry };
}