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: Touch/Touch.cpp
- Revision:
- 8:5f0190b282f7
- Parent:
- 7:f61ac963eb07
- Child:
- 9:a8420b353bb0
--- a/Touch/Touch.cpp Fri May 29 02:55:37 2020 +0000
+++ b/Touch/Touch.cpp Fri May 29 03:12:14 2020 +0000
@@ -25,7 +25,7 @@
void Touch::draw(N5110 &lcd)
{
- Vector2D bullet_pos = _bullet.get_pos(); //bullet position
+ Vector2D bullet_pos = _bullet.get_pos(); //bullet position data
/* s=0;
if((bullet_pos.y >= 0)&&(bullet_pos.y <= 24))
{
@@ -50,24 +50,21 @@
}
lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT); // draw a platform for game
print_scores(lcd);
- _board.draw(lcd);
- _bullet.draw(lcd);
+ _board.draw(lcd); // draw a board for game
+ _bullet.draw(lcd); // draw a bullet for game
}
void Touch::update(Gamepad &pad,N5110 &lcd)
{
- check_goal(pad);
- // important to update Boards and ball before checking collisions so can
- // correct for it before updating the display
+ drop(pad);
_board.update(_d,_mag);
- //_p2.update(_d,_mag);
_bullet.update(lcd);
- check_wall_collision(pad);
- check_Board_collisions(pad,lcd);
+ Boundary_touch(pad);
+ Board_touch(pad,lcd);
}
-void Touch::check_wall_collision(Gamepad &pad)
+void Touch::Boundary_touch(Gamepad &pad)
{
// read current ball attributes
Vector2D bullet_pos = _bullet.get_pos();
@@ -100,7 +97,7 @@
_bullet.set_pos(bullet_pos);
}
-void Touch::check_Board_collisions(Gamepad &pad,N5110 &lcd)
+void Touch::Board_touch(Gamepad &pad,N5110 &lcd)
{
Vector2D bullet_pos = _bullet.get_pos();
Vector2D bullet_velocity = _bullet.get_velocity();
@@ -134,7 +131,7 @@
_bullet.set_pos(bullet_pos);
}
-void Touch::check_goal(Gamepad &pad)
+void Touch::drop(Gamepad &pad)
{
Vector2D bullet_pos = _bullet.get_pos();
@@ -166,7 +163,4 @@
char buffer1[14];
sprintf(buffer1,"%2d",p1_score);
lcd.printString(buffer1,WIDTH/2 - 20,1); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
- char buffer2[14];
- sprintf(buffer2,"%2d",p2_score);
- lcd.printString(buffer2,WIDTH/2 + 4,1);
}
\ No newline at end of file