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
main.cpp
- Committer:
- el17cr
- Date:
- 2019-05-06
- Revision:
- 6:85314a3d69cd
- Parent:
- 5:1a9d84df7207
- Child:
- 7:cf469c3505a2
File content as of revision 6:85314a3d69cd:
/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name:
Username:
Student ID Number:
Date:
*/
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Falldown.h"
//#define GROUND_WIDTH 70
#define GROUND_HEIGHT 2
//#define GROUND_WIDTH 50
#define BALL_SIZE 3
//#define LINE_HEIGHT 1
//#define LINE_WIDTH WIDTH
int ground_width = 40;
double ground_speed = 0.5;
int level = 1;
struct UserInput {
Direction d;
float mag;
};
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // K64F - pwr from 3V3
Gamepad pad;
Falldown falldown;
void init();
void update_game(UserInput input);
void render();
void Level();
void welcome();
int main()
{
init();
welcome();
//Level();
render();
wait(0.1);
while (1) {
falldown.read_input(pad);
falldown.update(pad);
render();
wait(0.1);
if (falldown.check_goal() == 1) {
//falldown.read_input(pad);
//falldown.update(pad);
//render();
level = level++;
ground_width = ground_width + 2;
ground_speed = ground_speed + 0.2;
falldown.init(GROUND_HEIGHT,ground_width,BALL_SIZE,ground_speed);
//ground_width = ground_width + 10;
wait(0.1);
//clear lines
//redraw lines
}
}
/*while (falldown.check_goal == 1) {
falldown.init(GROUND_HEIGHT,BALL_SIZE);
wait(0.1);*/
}
void init()
{
lcd.init();
pad.init();
falldown.init(GROUND_HEIGHT,ground_width,BALL_SIZE,ground_speed);
}
void render()
{
lcd.clear();
falldown.draw(lcd);
char buffer[1];
sprintf(buffer,"%2d",level);
lcd.printString(buffer,1,1);
lcd.refresh();
}
/*
void Level()
{
int level = 1;
char buffer[14];
sprintf(buffer,"%2d",level);
lcd.printString(buffer,0,0);
}
*/
void welcome()
{
lcd.printString("Falldown",0,1);
lcd.printString("Press Start",0,4);
lcd.refresh();
while ( pad.check_event(Gamepad::START_PRESSED) == false) {
pad.leds_on();
wait(0.1);
pad.leds_off();
wait(0.1);
}
}