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
Fork of ll14zs by
Diff: main.cpp
- Revision:
- 2:5d3aac7fd3df
- Parent:
- 1:4f9586b828c9
--- a/main.cpp Thu Apr 26 16:25:37 2018 +0000
+++ b/main.cpp Tue May 08 11:15:58 2018 +0000
@@ -7,34 +7,38 @@
Date: 01/04/2018
*/
-///////// pre-processor directives ////////
+// Pre-Processor Directives //
+
#include "mbed.h"
+#include "N5110.h"
#include "Gamepad.h"
-#include "N5110.h"
-#include "PongEngine.h"
+#include "DashEngine.h"
+#include "Tone.h"
-#define PADDLE_WIDTH 2
-#define PADDLE_HEIGHT 8
-#define BALL_SIZE 2
-#define BALL_SPEED 3
+#define BALL_WIDTH 3
+#define BALL_HEIGHT 3
+int FLOOR_WIDTH;
+#define FLOOR_HEIGHT 1
+#define _X 3
+#define _Y 3
-/////////////// structs /////////////////
+// structs //
struct UserInput {
Direction d;
float mag;
};
-/////////////// objects ///////////////
-N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+// Objects //
Gamepad pad;
-PongEngine pong;
-///////////// prototypes ///////////////
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+//FallEngine fall;
+// Prototypes //
void init();
-void update_game(UserInput input);
void render();
void welcome();
-///////////// functions ////////////////
-int main()
-{
+void update_game(UserInput input);
+//Functions//
+int main() {
+
int fps = 8; // frames per second
init();
@@ -44,37 +48,50 @@
wait(1.0f/fps);
// game loop - read input, update the game state and render the display
- while (1) {
- pong.read_input(pad);
- pong.update(pad);
+
+ while(1) {
+ // fall.read_input(pad);
+ // fall.update(pad,lcd);
render();
wait(1.0f/fps);
+
}
}
-
-void init()
+ void init()
{
// need to initialise LCD and Gamepad
lcd.init();
pad.init();
// initialise the game
- pong.init(PADDLE_WIDTH,PADDLE_HEIGHT,BALL_SIZE,BALL_SPEED);
-
+ // fall.init(BALL_WIDTH,BALL_HEIGHT,FLOOR_HEIGHT,_X,_Y);
+
}
void render()
{
// clear screen, re-draw and refresh
lcd.clear();
- pong.draw(lcd);
+ // fall.draw(lcd,pad);
lcd.refresh();
}
+void flash() // Produce a brief flash on screen
+{
+ lcd.inverseMode();
+ wait(0.5);
+ lcd.normalMode();
+}
+
void welcome() {
- lcd.printString(" Pong! ",0,1);
- lcd.printString(" Press Start ",0,4);
+ lcd.printString(" DASH! ",0,0);
+ wait(0.5);
+ lcd.printString(" Zeshaan ",0,2);
+ wait(0.5);
+ lcd.printString(" Saeed ",0,3);
+ wait(0.5);
+ lcd.printString(" Press Start ",0,5);
lcd.refresh();
// wait flashing LEDs until start button is pressed
@@ -85,4 +102,5 @@
wait(0.1);
}
-}
\ No newline at end of file
+}
+
