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: shot/shot.cpp
- Revision:
- 15:3571beaaeed8
- Parent:
- 13:eb60628db8bf
- Child:
- 16:cf2bfada3adf
--- a/shot/shot.cpp Fri May 15 08:04:39 2020 +0000
+++ b/shot/shot.cpp Fri May 15 12:21:45 2020 +0000
@@ -74,7 +74,7 @@
}
-void shot::update(N5110 &lcd)
+void shot::update()
{
for (std::vector<shot_posandtype>::iterator i = _p.begin(); i < _p.end(); i++) {
if ((*i).dir == 0) {
@@ -97,11 +97,6 @@
(*i).y +=1;//SW
}
}
- // delete invalid shots
- delete_shot();
- //generate shot to keep constant number of shots
- update_shot();
- draw(lcd);
}
void shot::update_shot()
@@ -118,6 +113,11 @@
void shot::draw(N5110 &lcd)
{
+ update();
+ // delete invalid shots
+ delete_shot();
+ //generate shot to keep constant number of shots
+ update_shot();
for (std::vector<shot_posandtype>::iterator i = _p.begin(); i < _p.end(); i++) {
lcd.drawSprite((*i).x,(*i).y,3,3,(int*)shots[(*i).type]);
//printf("coordinate = %d,%d\n",(*i).x,(*i).y);
@@ -161,8 +161,28 @@
_size = size;
}
+void shot::set_shot(int x, int y, int type, int Direction)
+{
+ for (std::vector<shot_posandtype>::iterator i = _p.begin(); i < _p.end(); i++){
+ (*i).x = x;
+ (*i).y = y;
+ (*i).type = type;
+ (*i).dir = Direction;
+ }
+}
int shot::get_size()
{
return _size;
}
+
+Vector2D shot::get_shot()
+{
+ for (std::vector<shot_posandtype>::iterator i = _p.begin(); i < _p.end(); i++){
+ _shot_pos.x =(*i).x;
+ _shot_pos.y =(*i).y;
+ }
+ return _shot_pos;
+}
+
+
\ No newline at end of file