qiaobaaa / response3

0 stars 0 forks source link

1225 #20

Open qiaobaaa opened 6 months ago

qiaobaaa commented 6 months ago

//author: Liu Heng

include

include

include

include

include

include

include

include

include "material.h"

include "map.h"

include "mota_bin.h"

include "warrior.h"

include "monster.h"

define GFX_BL 48 // default backlight pin, you may replace DF_GFX_BL to actual backlight pin

const int yyy = 13;

Arduino_DataBus bus = new Arduino_ESP32SPI(41 / DC /, 10 / CS /, 12 / SCK /, 11 / MOSI /, GFX_NOT_DEFINED / MISO /); Arduino_ST7789 gfx = new Arduino_ST7789(bus, 42 / RST /, 0 / rotation /, true / IPS /, 240, 320, 0, 0); int rc;

/*

define SDMMC_D2 33 // SDMMC Data2

define SDMMC_D3 4 //34 // SDMMC Data3 / SPI CS

define SDMMC_CMD 5 // SDMMC CMD / SPI MOSI

define SDMMC_CLK 6 // SDMMC CLK / SPI SCK

define SDMMC_D0 7 // SDMMC Data0 / SPI MISO

define SDMMC_D1 38 // SDMMC Data1

*/

define SDMMC_D2 16 // SDMMC Data2

define SDMMC_D3 4 //34 // SDMMC Data3 / SPI CS

define SDMMC_CMD 5 // SDMMC CMD / SPI MOSI

define SDMMC_CLK 6 // SDMMC CLK / SPI SCK

define SDMMC_D0 7 // SDMMC Data0 / SPI MISO

define SDMMC_D1 15 // SDMMC Data1

int16_t h, xOffset, yOffset;

//所有游戏图片的像素指针

//商店 uint16_t shop_m; uint16_t shop_l; uint16_t *shop_r;

//@@@@@@@@@@ 敌人 //1 //初级卫兵 uint16_t gate_keeper_c; //绿史莱姆 uint16_t green_slime; //红史莱姆 uint16_t red_slime; //蝙蝠 uint16_t bat; //法师 uint16_t priest; //骷髅队长 uint16_t skeleton_a; //骷髅士兵 uint16_t skeleton_b; //骷髅人 uint16_t skeleton_c;

//2 //大史莱姆 uint16_t big_slime; //大蝙蝠 uint16_t big_bat; //石头人 uint16_t rock; //高级法师 uint16_t super_priest; //吸血鬼 uint16_t vampire; //兽人武士 uint16_t zombine_knight; //兽人 uint16_t *zombine;

//3 //中级卫兵 uint16_t gate_keeper_b; //鬼战士 uint16_t ghost_solider; //骑士队长 uint16_t gold_knight; //骑士 uint16_t knight; //幽灵 uint16_t slime_man; //战士 uint16_t solider; //双手剑士 uint16_t *swords_man;

//5 //黑暗骑士 uint16_t dark_knight; //高级卫兵 uint16_t gate_keeper_a; //高级巫师 uint16_t magician_a; //初级巫师 uint16_t magician_b; //魔法警卫 uint16_t magic_sergeant; //史莱姆王 uint16_t slime_lord; //吸血蝙蝠 uint16_t *vampire_bat;

//dragon 龙 uint16_t dragon_wn; uint16_t dragon_n; uint16_t *dragon_en;

uint16_t dragon_w; uint16_t dragon_m; uint16_t *dragon_e;

uint16_t dragon_ws; uint16_t dragon_s; uint16_t *dragon_es;

//octopus 章鱼 uint16_t octopus_wn; uint16_t octopus_n; uint16_t *octopus_en;

uint16_t octopus_w; uint16_t octopus_m; uint16_t *octopus_e;

uint16_t octopus_ws; uint16_t octopus_s; uint16_t *octopus_es;

//大魔导师 uint16_t great_magic_master; //魔王 uint16_t boss;

//.............. 特殊物品 //冰冻水晶 uint16_t snow_crystal; //幸运金币 uint16_t lucky_gold; //十字架 uint16_t cross; //传送道具 uint16_t orbof_flying; //屠龙匕首 uint16_t dragon_slayer; //向上飞行器 uint16_t wings_to_flyup; //向下飞行器 uint16_t wings_to_flydown; //中心对称飞行器 uint16_t warp_staff; //破墙镐 uint16_t mattock; //魔法钥匙 uint16_t magic_key; //炸药 uint16_t *bomb;

//............. npc //公主 uint16_t princess; //指引者 uint16_t oldman; //小偷 uint16_t thief; //商人 uint16_t merchant;

//.......... 剑的分类 //铁剑 uint16_t iron_sword; //神圣剑 uint16_t sacred_sword; //圣剑 uint16_t holy_sword; //骑士剑 uint16_t knight_sword; //银剑 uint16_t *silver_sword;

