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
Fork of ll14zs by
Level/Level.cpp
- Committer:
- ll14zs
- Date:
- 2018-05-24
- Revision:
- 3:1231a3961984
File content as of revision 3:1231a3961984:
#include "Level.h" Level::Level() { _height = 1; srand(time(NULL)); _width = rand()%70; //printf("%d\n",levelwidth) _x = 1; _y = 45; int direction = 0; if (direction == 0) { _velocity.y = -(1); } } Level::~Level() { } void Level::draw(N5110 &lcd) { lcd.drawRect(_x,_y,_width,_height,1); lcd.drawRect((_width +10),_y,(70-_width),_height,1); } void Level::update() { _x += _velocity.x; _y += _velocity.y; } void Level::set_velocity(Vector2D v) { _velocity.x = v.x; _velocity.y = v.y; } Vector2D Level::get_velocity() { Vector2D v = {_velocity.x,_velocity.y}; return v; } Vector2D Level::get_pos() { Vector2D p - {_x,_y}; return p; } void Level::set_pos(Vector2D p) { _x = p.x; _y = p.y; }