Yang Hongxiao 201199678
Dependencies: mbed
Platform.cpp
- Committer:
- YHX
- Date:
- 2020-05-14
- Revision:
- 1:a6ead8050c23
File content as of revision 1:a6ead8050c23:
#include "Platform.h" Platform::Platform() { } Platform::~Platform() { } void Platform::init(int y,int h,int w) { _x=WIDTH/2 - w/2; _y=y; _h = h; _w = w; _vv = 2; // default speed _score = 0; } void Platform::draw(N5110 &lcd) { lcd.drawRect(_x,_y,_w,_h,FILL_BLACK); } void Platform::update(Direction d,float mag) { _vv = int(mag*10.0f); if (d == W) { //West _x-=_vv; } else if (d == E) { //East _x+=_vv; } if (_x < 1) { _x = 1; } if (_x > WIDTH - _w - 1) { _x = WIDTH - _w - 1; } } Vector2D Platform::get_pos() { Vector2D p = {_x,_y}; return p; } void Platform::add_score() { _score++; } int Platform::get_score() { return _score; }