testing documentation

Dependencies:   mbed ll16j23s_test_docs

Committer:
JoeShotton
Date:
Mon May 25 20:31:52 2020 +0000
Revision:
9:0571880085cc
Parent:
8:bcc3403d7e79
Child:
10:a2d643b3c782
Post death menus partially implemented, mostly fixed food location issues and issues with tail display

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JoeShotton 3:fcd6d70e9694 1 #ifndef SNAKEBODY_H
JoeShotton 3:fcd6d70e9694 2 #define SNAKEBODY_H
JoeShotton 3:fcd6d70e9694 3
JoeShotton 3:fcd6d70e9694 4 #include "mbed.h"
JoeShotton 3:fcd6d70e9694 5 #include "N5110.h"
JoeShotton 3:fcd6d70e9694 6 #include "Gamepad.h"
JoeShotton 3:fcd6d70e9694 7 #include <vector>
JoeShotton 3:fcd6d70e9694 8
JoeShotton 3:fcd6d70e9694 9 class SnakeBody
JoeShotton 3:fcd6d70e9694 10 {
JoeShotton 3:fcd6d70e9694 11 struct Direction {
JoeShotton 4:ea3fa51c4386 12 int delta_x; // increment value for x
JoeShotton 4:ea3fa51c4386 13 int delta_y; // increment value for y
JoeShotton 4:ea3fa51c4386 14 int nextState[5]; // array of next states
JoeShotton 3:fcd6d70e9694 15 };
JoeShotton 3:fcd6d70e9694 16
JoeShotton 3:fcd6d70e9694 17 public:
JoeShotton 3:fcd6d70e9694 18
JoeShotton 3:fcd6d70e9694 19 SnakeBody();
JoeShotton 3:fcd6d70e9694 20 ~SnakeBody();
JoeShotton 4:ea3fa51c4386 21 void init();
JoeShotton 9:0571880085cc 22 void add_length(int increase);
JoeShotton 9:0571880085cc 23 void run(Gamepad &pad, N5110 &lcd, bool &_death); //draw, movement, snake-snakecollision
JoeShotton 4:ea3fa51c4386 24
JoeShotton 4:ea3fa51c4386 25 int _state;
JoeShotton 4:ea3fa51c4386 26 int _x_head;
JoeShotton 4:ea3fa51c4386 27 int _y_head;
JoeShotton 4:ea3fa51c4386 28 int _length;
JoeShotton 6:6c9453397f4a 29
JoeShotton 6:6c9453397f4a 30 std::vector<int> _body_x;
JoeShotton 6:6c9453397f4a 31 std::vector<int> _body_y;
JoeShotton 7:dd84e0fab346 32
JoeShotton 3:fcd6d70e9694 33 private:
JoeShotton 3:fcd6d70e9694 34
JoeShotton 9:0571880085cc 35 void snake_movement(Gamepad &pad);
JoeShotton 9:0571880085cc 36 void draw_body(N5110 &lcd);
JoeShotton 9:0571880085cc 37 void snake_snake_collision(Gamepad &pad, bool &_death);
JoeShotton 9:0571880085cc 38
JoeShotton 4:ea3fa51c4386 39 int update_direction(float _angle, int _x_head, int _y_head); //int _angle, int _x_head, int _y_head
JoeShotton 4:ea3fa51c4386 40 void update_position(); //int _d, int _state, int &_x_head, int &_y_head
JoeShotton 4:ea3fa51c4386 41 void update_body();
JoeShotton 4:ea3fa51c4386 42
JoeShotton 4:ea3fa51c4386 43 float _angle;
JoeShotton 4:ea3fa51c4386 44 int _d;
JoeShotton 9:0571880085cc 45 int _length_increase;
JoeShotton 3:fcd6d70e9694 46
JoeShotton 3:fcd6d70e9694 47 };
JoeShotton 3:fcd6d70e9694 48 #endif