testing documentation

Dependencies:   mbed ll16j23s_test_docs

Committer:
JoeShotton
Date:
Tue May 26 23:25:09 2020 +0000
Revision:
10:a2d643b3c782
Parent:
9:0571880085cc
Child:
12:33a5cff31339
Removed several bugs, started on thorough documentation

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 10:a2d643b3c782 9 /** SnakeBody Class
JoeShotton 10:a2d643b3c782 10 @author Joseph Shotton
JoeShotton 10:a2d643b3c782 11 @brief All functions that exclusively control the snake body
JoeShotton 10:a2d643b3c782 12 @date May 2020
JoeShotton 10:a2d643b3c782 13 @version V1.0
JoeShotton 10:a2d643b3c782 14 */
JoeShotton 10:a2d643b3c782 15
JoeShotton 10:a2d643b3c782 16
JoeShotton 3:fcd6d70e9694 17 class SnakeBody
JoeShotton 3:fcd6d70e9694 18 {
JoeShotton 3:fcd6d70e9694 19 struct Direction {
JoeShotton 4:ea3fa51c4386 20 int delta_x; // increment value for x
JoeShotton 4:ea3fa51c4386 21 int delta_y; // increment value for y
JoeShotton 4:ea3fa51c4386 22 int nextState[5]; // array of next states
JoeShotton 3:fcd6d70e9694 23 };
JoeShotton 3:fcd6d70e9694 24
JoeShotton 3:fcd6d70e9694 25 public:
JoeShotton 3:fcd6d70e9694 26
JoeShotton 3:fcd6d70e9694 27 SnakeBody();
JoeShotton 3:fcd6d70e9694 28 ~SnakeBody();
JoeShotton 4:ea3fa51c4386 29 void init();
JoeShotton 9:0571880085cc 30 void add_length(int increase);
JoeShotton 9:0571880085cc 31 void run(Gamepad &pad, N5110 &lcd, bool &_death); //draw, movement, snake-snakecollision
JoeShotton 10:a2d643b3c782 32 void reset();
JoeShotton 4:ea3fa51c4386 33
JoeShotton 4:ea3fa51c4386 34 int _x_head;
JoeShotton 4:ea3fa51c4386 35 int _y_head;
JoeShotton 6:6c9453397f4a 36
JoeShotton 6:6c9453397f4a 37 std::vector<int> _body_x;
JoeShotton 6:6c9453397f4a 38 std::vector<int> _body_y;
JoeShotton 7:dd84e0fab346 39
JoeShotton 3:fcd6d70e9694 40 private:
JoeShotton 3:fcd6d70e9694 41
JoeShotton 9:0571880085cc 42 void snake_movement(Gamepad &pad);
JoeShotton 9:0571880085cc 43 void draw_body(N5110 &lcd);
JoeShotton 9:0571880085cc 44 void snake_snake_collision(Gamepad &pad, bool &_death);
JoeShotton 9:0571880085cc 45
JoeShotton 10:a2d643b3c782 46 void update_direction();
JoeShotton 10:a2d643b3c782 47 void update_position();
JoeShotton 4:ea3fa51c4386 48 void update_body();
JoeShotton 10:a2d643b3c782 49
JoeShotton 4:ea3fa51c4386 50 float _angle;
JoeShotton 4:ea3fa51c4386 51 int _d;
JoeShotton 10:a2d643b3c782 52 int _move_state;
JoeShotton 10:a2d643b3c782 53 int _length;
JoeShotton 9:0571880085cc 54 int _length_increase;
JoeShotton 3:fcd6d70e9694 55
JoeShotton 3:fcd6d70e9694 56 };
JoeShotton 3:fcd6d70e9694 57 #endif