Trevor Martin / PokitWars

Dependencies:   PokittoLib

Revision:
8:976e983ce79a
Parent:
7:91365e9ad8c6
Child:
9:682f31473b25
--- a/wars.cpp	Sun Dec 10 15:43:25 2017 +0000
+++ b/wars.cpp	Mon Dec 11 02:00:10 2017 +0000
@@ -1,5 +1,7 @@
 #include "Pokitto.h"
 #include "warsprites.h"
+#include "hero_sprites.h"
+#include "ui_sprites.h"
 uint16_t dark_pal[16];
 #include "warfont.cpp"
 #include <vector>
@@ -9,12 +11,15 @@
 Pokitto::Display disp;
 Pokitto::Buttons btn;
 
-void splashScreen(const uint8_t * bitmap, uint16_t time) {
+#define SW disp.width
+#define SH disp.height
+
+void splashScreen(const uint8_t * bitmap, char * name, uint16_t time) {
     disp.bgcolor = 3;
     disp.clear();
-    disp.drawBitmap(0, 0, bitmap);
+    disp.drawBitmap(SW/2 -(*bitmap/2), SH/2 - (*bitmap/2), bitmap);
     disp.setColor(15);
-    disp.print(0,88-32,"TRELEMAR");
+    disp.print(SW/2- ((strlen(name)*6)/2),88-32,name);
     //game.wait(time);
     for (int i=0;i<16;i++) {disp.palette[i]=0;}
     disp.update();
@@ -24,7 +29,9 @@
         }
         disp.update();
         game.wait(10);
+        if (btn.pressed(BTN_A)) break;
     }
+    disp.load565Palette(sprite_pal);
 }
 
 void init_dark_palette() {
@@ -126,8 +133,8 @@
 #define KEY_REPEAT 5
 
 #define TASK_MOVE 0
+#define TASK_ATTACK 1
 #define TASK_ITEM 2
-#define TASK_ATTACK 1
 #define TASK_WAIT 3
 #define TASK_NONE 4
 #define TEAM_USER 0
@@ -147,9 +154,6 @@
     11,9,6,8
 };
 
-#define SW disp.width
-#define SH disp.height
-
 int map_x, map_y, cursor_x, cursor_y;
 
 bool center_cursor = true;
@@ -243,21 +247,21 @@
 };
 
 #define ID_SOLDIER 0
-#define ID_ORC 1
-#define ID_HEAVY 2
-#define ID_SNIPER 3
+#define ID_HEAVY 1
+#define ID_SNIPER 2
+#define ID_ORC 3
 
 const int sprite_ids[16] {
-    32,     //SOLDIER
-    38,     //ORC
-    34,     //HEAVY
-    36,     //SNIPER
+    0,     //SOLDIER
+    2,     //HEAVY
+    4,     //SNIPER
+    9,     //ORC
 };
 char id_names[][8] {
     {"SOLDIER"},
+    {"HEAVY"},
+    {"SNIPER"},
     {"ORC"},
-    {"HEAVY"},
-    {"SNIPER"}
 };
 char TRAITS[][8] {
     {""},
@@ -309,7 +313,7 @@
         }
         int spr_id = spr + (game.frameCount/10)%2;
         disp.invisiblecolor = 13;
-        if (draw) disp.drawBitmap((dx)+ox,(dy)+oy,sprites[spr_id], 0, flip);
+        if (draw) disp.drawBitmap((dx)+ox,(dy)+oy,hero_sprites[spr_id], 0, flip);
         disp.invisiblecolor = 12;
         if (id==ID_SNIPER&&team==TEAM_USER) {
             int lx = dx+ox+16;
@@ -426,10 +430,10 @@
     printb(16,(-y)+68,task_names[selected_task]);
 
     for (int i=0;i<4;i++) {
-        int spr = i+48;
+        int spr = i+8;
         if (!h->tasks[i]) spr-=8;
         else if (selected_task==i) spr+=8;
-        disp.drawBitmap(44+(i*16), y+4, sprites[spr]);
+        disp.drawBitmap(44+(i*16), y+4, ui_sprites[spr]);
     }
     int bw = 62;
     int hw = (bw/h->max_hp) * h->hp;
@@ -479,9 +483,9 @@
 
 void DrawTurnCounter(vector<Hero> &_heros) {
     disp.invisiblecolor = 13;
-    int spr = 44;
-    if (current_team==TEAM_CPU) spr = 45;
-    disp.drawBitmap(0, 0, sprites[spr]);
+    int spr = 32;
+    if (current_team==TEAM_CPU) spr = 33;
+    disp.drawBitmap(0, 0, ui_sprites[spr]);
     disp.invisiblecolor = 12;
     int count = 0;
     for (int i=0; i<_heros.size();i++) {
@@ -510,11 +514,11 @@
 void loadTileMap(char * filename) {
     disp.enableDirectPrinting(true);
     disp.fillLCD(disp.palette[0]);
-    disp.directBitmap(110-16,176/2-16,sprites[72],4,2);
+    disp.directBitmap(110-16,176/2-16,ui_sprites[7],4,2);
     disp.directbgcolor = disp.palette[0];
     disp.fontSize = 2;
     disp.directcolor = disp.palette[15];
-    disp.print(2,164,"LOADING CONTENT");
+    disp.print(24,164,"LOADING CONTENT");
     int inc = 220/144;
     #ifdef POK_SIM
         game.wait(20);
@@ -822,14 +826,14 @@
         disp.fillRoundRect(box_x, SH/2, 16, 16,2);
         for (int i=0; i<3; i++) {
             int x = (SW/4)*(i+1)-8;
-            int spr = 64+i;
+            int spr = 4+i;
             if (i==selected_item) {
                 box_target = x;
                 if (box_x-2<x&&box_x+2>x) {
                     box_x = x;
                 }
             }
-            disp.drawBitmap(x, SH/2, sprites[spr]);
+            disp.drawBitmap(x, SH/2, ui_sprites[spr]);
         }
         disp.bgcolor=12;
         break;
@@ -885,7 +889,7 @@
     //Hero * cursor_hero = NULL;
     //Hero * current_hero = NULL;
 
-    splashScreen(sprites[0], 1000);
+    splashScreen(sprites[0],"TRELEMAR", 1000);
 
     while (game.isRunning()) {
         if (game.update()) {