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
Body/Body.cpp
- Committer:
- el18lg
- Date:
- 2020-05-28
- Revision:
- 5:e0f08e8022de
- Parent:
- 4:748b3e0062f6
- Child:
- 8:59b01b57f0da
File content as of revision 5:e0f08e8022de:
#include "Body.h"
Body::Body() {
}
Body::~Body() {
}
void Body::update(Vector2D hP, int nbody) {
_nbody = nbody;
_x_init = hP.x;
_y_init = hP.y;
prevx = bodyx[0];
prevy = bodyy[0];
bodyx[0] = _x_init;
bodyy[0] = _y_init;
for (int i = 1; i < nbody; i++) {
prev2x = bodyx[i];
prev2y = bodyy[i];
bodyx[i] = prevx;
bodyy[i] = prevy;
prevx = prev2x;
prevy = prev2y;
}
}
void Body::draw(N5110 &lcd, int nbody) {
int _nbody = nbody;
for (int k = 0; k < _nbody; k++){ //Snake tail
lcd.drawRect(bodyx[k], bodyy[k], 2, 2, FILL_BLACK);
}
}