Final Submission. I have read and agreed with Statement of Academic Integrity.
Dependencies: mbed Gamepad N5110 Joystick
Snake/Snake.cpp
- Committer:
- el16dlc
- Date:
- 2019-05-09
- Revision:
- 10:aedca0082855
- Parent:
- 3:660de4311976
File content as of revision 10:aedca0082855:
#include "Snake.h" // constructor and destructor empty Snake::Snake() { } Snake::~Snake() { } void Snake::init() { _snake_posX = WIDTH/2 - 2; // Snake head set to horizontal centre _snake_posY = HEIGHT/2 - 2; // Snake head set to vertical centre } void Snake::draw_head(N5110 &lcd) { lcd.drawRect(_snake_posX,_snake_posY,4,4,FILL_BLACK); // Draws snake head } // this method allows changing the horizontal snake position void Snake::set_snake_posX(int snake_posX) {_snake_posX = snake_posX;} // this method allows changing thevertical snake position void Snake::set_snake_posY(int snake_posY) {_snake_posY = snake_posY;} // this method gets the horizontal position of snake int Snake::get_snake_posX() { return _snake_posX; } // this method gets the vertical position of snake int Snake::get_snake_posY() { return _snake_posY; } // this method allows changing the horizontal position of food void Snake::set_food_posX(int food_posX) {_food_posX = food_posX;} // this method allows changing the vertical position of food void Snake::set_food_posY(int food_posY) {_food_posY = food_posY;} // accessors // this method gets the food horizontal position int Snake::get_food_posX() { return _food_posX; } // this method gets the food vertical position int Snake::get_food_posY() { return _food_posY; } void Snake::draw_food(N5110 &lcd) { lcd.drawRect(_food_posX,_food_posY,4,4,FILL_BLACK); // draw food }