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: main.cpp
- Revision:
- 10:6c6e09023942
- Parent:
- 9:a81db6a703b7
- Child:
- 11:f481ec642cc5
--- a/main.cpp Sun Apr 21 17:35:15 2019 +0000
+++ b/main.cpp Mon Apr 22 17:34:11 2019 +0000
@@ -13,12 +13,12 @@
#include "N5110.h"
#include "Ball.h"
#include "Bat.h"
+#include "Cricket.h"
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
-Gamepad pad1;
-Ball ball;
-Bat bat;
+Gamepad pad;
+Cricket cricket;
void init();
@@ -31,28 +31,31 @@
init();
// welcome();
draw();
- float f;
+ float f;
int status=0;
while(1){
+ cricket.game(lcd);
+ draw();
+ }
+ /*
+ while(1){
ball.reset();
- ball.set_field(lcd);
+ field.set_field(lcd);
+ draw();
while (status!=1){
f= pad1.get_mag();
- printf("MAG %f \n",f);
int lol=bat.get_hitBall();
- ball.start(lcd,lol,pad1.get_direction());
+ ball.start(lcd,lol,pad.get_direction());
draw();
wait(1.0f/fps);
- }
+ }
}
-
+ */
}
void init(){
lcd.init();
- pad1.init();
- bat.init(4,5);
- ball.init(2,3);
- //field.init();
+ pad.init();
+ cricket.init();
lcd.setContrast(0.4);
lcd.normalMode(); // normal colour mode
lcd.setBrightness(0.5);
@@ -66,24 +69,20 @@
lcd.printString(" Press Start ",0,4);
lcd.refresh();
// wait flashing LEDs until start button is pressed
- while ( pad1.check_event(Gamepad::START_PRESSED) == false) {
- pad1.leds_on();
+ while ( pad.check_event(Gamepad::START_PRESSED) == false) {
+ pad.leds_on();
wait(0.1);
- pad1.leds_off();
+ pad.leds_off();
wait(0.1);
}
}
void draw(){
lcd.clear();
- lcd.drawCircle((WIDTH/2),HEIGHT/2,23,FILL_TRANSPARENT);
- lcd.drawRect(37,11,12,30,FILL_TRANSPARENT);
- ball.draw(lcd);
- ball.draw_field(lcd);
- bat.draw(lcd);
+ cricket.draw(lcd);
lcd.refresh();
}
-void ball_test(){
+/*void ball_test(){
Vector2D ball_pos = ball.get_pos();
Vector2D ball_velocity = ball.get_velocity();
ball.update();
@@ -91,4 +90,5 @@
ball.set_velocity(ball_velocity);
ball.set_pos(ball_pos);
ball.update();
-}
\ No newline at end of file
+}
+*/
\ No newline at end of file