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: Ball/Ball.cpp
- Revision:
- 7:a1a6bff238c1
- Parent:
- 6:3e50f2cf4366
- Child:
- 8:7b7e1a5b8200
- Child:
- 9:a81db6a703b7
--- a/Ball/Ball.cpp Thu Apr 18 09:31:52 2019 +0000 +++ b/Ball/Ball.cpp Thu Apr 18 13:04:37 2019 +0000 @@ -14,7 +14,8 @@ void Ball::init(int size,int speed) { _size = size; - + _x1=42; + _y1=3; _x = 42; _y = 15; bat.init(3,4); @@ -37,12 +38,42 @@ _velocity.y = -speed; } } - -void Ball::start(N5110 &lcd,int checkHit){ - Direction dir; - if(bowled==36 && ballHit==1){ +int Ball::bowler_start(){ + if(_y1!=15){ + _y1++; + return 0; + } + else { + return 1; + } +} +void Ball::start(N5110 &lcd,int checkHit, Direction dir){ + int ball_start_check=bowler_start(); + if (ball_start_check==1){ + printf("HELLO\n"); + if (bowled==1){ + update_ball(checkHit, dir); + } + else if (_y!=36){ + _y+=1; + } + else { + bowled=1; + } + } +} +void Ball::draw(N5110 &lcd) +{ + lcd.drawCircle(_x1,_y1,2,FILL_BLACK); + lcd.drawCircle(_x,_y,1,FILL_BLACK); + //lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); +} +void Ball::update_ball(int checkHit, Direction dir){ + if (ballHit!=1 && checkHit==1){ + ballHit=1; + } + if(bowled==1 && ballHit==1){ printf("TEST\n"); - dir=bat.get_ballDirection(); if (dir==NE){ printf("x=%i y=%i \n",_x,_y); if (!(_y == 2 )){ @@ -55,18 +86,7 @@ } } - if (ballHit!=1 && checkHit==1){ - ballHit=1; - } - printf("HELLO\n"); - if (_y!=36){ - _y+=1; - } -} -void Ball::draw(N5110 &lcd) -{ - lcd.drawCircle(_x,_y,1,FILL_BLACK); - //lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); + } void Ball::update()