mirror of
https://github.com/ProgramSnail/snake_2024.git
synced 2025-12-15 19:08:42 +00:00
initial game
This commit is contained in:
parent
4570d6e593
commit
adabb50a9e
10 changed files with 200 additions and 132 deletions
14
src/Snake.cpp
Normal file
14
src/Snake.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "Snake.hpp"
|
||||
|
||||
void Worm::add(Veci pos) {
|
||||
track_.push_back(pos);
|
||||
if (track_.size() > length) {
|
||||
track_.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
void Worm::draw(Veci offset) const {
|
||||
for (const auto &pos : track_) {
|
||||
paint::circle({{.pos = pos - offset, .color = color}, radius});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue