aboutsummaryrefslogtreecommitdiffstats
path: root/src/snake_map.h
diff options
context:
space:
mode:
authornathan <thenathansmithsmith@gmail.com>2023-03-20 06:34:54 +0000
committernathan <thenathansmithsmith@gmail.com>2023-03-20 06:34:54 +0000
commitdd98918fe32b9dcdfc482a2c68481e93ceb50623 (patch)
treebf2ea0e4f4e47facde93c0cf277adb2031f7b3ec /src/snake_map.h
downloadfltk_snake-main.tar.gz
fltk_snake-main.tar.bz2
fltk_snake-main.zip
first commitHEADmain
Diffstat (limited to 'src/snake_map.h')
-rw-r--r--src/snake_map.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/snake_map.h b/src/snake_map.h
new file mode 100644
index 0000000..a10c123
--- /dev/null
+++ b/src/snake_map.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "program_data.h"
+#include "snake_utils.h"
+
+class SnakeMap : public Fl_Group {
+ public:
+ SnakeMap(MainData * md) : Fl_Group(0, 0, 0, 0) {
+ main_init(md);
+ }
+
+ void draw();
+ int handle(int event);
+ void update();
+
+ // Always reset size first then snake.
+ void reset_size();
+ void reset_snake();
+ void reset_snack();
+ void reset_all();
+
+ SNAKE_DIR snake_direction() { return direction; }
+ void snake_direction(SNAKE_DIR direction) { this->direction = direction; }
+
+ void add_snake_block();
+
+ void update_length_output();
+ private:
+ MainData * mdata;
+ SNAKE_DIR direction = SNAKE_STILL;
+ SnakeSnack snack;
+
+ std::vector<SnakeBlock> snake_blocks;
+
+ void main_init(MainData * md);
+ bool snake_block_out_of_bounds(SnakeBlock snake_block);
+};