![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Final Submission. I have read and agreed with Statement of Academic Integrity.
Dependencies: mbed Gamepad N5110 Joystick
Snake/Snake.cpp@2:0bd6711eae26, 2019-05-08 (annotated)
- Committer:
- el16dlc
- Date:
- Wed May 08 21:26:27 2019 +0000
- Revision:
- 2:0bd6711eae26
- Parent:
- 1:b9f3b7d869d8
- Child:
- 3:660de4311976
3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el16dlc | 1:b9f3b7d869d8 | 1 | #include "Snake.h" |
el16dlc | 1:b9f3b7d869d8 | 2 | |
el16dlc | 1:b9f3b7d869d8 | 3 | Snake::Snake() { |
el16dlc | 1:b9f3b7d869d8 | 4 | } |
el16dlc | 1:b9f3b7d869d8 | 5 | |
el16dlc | 1:b9f3b7d869d8 | 6 | Snake::~Snake() { |
el16dlc | 1:b9f3b7d869d8 | 7 | } |
el16dlc | 1:b9f3b7d869d8 | 8 | |
el16dlc | 1:b9f3b7d869d8 | 9 | void Snake::init() { |
el16dlc | 1:b9f3b7d869d8 | 10 | _snake_posX = WIDTH/2 - 2; // Snake head set to horizontal centre |
el16dlc | 1:b9f3b7d869d8 | 11 | _snake_posY = HEIGHT/2 - 2; // Snake head set to vertical centre |
el16dlc | 1:b9f3b7d869d8 | 12 | } |
el16dlc | 1:b9f3b7d869d8 | 13 | |
el16dlc | 1:b9f3b7d869d8 | 14 | void Snake::draw_head(N5110 &lcd) { |
el16dlc | 1:b9f3b7d869d8 | 15 | lcd.drawRect(_snake_posX,_snake_posY,4,4,FILL_BLACK); // Draws snake head |
el16dlc | 1:b9f3b7d869d8 | 16 | } |
el16dlc | 1:b9f3b7d869d8 | 17 | |
el16dlc | 2:0bd6711eae26 | 18 | void Snake::set_snake_posX(int snake_posX) {_snake_posX = snake_posX;} // mutators allow changing snake position |
el16dlc | 2:0bd6711eae26 | 19 | void Snake::set_snake_posY(int snake_posY) {_snake_posY = snake_posY;} |
el16dlc | 2:0bd6711eae26 | 20 | |
el16dlc | 2:0bd6711eae26 | 21 | // accessors |
el16dlc | 2:0bd6711eae26 | 22 | int Snake::get_snake_posX() { |
el16dlc | 2:0bd6711eae26 | 23 | return _snake_posX; |
el16dlc | 2:0bd6711eae26 | 24 | } |
el16dlc | 2:0bd6711eae26 | 25 | int Snake::get_snake_posY() { |
el16dlc | 2:0bd6711eae26 | 26 | return _snake_posY; |
el16dlc | 2:0bd6711eae26 | 27 | } |