A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.

Dependencies:   mbed MotionSensor

Revision:
5:75b6cb06372a
Parent:
4:d1aeb131e533
Child:
6:104c2506237e
--- a/main.cpp	Mon Apr 15 02:28:55 2019 +0000
+++ b/main.cpp	Mon Apr 15 03:05:40 2019 +0000
@@ -9,60 +9,16 @@
 */
 
 #include "main.h"
-N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
-Gamepad gamepad;
-
-bool matrix_collision_test(int pos_x, int pos_y, int map_no, int width, int length){
-    for (int j = pos_y; j < pos_y+length; j++){
-        for(int i = pos_x; i < pos_x+width; i++){
-            if ((j>=48) || (i>=84) || (j<0) || (i<0)) {
-            }
-            else if ((level_map[0][j][i] == 1)) {
-                return false;
-            }
-        }
-    }
-    return true;
-}
 
 int main()
 {
     lcd.init();
     lcd.setContrast(0.45);
     gamepad.init();
-    
-    float player_pos[2] = {39,27};
-    float future_player_pos[2] = {39,27};
-    int face = 2;
-    int counter = 0;
 
     while(1){
         
-        Vector2D mapped_coord = gamepad.get_mapped_coord();
-        future_player_pos[0] = player_pos[0] + mapped_coord.x/2;
-        future_player_pos[1] = player_pos[1] - mapped_coord.y/2;
-        if(matrix_collision_test(future_player_pos[0], player_pos[1], 0, 6, 5)){
-            player_pos[0] = future_player_pos[0];
-        }
-        if(matrix_collision_test(player_pos[0], future_player_pos[1], 0, 6, 5)){
-            player_pos[1] = future_player_pos[1];
-        }
-        moving = false;
-        if (abs(mapped_coord.x) + abs(mapped_coord.y) > 0.1f){
-            moving = true;
-            if (mapped_coord.y < 0 && abs(mapped_coord.y) > abs(mapped_coord.x)){
-                face = 2;
-            }
-            else if (mapped_coord.y > 0 && abs(mapped_coord.y) > abs(mapped_coord.x)){
-                face = 0;
-            }
-            else if (mapped_coord.x > 0 && abs(mapped_coord.x) > abs(mapped_coord.y)){
-                face = 1;
-            }
-            else if (mapped_coord.x < 0 && abs(mapped_coord.x) > abs(mapped_coord.y)){
-                face = 3;
-            }
-        }
+        move_player();
         
         lcd.clear();
         lcd.drawSprite(0,0,48,84,(int *)level_map[1]);