My ELEC2645 project. Nikollao Sulollari. 200804685
Dependencies: N5110 SoftPWM mbed
Diff: main.cpp
- Revision:
- 16:a6ca6858af24
- Parent:
- 15:c7af2ea5f164
- Child:
- 17:2d424db3975f
diff -r c7af2ea5f164 -r a6ca6858af24 main.cpp --- a/main.cpp Fri Apr 29 19:35:13 2016 +0000 +++ b/main.cpp Mon May 02 08:56:08 2016 +0000 @@ -6,23 +6,30 @@ #include "main.h" #include "stdlib.h" +#include "P_defines.h" +#include "hero.h" +#include "joystick.h" +#include "game.h" +#include "background.h" + int main() { lcd.init(); init_K64F(); init_serial(); + init_game(); ///initialize game - init_game(); ///initialize game calibrateJoystick(); ///calibrate joystick button.rise(&button_isr); ///assign rise with ISR button1.rise(&button1_isr); + + game_ticker.attach(&game_timer_isr,0.2); menu(); - ticker.attach(&timer_isr,0.05); ///attach ticker with ISR every 0.1 sec + game_ticker.detach(); + + ticker.attach(&timer_isr,game_speed); ///attach ticker with ISR every 0.1 sec reset = level; ///set reset = level to check later if level has increased - // buzzer.start(); - //buzzer.write(0.5); - //buzzer.period_ms(4); - + while (1) { if (g_timer_flag) { @@ -30,7 +37,9 @@ g_timer_flag = 0; ///reset flag lcd.clear(); guidance(); - hero(); + drawHero(); + moveHero(); + //hero(); enemies(); obstacles(); @@ -44,11 +53,11 @@ } pc.printf("x = %f y = %f button = %d \n",joystick.x,joystick.y,joystick.button); pc.printf("heroY = %d , heroX = %d , n = %d \n",heroY, heroX, n); + checkOverlap(); + updateJoystick(); + //callibrateJoystick(); + lcd.refresh(); } - checkOverlap(); - updateJoystick(); - //callibrateJoystick(); - lcd.refresh(); sleep(); } } @@ -70,7 +79,6 @@ left_led = 1; centre_led = 1; right_led = 1; - // since the on-board switches have external pull-ups, we should disable the internal pull-down // resistors that are enabled by default using InterruptIn @@ -113,6 +121,6 @@ void timeout_isr() { if (button) { - pc.printf("button is pressed! \n"); + pc.printf("timeout \n"); } -} \ No newline at end of file +}