functional bots, small refactoring, readme edit

This commit is contained in:
programsnail 2024-07-26 22:36:12 +03:00
parent 5299e89633
commit 7e67a3bd30
13 changed files with 179 additions and 91 deletions

View file

@ -14,6 +14,8 @@ class Player : public Snake {
public:
using Snake::Snake;
uint get_score() { return get_length() - get_initial_length(); }
void act(float dt) override {
int eaten = map_.eat(
utils::to_world_coord(get_pos() + utils::get_screen_center()), 20);
@ -24,10 +26,14 @@ public:
move(dt);
}
void draw(Veci offset) override {
void draw(Veci offset) const override {
Snake::draw(offset - utils::get_screen_center());
}
bool touches(const SnakeObject &other, Veci offset = {}) override {
return Snake::touches(other, offset - utils::get_screen_center());
}
protected:
void change_direction(float) override {
Veci cursor = utils::get_cursor();