mirror of
https://github.com/ProgramSnail/snake_2024.git
synced 2025-12-17 19:58:44 +00:00
functional bots, small refactoring, readme edit
This commit is contained in:
parent
5299e89633
commit
7e67a3bd30
13 changed files with 179 additions and 91 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue