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
rec/rect.cpp
- Committer:
- RickYu
- Date:
- 2018-04-17
- Revision:
- 6:46d0caedf217
- Parent:
- 5:0a116644cce2
- Child:
- 7:1964f649676e
File content as of revision 6:46d0caedf217:
#include "rect.h" rect::rect() { } rect::~rect() { } void rect::init(int x,int y) { //rect_x = x; // x value on screen is fixed //rect_y = 80; rect_speed = 0.7; // default speed } void rect::draw(N5110 &lcd) { lcd.drawRect(rect_x,40,10,1,FILL_BLACK); } void rect::update(Direction d,float mag) { rect_speed = int(mag*10.0f); // scale is arbitrary, could be changed in future /*if (d == N) { rect_y=80; } else if (d == S) { rect_y=80; } */ if (d == W) { rect_x-=rect_speed; } else if (d == E) { rect_x+=rect_speed; } // check the y origin to ensure that the paddle doesn't go off screen } Vector2D rect::get_pos() { Vector2D p = {rect_x}; return p; } void rect::set_pos(Vector2D p) { rect_x = p.x; //rect_y = p.y; }