//......... 盾的分类 uint16_t iron_shield; uint16_t sacred_shield; uint16_t holy_shield; uint16_t knight_shield; uint16_t *silver_shield;

//............ 背景 //铁门 or 笼子 uint16_t iron_gate; //钢门 or 花门 uint16_t steel_gate; //熔岩 uint16_t lava; //星空 uint16_t star;

uint16_t road; uint16_t wall;

uint16_t upstair; uint16_t downstair;

uint16_t yellow_door; uint16_t red_door; uint16_t *blue_door;

uint16_t yellow_key; uint16_t red_key; uint16_t *blue_key;

uint16_t yellow_keyy; uint16_t red_keyy; uint16_t *blue_keyy;

uint16_t attack; uint16_t defend; uint16_t life; uint16_t gold;

//物品 uint16_t red_crystal; uint16_t blue_crystal; uint16_t red_elixir; uint16_t blue_elixir;

//人物CRYSTAL uint16_t people_up; uint16_t people_down; uint16_t people_right; uint16_t people_left;

//enemy

uint16_t background; uint16_t backgroundd; //uint16_t MOTA "/motaa.jpg" //uint16_t ZHUANGBEI "/zhuangbeii.jpg" //uint16_t * III "/iii.jpg"

GFXfont *f = NULL;

Warrior w;

void logMemoryy() { log_d("Used PSRAM: %d", ESP.getPsramSize()); } void logMemory() { log_d("Used PSRAM: %d", ESP.getPsramSize() - ESP.getFreePsram()); }

//void initpsarm(char file, uint16_t buffer);

void display_picture(int h, int w, uint16_t data) { for (int i = 0; i < 20; i++) { gfx->draw16bitRGBBitmap(w, i + h, data + (i 20), 20, 1); } }

void display_picture2(int h, int w, uint16_t data) { for (int i = 0; i < 20; i++) { gfx->draw16bitRGBBitmap(w, i + h, data + (i 10), 10, 1); } }

void findrole(int& prow, int& pcol) { for (prow = 1; prow <= NUM; prow++) { for (pcol = 1; pcol <= NUM; pcol++) { switch (mappp[w.getLevel()][prow][pcol]) { case 16: case 17: case 18: case 19: return; } } } }

