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
Wall/Wall.cpp
- Committer:
- ml16c5l
- Date:
- 2019-04-29
- Revision:
- 10:bb273261d33d
- Parent:
- 9:192ad897ec95
- Child:
- 11:ba1906f151fd
File content as of revision 10:bb273261d33d:
/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name: Caiwenjing Liu
Username:ml16c5l
Student ID Number: 201165261
Date: 11/04/2019
*/
#include "Wall.h"
Wall::Wall(){
}
Wall::~Wall(){
}
void Wall::init(int size,int speed)
{
_size = size;
_x =0;
_y =0 ;
_velocity.x = speed;
_velocity.y = speed;
}
void Wall::draw(N5110 &lcd)
{
lcd.drawRect(_x-50, _y, 5, _y+15,FILL_BLACK);
lcd.drawRect(_x-20, _y+15, 5, _y+15,FILL_BLACK);
lcd.drawRect(_x+10, _y+35, 5,_y+15,FILL_BLACK);
lcd.drawRect(_x-60, _y+40, 5, _y+15,FILL_BLACK);
}
void Wall::update()
{
_x -= _velocity.x;
if (_x <= 1){
_x = WIDTH;
_y = _y;
}
}
void Wall::set_velocity(Vector2D v)
{
_velocity.x = v.x;
_velocity.y = v.y;
}
Vector2D Wall::get_velocity()
{
Vector2D v = {_velocity.x,_velocity.y};
return v;
}
Vector2D Wall::get_pos()
{
Vector2D p = {_x,_y};
return p;
}
void Wall::set_pos(Vector2D p)
{
_x = p.x;
_y = p.y;
}