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.
Snek/Snek.cpp
- Committer:
- Andrew_M
- Date:
- 2018-04-29
- Revision:
- 3:6253a2d374fa
- Parent:
- 2:9ca5e1c221c3
- Child:
- 4:6353f829c56c
File content as of revision 3:6253a2d374fa:
#include "Snek.h" // nothing doing in the constructor and destructor Snek::Snek() { } Snek::~Snek() { } void Snek::init(int x, int y) { //Inital values for variables _x = x; _y = y; printf ("floats: %i %i \n", _x, _y); } void Snek::update(Direction d) { if (d == N) { _y -= 1; _oldDirection = 'N'; } else if (d == S) { _y += 1; _oldDirection = 'S'; } else if (d == E) { _x += 1; _oldDirection = 'E'; } else if (d == W) { _x -= 1; _oldDirection = 'W'; } else { if (_oldDirection == 'N') { _y -= 1; } else if (_oldDirection == 'S') { _y += 1; } else if (_oldDirection == 'E') { _x += 1; } else if (_oldDirection == 'W') { _x -= 1; } } } int Snek::getX() { return _x; } int Snek::getY() { return _y; }