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:
- S_Tingle
- Date:
- 2019-05-08
- Revision:
- 17:ce6b54422113
- Parent:
- 16:37d98c281eb3
- Child:
- 18:ba4159ab4da7
File content as of revision 17:ce6b54422113:
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Game.h"
#include "Menu.h"
struct joystick_val {
Direction dir;
float mag;
};
Game game;
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
Smiley smiley;
Coin coin;
Enemy1 enemy1;
Menu menu;
void init();
void render();
void startScreen();
int main(){
int fps = 30;
lcd.setContrast(0.4);
lcd.setBrightness(0.5);
init();
startScreen();
//game.UI(pad,lcd);
//render();
wait(1.0f/fps);
while (1) {
game.UI(pad,lcd);
game.init();
int lives = game.get_lives();
while (lives > 0) {
render();
wait(1.0f/fps);
lives = game.get_lives();
}
}
}
void init(){
lcd.init();
pad.init();
}
void render(){
lcd.clear();
game.dirmag(pad);
game.drawSprite(lcd);
game.movement(pad,lcd);
game.collect(lcd, pad);
game.damage(lcd,pad);
game.death(lcd,pad);
lcd.refresh();
}
void startScreen(){
while (pad.check_event(Gamepad::START_PRESSED) == false) {
lcd.clear();
lcd.drawSprite(0,0,48,84,(int *)start_01);
lcd.refresh();
wait(0.5);
lcd.drawSprite(0,0,48,84,(int *)start_02);
lcd.refresh();
wait(0.5);
lcd.drawSprite(0,0,48,84,(int *)start_03);
lcd.refresh();
wait(0.5);
}
}