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
Diff: Wall/Wall.cpp
- Revision:
- 7:0a122d5295d2
- Child:
- 8:ccf827ce0072
diff -r 0bc6813fe434 -r 0a122d5295d2 Wall/Wall.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Wall/Wall.cpp Fri Apr 19 05:22:02 2019 +0000
@@ -0,0 +1,84 @@
+ /*
+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 "Walls.h"
+
+Wall::Wall(){
+}
+
+Wall::~Wall(){
+}
+
+void Wall::init(int size,int speed)
+{
+ _size = size;
+ _x = WIDTH;
+ _y =0 ;
+ srand(time(NULL));
+ int di = 0; // randomise the direction.
+ if (di == 0) {
+ _velocity.x = speed;
+ _velocity.y = 1;
+ }
+}
+
+void Wall::draw(N5110 &lcd)
+{
+ /* lcd.drawRect(_x+1,_y+1,_x+40,_y+1,FILL_BLACK);
+ lcd.drawRect(_x+5,_y+2,_x+36,_y+2,FILL_BLACK);
+ lcd.drawRect(_x+10,_y+3,_x+31,_y+3,FILL_BLACK);
+ lcd.drawRect(_x+15,_y+4,_x+26,_y+4,FILL_BLACK);
+ lcd.drawRect(_x+17,_y+5,_x+23,_y+5,FILL_BLACK);
+ lcd.drawRect(_x+19,_y+6,_x+21,_y+6,FILL_BLACK);*/
+
+ lcd.drawRect(_x,_y,_x+10,_y+10,FILL_BLACK);
+ // lcd.drawRect(_x+20,_y,_x+30,_y+10,FILL_BLACK);
+ lcd.drawRect(_x+10,_y+33,_x+20,_y+40,FILL_BLACK);
+
+
+
+
+}
+
+void Wall::update()
+{
+
+ _x -= _velocity.x;
+ if (_x <= 1){
+ _x = WIDTH;
+ _y = 0;
+ }
+}
+
+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;
+}
\ No newline at end of file