void setup() { Serial.begin(115200); // Serial.setDebugOutput(true); // while(!Serial); Serial.println("PNG Image Viewer");

ifdef GFX_EXTRA_PRE_INIT

GFX_EXTRA_PRE_INIT();

endif

// Init Display gfx->begin();

gfx->fillScreen(BLACK); gfx->setUTF8Print(true);

ifdef GFX_BL

pinMode(GFX_BL, OUTPUT); //digitalWrite(GFX_BL, HIGH); analogWrite(GFX_BL, 180);

endif

// pinMode(SDMMC_D3 / CS /, OUTPUT); // digitalWrite(SDMMC_D3 / CS /, HIGH); //#if defined(SOC_SDMMC_USE_GPIO_MATRIX) // SD_MMC.setPins(SDMMC_CLK, SDMMC_CMD, SDMMC_D0); //#endif

if defined(SOC_SDMMC_USE_GPIO_MATRIX)

SD_MMC.setPins(SDMMC_CLK, SDMMC_CMD, SDMMC_D0, SDMMC_D1, SDMMC_D2, SDMMC_D3);

endif

if (!SD_MMC.begin("/root", true)) { //if(!FFat.begin(true)){ Serial.println("FFat Mount Failed"); return; } else { if (psramInit()) { Serial.printf("Total PSRAM: %d", ESP.getPsramSize()); Serial.println("\nPSRAM is correctly initialized"); } } //rc = png.open(PNG_FILENAME, myOpen, myClose, myRead, mySeek, PNGDraw); }

void loop() { logMemoryy(); //给所有的图片素材申请空间 shop_m = (uint16_t )ps_malloc(800); shop_l = (uint16_t )ps_malloc(800); shop_r = (uint16_t )ps_malloc(800); //@@@@@@@@@@@ 敌人 //1 gate_keeper_c = (uint16_t )ps_malloc(800); green_slime = (uint16_t )ps_malloc(800); red_slime = (uint16_t )ps_malloc(800); bat = (uint16_t )ps_malloc(800); priest = (uint16_t )ps_malloc(800); skeleton_a = (uint16_t )ps_malloc(800); skeleton_b = (uint16_t )ps_malloc(800); skeleton_c = (uint16_t *)ps_malloc(800);

//2 big_slime = (uint16_t )ps_malloc(800); big_bat = (uint16_t )ps_malloc(800); rock = (uint16_t )ps_malloc(800); super_priest = (uint16_t )ps_malloc(800); vampire = (uint16_t )ps_malloc(800); zombine_knight = (uint16_t )ps_malloc(800); zombine = (uint16_t *)ps_malloc(800);

//3 gate_keeper_b = (uint16_t )ps_malloc(800); ghost_solider = (uint16_t )ps_malloc(800); gold_knight = (uint16_t )ps_malloc(800); knight = (uint16_t )ps_malloc(800); slime_man = (uint16_t )ps_malloc(800); solider = (uint16_t )ps_malloc(800); swords_man = (uint16_t *)ps_malloc(800);

//5 dark_knight = (uint16_t )ps_malloc(800); gate_keeper_a = (uint16_t )ps_malloc(800); magician_a = (uint16_t )ps_malloc(800); magician_b = (uint16_t )ps_malloc(800); magic_sergeant = (uint16_t )ps_malloc(800); slime_lord = (uint16_t )ps_malloc(800); vampire_bat = (uint16_t *)ps_malloc(800);

//dragon 龙 dragon_wn = (uint16_t )ps_malloc(800); dragon_n = (uint16_t )ps_malloc(800); dragon_en = (uint16_t *)ps_malloc(800);

dragon_w = (uint16_t )ps_malloc(800); dragon_m = (uint16_t )ps_malloc(800); dragon_e = (uint16_t *)ps_malloc(800);

dragon_ws = (uint16_t )ps_malloc(800); dragon_s = (uint16_t )ps_malloc(800); dragon_es = (uint16_t *)ps_malloc(800);

//octopus 章鱼 octopus_wn = (uint16_t )ps_malloc(800); octopus_n = (uint16_t )ps_malloc(800); octopus_en = (uint16_t *)ps_malloc(800);

octopus_w = (uint16_t )ps_malloc(800); octopus_m = (uint16_t )ps_malloc(800); octopus_e = (uint16_t *)ps_malloc(800);

octopus_ws = (uint16_t )ps_malloc(800); octopus_s = (uint16_t )ps_malloc(800); octopus_es = (uint16_t *)ps_malloc(800);

//大魔导师 great_magic_master = (uint16_t )ps_malloc(800); //魔王 boss = (uint16_t )ps_malloc(800);

//.............. 特殊物品 snow_crystal = (uint16_t )ps_malloc(800); //幸运金币 lucky_gold = (uint16_t )ps_malloc(800); //十字架 cross = (uint16_t )ps_malloc(800); //传送道具 orbof_flying = (uint16_t )ps_malloc(800); dragon_slayer = (uint16_t )ps_malloc(800); wings_to_flyup = (uint16_t )ps_malloc(800); wings_to_flydown = (uint16_t )ps_malloc(800); warp_staff = (uint16_t )ps_malloc(800); //破墙镐 mattock = (uint16_t )ps_malloc(800); magic_key = (uint16_t )ps_malloc(800); bomb = (uint16_t *)ps_malloc(800);

//............. npc princess = (uint16_t )ps_malloc(800); oldman = (uint16_t )ps_malloc(800); thief = (uint16_t )ps_malloc(800); merchant = (uint16_t )ps_malloc(800);

//.......... 剑的分类 iron_sword = (uint16_t )ps_malloc(800); //神圣剑 sacred_sword = (uint16_t )ps_malloc(800); //圣剑 holy_sword = (uint16_t )ps_malloc(800); knight_sword = (uint16_t )ps_malloc(800); silver_sword = (uint16_t *)ps_malloc(800);

//......... 盾的分类 iron_shield = (uint16_t )ps_malloc(800); sacred_shield = (uint16_t )ps_malloc(800); holy_shield = (uint16_t )ps_malloc(800); knight_shield = (uint16_t )ps_malloc(800); silver_shield = (uint16_t *)ps_malloc(800);

//............ 背景 //铁门 or 笼子 iron_gate = (uint16_t )ps_malloc(800); //钢门 or 花门 steel_gate = (uint16_t )ps_malloc(800); //熔岩 lava = (uint16_t )ps_malloc(800); star = (uint16_t )ps_malloc(800);

road = (uint16_t )ps_malloc(800); wall = (uint16_t )ps_malloc(800);

upstair = (uint16_t )ps_malloc(800); downstair = (uint16_t )ps_malloc(800);

yellow_door = (uint16_t )ps_malloc(800); red_door = (uint16_t )ps_malloc(800); blue_door = (uint16_t *)ps_malloc(800);

yellow_key = (uint16_t )ps_malloc(800); red_key = (uint16_t )ps_malloc(800); blue_key = (uint16_t *)ps_malloc(800);

yellow_keyy = (uint16_t )ps_malloc(800); red_keyy = (uint16_t )ps_malloc(800); blue_keyy = (uint16_t *)ps_malloc(800);

attack = (uint16_t )ps_malloc(800); defend = (uint16_t )ps_malloc(800); life = (uint16_t )ps_malloc(800); gold = (uint16_t )ps_malloc(800);

//物品 red_crystal = (uint16_t )ps_malloc(800); blue_crystal = (uint16_t )ps_malloc(800); red_elixir = (uint16_t )ps_malloc(800); blue_elixir = (uint16_t )ps_malloc(800);

//人物 people_up = (uint16_t )ps_malloc(800); people_down = (uint16_t )ps_malloc(800); people_right = (uint16_t )ps_malloc(800); people_left = (uint16_t )ps_malloc(800); //2020 background = (uint16_t )ps_malloc(800); //1020 backgroundd = (uint16_t )ps_malloc(800);

//buffer = (uint16_t )heap_caps_malloc(80000, MALLOC_CAP_SPIRAM); //Serial.printf("@@@@@@ %d %f\n", sizeof(uint16_t), sizeof(byte)); //big_bat = (uint16_t )ps_malloc(400); logMemory();

// loadpsarm(SHOP_M, shop_m); //loadpsarm(SHOP_L,shop_l); //loadpsarm(SHOP_R,shop_r);

/ //@@@@@@@@@@ 敌人 //1 loadpsarm(gate_keeper_a,gate_keeper_c; //绿史莱姆 uint16_t green_slime; //红史莱姆 uint16_t red_slime; //蝙蝠 uint16_t bat; //法师 uint16_t priest; //骷髅队长 uint16_t skeleton_a; //骷髅士兵 uint16_t skeleton_b; //骷髅人 uint16_t skeleton_c; */ loadpsarm(SHOP_M, shop_m); loadpsarm(SHOP_L, shop_l); loadpsarm(SHOP_R, shop_r);

//1 loadpsarm(GATE_KEEPER_C, gate_keeper_c); loadpsarm(GREEN_SLIME, green_slime); loadpsarm(RED_SLIME, red_slime); loadpsarm(BAT, bat); loadpsarm(PRIEST, priest); loadpsarm(SKELETON_A, skeleton_a); loadpsarm(SKELETON_B, skeleton_b); loadpsarm(SKELETON_C, skeleton_c);

//2 loadpsarm(BIG_SLIME, big_slime); loadpsarm(BIG_BAT, big_bat); loadpsarm(ROCK, rock); loadpsarm(SUPER_PRIEST, super_priest); loadpsarm(VAMPIRE, vampire); loadpsarm(ZOMBINE, zombine); loadpsarm(ZOMBINE_KNIGHT, zombine_knight);

//3 loadpsarm(GATE_KEEPER_B, gate_keeper_b); loadpsarm(GHOST_SOLIDER, ghost_solider); loadpsarm(GOLD_KNIGHT, gold_knight); loadpsarm(KNIGHT, knight); loadpsarm(SLIME_MAN, slime_man); loadpsarm(SOLIDER, solider); loadpsarm(SWORDS_MAN, swords_man);

//5 loadpsarm(DARK_KNIGHT, dark_knight); loadpsarm(GATE_KEEPER_A, gate_keeper_a);

loadpsarm(MAGICIAN_A, magician_a); loadpsarm(MAGICIAN_B, magician_b);

loadpsarm(MAGIC_SERGEANT, magic_sergeant); loadpsarm(SLIME_LORD, slime_lord); loadpsarm(VAMPIRE_BAT, vampire_bat);

//dragon

loadpsarm(DRAGON_WN, dragon_wn); loadpsarm(DRAGON_N, dragon_n); loadpsarm(DRAGON_EN, dragon_en);

loadpsarm(DRAGON_W, dragon_w); loadpsarm(DRAGON_M, dragon_m); loadpsarm(DRAGON_E, dragon_e);

loadpsarm(DRAGON_WS, dragon_ws); loadpsarm(DRAGON_S, dragon_s); loadpsarm(DRAGON_ES, dragon_es);

//octopus loadpsarm(OCTOPUS_WN, octopus_wn); loadpsarm(OCTOPUS_N, octopus_n); loadpsarm(OCTOPUS_EN, octopus_en);

loadpsarm(OCTOPUS_W, octopus_w); loadpsarm(OCTOPUS_M, octopus_m); loadpsarm(OCTOPUS_E, octopus_e);

loadpsarm(OCTOPUS_WS, octopus_ws); loadpsarm(OCTOPUS_S, octopus_s); loadpsarm(OCTOPUS_ES, octopus_es);

// loadpsarm(GREAT_MAGIC_MASTER, great_magic_master); loadpsarm(BOSS, boss);

//.............. 特殊物品 //冰冻水晶 loadpsarm(SNOW_CRYSTAL, snow_crystal); loadpsarm(LUCKY_GOLD, lucky_gold); loadpsarm(CROSS, cross); loadpsarm(ORBOFFLY, orbof_flying); //屠龙匕首 loadpsarm(DRAGON_SLAYER, dragon_slayer); //向上飞行器 loadpsarm(WINGS_TO_FLYUP, wings_to_flyup); //向下飞行器 loadpsarm(WINGS_TO_FLYDOWN, wings_to_flydown); //中心对称飞行器 loadpsarm(WARP_STAFF, warp_staff); //破墙镐 loadpsarm(MATTOCK, mattock); //魔法钥匙 loadpsarm(MAGIC_KEY, magic_key); //炸药 loadpsarm(BOMB, bomb);

//............. npc //公主 loadpsarm(PRINCESS, princess); loadpsarm(OLDMAN, oldman); loadpsarm(THIEF, thief); loadpsarm(MERCHANT, merchant);

loadpsarm(IRON_SWORD, iron_sword); loadpsarm(SACRED_SWORD, sacred_sword); loadpsarm(HOLY_SWORD, holy_sword); loadpsarm(KNIGHT_SWORD, knight_sword); loadpsarm(SILVER_SWORD, silver_sword);

loadpsarm(IRON_SHIELD, iron_shield); loadpsarm(SACRED_SHIELD, sacred_shield); loadpsarm(HOLY_SHIELD, holy_shield); loadpsarm(KNIGHT_SHIELD, knight_shield); loadpsarm(SILVER_SHIELDD, silver_shield);

loadpsarm(IRONGATE, iron_gate); loadpsarm(STEEL_GATE, steel_gate); loadpsarm(LAVA, lava); loadpsarm(STAR, star);

// loadpsarm(ROAD, road); loadpsarm(WALL, wall);

loadpsarm(UPSTAIR, upstair); loadpsarm(DOWNSTAIR, downstair);

loadpsarm(YELLOWDOOR, yellow_door); loadpsarm(REDDOOR, red_door); loadpsarm(BLUEDOOR, blue_door);

loadpsarm(YELLOWKEY, yellow_key); loadpsarm(REDKEY, red_key); loadpsarm(BLUEKEY, blue_key);

loadpsarm(YELLOWKEYY, yellow_keyy); loadpsarm(REDKEYY, red_keyy); loadpsarm(BLUEKEYY, blue_keyy);

loadpsarm(ATTACK, attack); loadpsarm(DEFEND, defend); loadpsarm(LIFE, life); loadpsarm(GOLD, gold);

//物品 loadpsarm(REDCRYSTAL, red_crystal); loadpsarm(BLUECRYSTAL, blue_crystal); loadpsarm(REDELIXIR, red_elixir); loadpsarm(BLUEELIXIR, blue_elixir);

loadpsarm(PEOPLEUP, people_up); loadpsarm(PEOPLEDOWN, people_down); loadpsarm(PEOPLERIGHT, people_right); loadpsarm(PEOPLELEFT, people_left);

loadpsarm(BACKGROUND, background); loadpsarm(BACKGROUNDD, backgroundd);

//gfx->fillScreen(BLACK); unsigned long start = millis(); //gfx->fillScreen(RED); initfirstfloor(); information(); Serial.printf(" time used: %lu\n", millis() - start); / gfx->fillScreen(BLACK); for (int x = 0; x < 11; x += 20) { for (int y = 0; y < 1; y += 20) { display_picture(x, y, wall); } } //for (int i=0;i<30;i++) { // gfx->draw16bitRGBBitmap(30, i, buffer+(i30), 30, 1); // } Serial.printf(" time used: %lu\n", millis() - start); */ delay(100000000); }

void loadpsarm(char file, uint16_t buffer) { File bmpFile = SD_MMC.open(file, "r"); if (!bmpFile || bmpFile.isDirectory()) { Serial.println("ERROR: Failed to open file for reading"); } else { byte lo, hi; uint16_t tem; if (strcmp(BACKGROUNDD, file) == 0) { for (int y = 0; y < 20; y++) { bmpFile.seek(4 + (y 20)); //seek at start of line for (int x = 0; x < 10; x++) { lo = bmpFile.read(); hi = bmpFile.read(); tem = lo; tem = tem << 8; tem = tem | hi; //Serial.printf(" %d %d %x %x %x\n", y, x, lo, hi, tem); buffer[y 10 + x] = tem; } } } else { for (int y = 0; y < 20; y++) { bmpFile.seek(4 + (y 40)); //seek at start of line for (int x = 0; x < 20; x++) { lo = bmpFile.read(); hi = bmpFile.read(); tem = lo; tem = tem << 8; tem = tem | hi; //Serial.printf(" %d %d %x %x %x\n", y, x, lo, hi, tem); buffer[y 20 + x] = tem; } } } } bmpFile.close(); }

void drawmap(int floor) { for (int x = 1; x < 12; x++) { for (int y = 0; y < 13; y++) { int tem = mappp[floor][x][y]; switch (tem) { case 0: if (y == 0) { display_picture2((x - 1) 20, y 20, backgroundd); } else if (y == 12) { display_picture2((x - 1) 20, (y 20) - 10, backgroundd); } else { display_picture((x - 1) 20, (y 20) - 10, wall); } break; case 1: display_picture((x - 1) 20, (y 20) - 10, road); break; //暗墙 case 2: display_picture((x - 1) 20, (y 20) - 10, wall); break; //隐形墙 case 3: display_picture((x - 1) 20, (y 20) - 10, road); break; //岩浆 case 4: display_picture((x - 1) 20, (y 20) - 10, lava); break; //虚空 case 5: display_picture((x - 1) 20, (y 20) - 10, star); break; case 6: display_picture((x - 1) 20, (y 20) - 10, yellow_door); break; case 7: display_picture((x - 1) 20, (y 20) - 10, blue_door); break; case 8: display_picture((x - 1) 20, (y 20) - 10, red_door); break; case 9: display_picture((x - 1) 20, (y 20) - 10, iron_gate); break; case 10: display_picture((x - 1) 20, (y 20) - 10, steel_gate); break; case 11: display_picture((x - 1) 20, (y 20) - 10, upstair); break; case 12: display_picture((x - 1) 20, (y 20) - 10, downstair); break;

    case 16:
      display_picture((x - 1) * 20, (y * 20) - 10, people_up);
      break;
    case 17:
      display_picture((x - 1) * 20, (y * 20) - 10, people_down);
      break;
    case 18:
      display_picture((x - 1) * 20, (y * 20) - 10, people_left);
      break;
    case 19:
      display_picture((x - 1) * 20, (y * 20) - 10, people_right);
      break;

    case 21:
      display_picture((x - 1) * 20, (y * 20) - 10, yellow_key);
      break;
    case 22:
      display_picture((x - 1) * 20, (y * 20) - 10, blue_key);
    case 23:
      display_picture((x - 1) * 20, (y * 20) - 10, red_key);
      break;

    case 24:
      display_picture((x - 1) * 20, (y * 20) - 10, red_crystal);
      break;
    case 25:
      display_picture((x - 1) * 20, (y * 20) - 10, blue_crystal);
      break;
    case 26:
      display_picture((x - 1) * 20, (y * 20) - 10, red_elixir);
      break;
    case 27:
      display_picture((x - 1) * 20, (y * 20) - 10, blue_elixir);
      break;

    case 31:
      display_picture((x - 1) * 20, (y * 20) - 10, iron_sword);
      break;
    case 32:
      display_picture((x - 1) * 20, (y * 20) - 10, iron_shield);
      break;
    case 33:
      display_picture((x - 1) * 20, (y * 20) - 10, silver_sword);
      break;
    case 34:
      display_picture((x - 1) * 20, (y * 20) - 10, silver_shield);
      break;
    case 35:
      display_picture((x - 1) * 20, (y * 20) - 10, knight_sword);
      break;
    case 36:
      display_picture((x - 1) * 20, (y * 20) - 10, knight_shield);
      break;
    case 37:
      display_picture((x - 1) * 20, (y * 20) - 10, sacred_sword);
      break;
    case 38:
      display_picture((x - 1) * 20, (y * 20) - 10, sacred_shield);
      break;
    case 39:
      display_picture((x - 1) * 20, (y * 20) - 10, holy_sword);
      break;
    case 40:
      display_picture((x - 1) * 20, (y * 20) - 10, holy_shield);
      break;

    case 41:
      display_picture((x - 1) * 20, (y * 20) - 10, orbof_flying);
      break;
    //notebook
    case 42:
      display_picture((x - 1) * 20, (y * 20) - 10, orbof_flying);
      break;
    case 43:
      display_picture((x - 1) * 20, (y * 20) - 10, cross);
      break;
    case 44:
      display_picture((x - 1) * 20, (y * 20) - 10, mattock);
      break;
    case 45:
      display_picture((x - 1) * 20, (y * 20) - 10, bomb);
      break;
    case 46:
      display_picture((x - 1) * 20, (y * 20) - 10, warp_staff);
      break;
    case 47:
      display_picture((x - 1) * 20, (y * 20) - 10, lucky_gold);
      break;
    case 48:
      display_picture((x - 1) * 20, (y * 20) - 10, snow_crystal);
      break;
    case 49:
      display_picture((x - 1) * 20, (y * 20) - 10, wings_to_flydown);
      break;
    case 50:
      display_picture((x - 1) * 20, (y * 20) - 10, wings_to_flyup);
      break;
    case 51:
      display_picture((x - 1) * 20, (y * 20) - 10, magic_key);
      break;
    case 52:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_slayer);
      break;

    case 92:
    case 93:
    case 94:
    case 95:
    case 96:
    case 97:
    case 98:
    case 99:
    case 100:
      display_picture((x - 1) * 20, (y * 20) - 10, thief);
      break;

    case 101:
    case 102:
    case 103:
    case 104:
    case 105:
    case 106:
    case 107:
    case 108:
    case 109:
    case 110:
    case 111:
    case 112:
    case 113:
    case 114:
    case 115:
    case 116:
    case 117:
    case 118:
    case 119:
    case 120:
      display_picture((x - 1) * 20, (y * 20) - 10, oldman);
      break;

    case 131:
    case 132:
    case 133:
    case 134:
    case 135:
    case 136:
    case 137:
    case 138:
    case 139:
    case 140:
    case 141:
    case 142:
      display_picture((x - 1) * 20, (y * 20) - 10, merchant);
      break;

    case 160:
      display_picture((x - 1) * 20, (y * 20) - 10, shop_l);
      break;
    case 161:
      display_picture((x - 1) * 20, (y * 20) - 10, shop_m);
      break;
    case 162:
      display_picture((x - 1) * 20, (y * 20) - 10, shop_r);
      break;
    case 163:
    case 164:
      display_picture((x - 1) * 20, (y * 20) - 10, princess);
      break;

    case 251:
      display_picture((x - 1) * 20, (y * 20) - 10, green_slime);
      break;
    case 252:
      display_picture((x - 1) * 20, (y * 20) - 10, red_slime);
      break;
    case 253:
      display_picture((x - 1) * 20, (y * 20) - 10, bat);
      break;
    case 254:
      display_picture((x - 1) * 20, (y * 20) - 10, priest);
      break;
    case 255:
      display_picture((x - 1) * 20, (y * 20) - 10, skeleton_c);
      break;
    case 256:
      display_picture((x - 1) * 20, (y * 20) - 10, skeleton_b);
      break;
    case 257:
      display_picture((x - 1) * 20, (y * 20) - 10, gate_keeper_c);
      break;
    case 258:
      display_picture((x - 1) * 20, (y * 20) - 10, skeleton_a);
      break;
    case 259:
      display_picture((x - 1) * 20, (y * 20) - 10, big_slime);
      break;
    case 260:
      display_picture((x - 1) * 20, (y * 20) - 10, big_bat);
      break;
    case 261:
      display_picture((x - 1) * 20, (y * 20) - 10, super_priest);
      break;
    case 262:
      display_picture((x - 1) * 20, (y * 20) - 10, zombine);
      break;
    case 263:
      display_picture((x - 1) * 20, (y * 20) - 10, zombine_knight);
      break;
    case 264:
      display_picture((x - 1) * 20, (y * 20) - 10, rock);
      break;
    case 265:
      display_picture((x - 1) * 20, (y * 20) - 10, vampire);
      break;
    case 266:
      display_picture((x - 1) * 20, (y * 20) - 10, ghost_solider);
      break;
    case 267:
      display_picture((x - 1) * 20, (y * 20) - 10, solider);
      break;
    case 268:
      display_picture((x - 1) * 20, (y * 20) - 10, slime_man);
      break;
    case 269:
      display_picture((x - 1) * 20, (y * 20) - 10, gate_keeper_b);
      break;
    case 270:
      display_picture((x - 1) * 20, (y * 20) - 10, swords_man);
      break;
    case 271:
      display_picture((x - 1) * 20, (y * 20) - 10, knight);
      break;
    case 272:
      display_picture((x - 1) * 20, (y * 20) - 10, gold_knight);
      break;
    case 282:
      display_picture((x - 1) * 20, (y * 20) - 10, great_magic_master);
      break;
    case 280:
    case 281:
    case 283:
      display_picture((x - 1) * 20, (y * 20) - 10, boss);
      break;
    case 284:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_wn);
      break;
    case 285:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_n);
      break;
    case 286:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_en);
      break;
    case 287:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_w);
      break;
    case 288:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_m);
      break;
    case 289:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_e);
      break;
    case 290:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_ws);
      break;
    case 291:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_s);
      break;
    case 292:
      display_picture((x - 1) * 20, (y * 20) - 10, octopus_es);
      break;
    case 293:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_wn);
      break;//魔龙左上
    case 294:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_n);
      break;//中上
    case 295:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_en);
      break;//右上
    case 296:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_w);
      break;
    case 297:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_m);
      break;
    case 298:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_e);
      break;
    case 299:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_ws);
      break;
    case 300:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_s);
      break;
    case 301:
      display_picture((x - 1) * 20, (y * 20) - 10, dragon_es);
      break;
    case 302:
      display_picture((x - 1) * 20, (y * 20) - 10, magician_b);
      break;
    case 303:
      display_picture((x - 1) * 20, (y * 20) - 10, magician_a);
      break;//高级巫师
    case 304:
      display_picture((x - 1) * 20, (y * 20) - 10, slime_lord);
      break;
    case 305:
      display_picture((x - 1) * 20, (y * 20) - 10, vampire_bat);
      break;//吸血蝙蝠
    case 306:
      display_picture((x - 1) * 20, (y * 20) - 10, dark_knight);
      break;//黑暗骑士
    case 307:
      display_picture((x - 1) * 20, (y * 20) - 10, magic_sergeant);
      break;//魔法警卫
    case 308:
      display_picture((x - 1) * 20, (y * 20) - 10, gate_keeper_a);
      break;//高级卫兵
  }
}

} }

