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-30
- Revision:
- 25:1d91ab97d86a
- Parent:
- 24:14489d259ffb
File content as of revision 25:1d91ab97d86a:
#include "rect.h" rect::rect() { } rect::~rect() { } void rect::init() { rect_speed = 1; // set the initial speed } void rect::draw(N5110 &lcd) { //draw rect om the screen lcd.drawRect(rect_x,40,10,1,FILL_BLACK); lcd.drawRect(rect_x+3,39,4,1,FILL_BLACK); } void rect::update(Direction d) { //control the movement of rect when joystick moves if (d == W) { rect_x-=rect_speed; } else if (d == E) { rect_x+=rect_speed; } } void rect::init_score() { rect_score = 0; //using this function when game over } void rect::add_score() { rect_score++; } void rect::minus_score() { rect_score--; } int rect::get_score() { return rect_score; } Vector2D rect::get_pos() { Vector2D p = {rect_x}; return p; } void rect::set_pos(Vector2D p) { rect_x = p.x; }