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.
Laser.cpp
00001 #include "Laser.h" 00002 00003 Laser::Laser() 00004 { 00005 00006 } 00007 00008 Laser::~Laser() 00009 { 00010 00011 } 00012 00013 void Laser::init() // initialises the lasers off screen 00014 { 00015 _x = -10; 00016 _y = 0; 00017 00018 _speed_y = -2; // -2 speed in the y direction, doesnt change even off screen 00019 } 00020 00021 void Laser::draw(N5110 &lcd) 00022 { 00023 if (_x >= 0) { // only draw if on screen (more efficient?) 00024 lcd.drawRect(_x,_y,2,6,FILL_BLACK); 00025 } 00026 } 00027 00028 void Laser::update() // updates the laser's y coordinate according to its speed 00029 { 00030 _y += _speed_y; 00031 } 00032 00033 int Laser::get_x() // retrieves the lasers's x coordinate 00034 { 00035 return _x; 00036 } 00037 00038 int Laser::get_y() // retrieves the lasers's y coordinate 00039 { 00040 return _y; 00041 } 00042 00043 void Laser::set_posx(int x) // sets the laser's x coordinate 00044 { 00045 _x = x; 00046 } 00047 00048 void Laser::set_posy(int y) // sets the lasers's y coordinate 00049 { 00050 _y = y; 00051 }
Generated on Wed Jul 13 2022 09:05:52 by
1.7.2