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.
Diff: Map/Map.cpp
- Revision:
- 2:ee9b361ba6df
- Child:
- 3:3d35ab70b565
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Map/Map.cpp Sun May 05 21:54:07 2019 +0000 @@ -0,0 +1,47 @@ +#include "Map.h" + +Map::Map() { + +} + +Map::~Map() { + +} + +void Map::init(int width,int height) { + _w = width; + _h = height; + _x1 = -42 - (_w - 84) / 2; + _x2 = 84 + (_w - 84) / 2; + _y1 = -24 - (_h - 48) / 2; + _y2 = 48 + (_h - 48) / 2; +} + +void Map::write(int pix_x, int pix_y) { + + _x1 = _x1 - pix_x; + _x2 = _x2 - pix_x; + _y2 = _y2 + pix_y; + _y2 = _y2 + pix_y; + + if (_x1 > 0) { + _x1 = 0; + } + if (_x2 < 42) { + _x2 = 42; + } + if (_y1 > 0) { + _y1 = 0; + } + if (_y2 < 24) { + _y1 = 24; + } +} + +void Map::draw(N5110 &lcd) { + + lcd.drawRect(_x1,_y1,_w,24,FILL_BLACK); + lcd.drawRect(_x1,_y1,48,_h,FILL_BLACK); + lcd.drawRect(_x1,_y2,_w,24,FILL_BLACK); + lcd.drawRect(_x2,_y1,48,_h,FILL_BLACK); +} \ No newline at end of file