void initfirstfloor() {

for (int x = 1; x < 12; x++) { for (int y = 0; y < 13; y++) { int tem = mappp[1][x][y]; switch (tem) { case 0: if (y == 0) { display_picture2((x - 1) 20, y 20, backgroundd); } else if (y == 12) { display_picture2((x - 1) 20, (y 20) - 10, backgroundd); } else { display_picture((x - 1) 20, (y 20) - 10, wall); } break; case 1: display_picture((x - 1) 20, (y 20) - 10, road); break; case 6: display_picture((x - 1) 20, (y 20) - 10, yellow_door); break; case 8: display_picture((x - 1) 20, (y 20) - 10, red_door); break; case 11: display_picture((x - 1) 20, (y 20) - 10, upstair); break; case 17: display_picture((x - 1) 20, (y 20) - 10, people_down); break; case 21: display_picture((x - 1) 20, (y 20) - 10, yellow_key); break; case 22: display_picture((x - 1) 20, (y 20) - 10, blue_key); case 23: display_picture((x - 1) 20, (y 20) - 10, red_key); break; case 24: display_picture((x - 1) 20, (y 20) - 10, red_crystal); break; case 25: display_picture((x - 1) 20, (y 20) - 10, blue_crystal); break; case 26: display_picture((x - 1) 20, (y 20) - 10, red_elixir); break; case 27: display_picture((x - 1) 20, (y 20) - 10, blue_elixir); break; case 41: display_picture((x - 1) 20, (y 20) - 10, orbof_flying); break; case 251: display_picture((x - 1) 20, (y 20) - 10, green_slime); break; case 252: display_picture((x - 1) 20, (y 20) - 10, red_slime); break; case 253: display_picture((x - 1) 20, (y 20) - 10, bat); break; case 254: display_picture((x - 1) 20, (y 20) - 10, priest); break; case 255: display_picture((x - 1) 20, (y 20) - 10, skeleton_c); break; case 256: display_picture((x - 1) 20, (y 20) - 10, skeleton_b); break; } } } }

