Trevor Martin / PokitWars

Dependencies:   PokittoLib

Revision:
7:91365e9ad8c6
Parent:
6:2b8e70d68247
Child:
8:976e983ce79a
diff -r 2b8e70d68247 -r 91365e9ad8c6 wars.cpp
--- a/wars.cpp	Sun Dec 10 04:47:05 2017 +0000
+++ b/wars.cpp	Sun Dec 10 15:43:25 2017 +0000
@@ -9,6 +9,24 @@
 Pokitto::Display disp;
 Pokitto::Buttons btn;
 
+void splashScreen(const uint8_t * bitmap, uint16_t time) {
+    disp.bgcolor = 3;
+    disp.clear();
+    disp.drawBitmap(0, 0, bitmap);
+    disp.setColor(15);
+    disp.print(0,88-32,"TRELEMAR");
+    //game.wait(time);
+    for (int i=0;i<16;i++) {disp.palette[i]=0;}
+    disp.update();
+    for (int i=0;i<80;i++) {
+        for (int c = 0;c<16;c++) {
+            disp.palette[c]=disp.interpolateColor(disp.palette[c],sprite_pal[c],80);
+        }
+        disp.update();
+        game.wait(10);
+    }
+}
+
 void init_dark_palette() {
     for (uint8_t c=1;c<15;c++) {
         dark_pal[c] = disp.interpolateColor(sprite_pal[c], sprite_pal[0], 100);
@@ -141,6 +159,11 @@
     map_y = cursor_y - 2;
 }
 
+static void print(char text[], uint8_t color) {
+    disp.setColor(color);
+    disp.print(text);
+}
+
 static void printb(int x, int y, int text) {
     disp.setColor(0);
     disp.print(x,y-1,text);
@@ -374,6 +397,8 @@
     disp.setColor(0);
     disp.fillRoundRect(1,y,SW-2,88-67,3);
     if (!base) return;
+    disp.setColor(15);
+    disp.print(4, y, (int)selected_task);
 }
 
 void DrawSelectedHeroUI(Hero * h, int y) {
@@ -483,8 +508,13 @@
 };
 
 void loadTileMap(char * filename) {
+    disp.enableDirectPrinting(true);
     disp.fillLCD(disp.palette[0]);
     disp.directBitmap(110-16,176/2-16,sprites[72],4,2);
+    disp.directbgcolor = disp.palette[0];
+    disp.fontSize = 2;
+    disp.directcolor = disp.palette[15];
+    disp.print(2,164,"LOADING CONTENT");
     int inc = 220/144;
     #ifdef POK_SIM
         game.wait(20);
@@ -492,8 +522,14 @@
 
     pokInitSD();
     int success = fileOpen(filename,FILE_MODE_BINARY);
+    if (!isThisFileOpen(filename)) {
+        disp.directcolor = disp.palette[6];
+        disp.print(0,16,"SD LOADING ERROR");
+        while (!btn.aBtn()) {
+            game.wait(100);
+        }
+    }
     for (int i = 0; i<144; i++) {
-        if (success==FILE_MODE_FAILED) break;
         int x = i%MAP_WIDTH;
         int y = (i-x)/MAP_WIDTH;
         //fileSetPosition(i);
@@ -504,6 +540,7 @@
         disp.directRectangle(inc*(i*2),0,inc,8,disp.palette[15]);
     }
     fileClose();
+    disp.enableDirectPrinting(false);
 }
 
 void saveTileMap() {
@@ -756,7 +793,7 @@
                 disp.clear();
                 disp.print("LOADING");
                 pokInitSD();
-                //loadTileMap("file_out.war");
+                loadTileMap("file_out.war");
                 State = MAIN;
                 break;
             case (2):   //OPTIONS
@@ -848,6 +885,8 @@
     //Hero * cursor_hero = NULL;
     //Hero * current_hero = NULL;
 
+    splashScreen(sprites[0], 1000);
+
     while (game.isRunning()) {
         if (game.update()) {
             switch (State) {
@@ -980,6 +1019,9 @@
                 else if (current_hero&&current_task==TASK_NONE) {
                         tTrans.enabled=false; current_hero = NULL; //UNSELECT HERO.
                 }
+                else if (current_base&&current_task==TASK_NONE) {
+                        tTrans.enabled=false; current_base = NULL; //UNSELECT BASE
+                }
             }
             if (btn.pressed(BTN_C)&& !current_hero) {
                 //heros.push_back(Hero(cursor_x,cursor_y,0,0));