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
Ball/Ball.cpp
- Committer:
- shahidsajid
- Date:
- 2019-04-23
- Revision:
- 13:924891519a95
- Parent:
- 12:954da4f4e565
- Child:
- 14:122eaa3b7a50
File content as of revision 13:924891519a95:
#include "Ball.h" Ball::Ball() { } Ball::~Ball() { } void Ball::init(int size,int speed) { _size = size; _x1=42; _y1=3; _x = 42; _y = 15; bat.init(3,4); bowled=0; } Vector2D Ball::get_pos() { Vector2D p = {_x,_y}; return p; } void Ball::set_pos(Vector2D p) { _x = p.x; _y = p.y; } int Ball::bowler_start(){ if(_y1!=15){ _y1+=1; return 0; } else { return 1; } } int Ball::ball_start(){ int bowler_start_check=bowler_start(); if (bowler_start_check==1){ if (_y!=36){ _y+=1; return 0; } else{ bowled=1; return 1; } } } void Ball::draw(N5110 &lcd) { lcd.drawCircle(_x1,_y1,2,FILL_TRANSPARENT); lcd.drawCircle(_x,_y,2,FILL_BLACK); //lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); } void Ball::update_ball_y(int expected_y){ if (_y!=expected_y){ printf("IN HERE \n"); if (_y>expected_y){ printf("MADE IT \n"); _y--; } else{ _y++; } } } void Ball::update_ball_x(int expected_x){ if (_x!=expected_x){ if (_x>expected_x){ _x--; } else{ _x++; } } } void Ball::reset(){ bowled=0; ballHit=0; }