void information() {

for (int x = 0; x < 240; x += 20) { display_picture(220, x, background); } for (int x = 0; x < 130; x += 20) { display_picture(280, x, background); } display_picture(240, 0, life); display_picture(240, 70, gold); display_picture(260, 0, attack); display_picture(260, 70, defend);

display_picture(240, 135, yellow_keyy); display_picture(260, 135, blue_keyy); display_picture(280, 135, red_keyy);

displaymota(); displayzhuangbei(); }

void displaymota() { gfx->setFont(u8g2_font_unifont_t_chinese); gfx->setTextColor(WHITE); gfx->setCursor(188, 265); gfx->println("魔 塔"); gfx->setCursor(183, 290); gfx->println("第 层"); //displayfloor(); gfx->setFont(f); }

void displayzhuangbei() { gfx->setFont(u8g2_font_unifont_t_chinese); gfx->setTextColor(WHITE); gfx->setCursor(0, 315); gfx->println("装备"); gfx->setFont(f); }

qiaobaaa commented 6 months ago

case 1: //人的前面是空地 mappp[w.getLevel()][row - 1][col] = 16; mappp[w.getLevel()][row][col] = 1; display_picture2((row - 1 - 1) 20, col 20 - 10, people_up); display_picture2((row - 1) 20, col 20 - 10, road); break; case 2: //人的前面是暗墙 mappp[w.getLevel()][row - 1][col] = 1; mappp[w.getLevel()][row][col] = 16; display_picture2((row - 1 - 1) 20, col 20 - 10, people_up); display_picture2((row - 1) 20, col 20 - 10, road); break; case 3: //人的前面是(全向)隐形墙 mappp[w.getLevel()][row - 1][col] = 0; mappp[w.getLevel()][row][col] = 16; display_picture2((row - 1 - 1) 20, col 20 - 10, wall); display_picture2((row - 1) 20, col 20 - 10, people_up); break; case 5: //传送至50楼 if (w.getClevel() == 24) { int k = 26; while (k--) w.LevelUp(); } else { map[w.getLevel()][row][col] = 16; } break; case 6://遇到黄门 if (w.getYellow_Key() == 0) { map[w.getLevel()][row][col] = 16; //先画框再显示文字提示 gfx->fillRect(18, 18, 116, 86, BLACK); gfx->setFont(u8g2_font_unifont_t_chinese); gfx->setTextColor(WHITE); gfx->setCursor(188, 265); gfx->println("黄钥匙不足"); gfx->setFont(f); //然后再根据提示框范围显示原来的 //保持是一个原来图层整数范围,显示起来会容易很多 } else { map[w.getLevel()][row - 1][col] = 1; map[w.getLevel()][row][col] = 16; display_picture2((row - 1 - 1) 20, col 20 - 10, road); w.Spend_Yellow_Key(); } break; case 7://遇到蓝门 if (w.getBlue_Key() == 0) { map[w.getLevel()][row][col] = 16; Draw(); MessageBox(hwnd, _T("蓝钥匙不足"), _T("提示"), MB_OK); } else { map[w.getLevel()][row - 1][col] = 1; map[w.getLevel()][row][col] = 16; w.Spend_Blue_Key(); } break;