Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ll16j23s_test_docs
SnakeBody/SnakeBody.h
- Committer:
- JoeShotton
- Date:
- 2020-05-23
- Revision:
- 6:6c9453397f4a
- Parent:
- 4:ea3fa51c4386
- Child:
- 7:dd84e0fab346
File content as of revision 6:6c9453397f4a:
#ifndef SNAKEBODY_H
#define SNAKEBODY_H
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include <vector>
class SnakeBody
{
struct Direction {
int delta_x; // increment value for x
int delta_y; // increment value for y
int nextState[5]; // array of next states
};
public:
SnakeBody();
~SnakeBody();
void init();
void snake_movement(Gamepad &pad);
void draw_body(N5110 &lcd);
void snake_snake_collision(Gamepad &pad, bool &death); //(int _x_head, int _y_head, vector<int> _body_x, vector<int> _body_y, int _length);
int _state;
int _x_head;
int _y_head;
int _length;
std::vector<int> _body_x;
std::vector<int> _body_y;
/*
void init(int x,int height,int width);
void draw(N5110 &lcd);
void update(Direction d,float mag);
void add_score();
int get_score();
Vector2D get_pos();
*/
private:
int update_direction(float _angle, int _x_head, int _y_head); //int _angle, int _x_head, int _y_head
void update_position(); //int _d, int _state, int &_x_head, int &_y_head
void update_body();
float _angle;
int _d;
/*
int _height;
int _width;
int _x;
int _y;
int _speed;
int _score;
*/
};
#endif