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:
- 6:b393cfe4e0a7
- Parent:
- 5:7207c9b70108
- Child:
- 7:f61ac963eb07
--- a/Touch/Touch.cpp Wed May 27 21:13:59 2020 +0000 +++ b/Touch/Touch.cpp Thu May 28 01:11:47 2020 +0000 @@ -10,7 +10,7 @@ } -void Touch::init(int board_width,int board_height,int bullet_size,int speed,N5110 &lcd) +void Touch::init(int board_width,int board_height,int bullet_size,int speed) { // initialise the game parameters _Board_width = board_width; @@ -23,7 +23,7 @@ _p2x = WIDTH - GAP - _Board_width; _p1y=48-board_height*0.5; // puts boards and ball in middle - _p1.init(_p1x,_p1y,_Board_height,_Board_width,lcd); + _p1.init(_p1x,_p1y,_Board_height,_Board_width); //lcd.drawRect(0,0,84,24,FILL_BLACK); _bullet.init(_p1x,board_height,_speed,_Board_height); } @@ -51,17 +51,17 @@ _bullet.draw(lcd); } -void Touch::update(Gamepad &pad,N5110 &lcd) +void Touch::update(Gamepad &pad) { check_goal(pad); // important to update boards and ball before checking collisions so can // correct for it before updating the display - _p1.update(_d,_mag,lcd); + _p1.update(_d,_mag); //_p2.update(_d,_mag); - _bullet.update(lcd); + _bullet.update(); check_wall_collision(pad); - check_Board_collisions(pad,lcd); + check_Board_collisions(pad); } void Touch::check_wall_collision(Gamepad &pad) @@ -91,7 +91,7 @@ _bullet.set_pos(bullet_pos); } -void Touch::check_Board_collisions(Gamepad &pad,N5110 &lcd) +void Touch::check_Board_collisions(Gamepad &pad) { // read current ball attributes Vector2D bullet_pos = _bullet.get_pos(); @@ -118,7 +118,7 @@ } if((bullet_pos.y >= 0)&&(bullet_pos.y <= 24)) { - lcd.drawRect(bullet_pos.x,bullet_pos.y-4,4,4,FILL_TRANSPARENT); + // lcd.drawRect(bullet_pos.x,bullet_pos.y-4,4,4,FILL_TRANSPARENT); bullet_pos.y = bullet_pos.y + _Board_width; bullet_velocity.y = -bullet_velocity.y; }