home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 February / VPR9702A.ISO / FFILLY / NVM61028 / NVMAZE.TFY < prev    next >
Text File  |  1996-10-27  |  13KB  |  608 lines

  1. // NvMaze.tfy
  2. // 
  3. // Nervous Maze ver.96.10.28
  4. // Copyright(c) 1996 Kacha
  5.  
  6. #info INAM "Nervous Maze"
  7. #info IART "Kacha"
  8. #info ICOP "(C)1996 Kacha"
  9. #info VIDO "640x400,256色"
  10. #info IGNR "joy"
  11. #info MDFY "Ask me"
  12. #info TRNS "Ask me"
  13. #info JINT "Ask me"
  14. #info GRPC "Kacha.VER04011@niftyserve.or.jp"
  15. #info VOIC "Kacha.VER04011@niftyserve.or.jp"
  16. #info CONT "Kacha.VER04011@niftyserve.or.jp"
  17. #info PROD "Kacha.VER04011@niftyserve.or.jp"
  18.  
  19. #include "NmWnd.tfy"
  20. #include "NmBtn.tfy"
  21.  
  22. #define CUR_X    48
  23. #define CUR_Y    20
  24.  
  25. #define COLOR_WALL 0x00FFFF
  26. #define COLOR_GOAL 0x0000FF
  27. #define COLOR_START 0xFF0000
  28.  
  29. int picCurCast;
  30. int nShowCur, nMapCast, nCurCast;
  31. int picMap, picExplosion, picGoal, picTimeOut;
  32. int picMessageBase, picTimeBase, picScoreBase, picTime, picScore;
  33. int wavStart1, wavStart2, wavGoal, wavExplosion;
  34.  
  35. str ScoreRankName[];
  36. int ScoreRankScore[];
  37. int ScoreRankStage[];
  38. str sIniFileName;
  39.  
  40. int nLife, nLeftTime, nScore, nStage, nStages;
  41.  
  42. main()
  43. {
  44.     OpenMainWindow();
  45.     InitializeButton();
  46.     Initialize();
  47.     ShowTitle();
  48. }
  49.  
  50. ShowTitle()
  51. {
  52.     int btnStart, btnQuit, btnRecords;
  53.     SetFont(50,"Times New Roman",0,0,0,0,400,1);
  54.     TextColor(200, 200, 255);
  55.     TextWrite("Nervous Maze", picMainWnd, 190, 100);
  56.     SetFont(18,"Times New Roman",0,0,0,0,400,0);
  57.     TextColor(255, 255, 255);
  58.     TextWrite("Copyright (c) 1996 Kacha", picMainWnd, 450, 370);
  59.     btnStart = MakeButton("START", 44, 250, 270, 140);
  60.     btnRecords = MakeButton("RECORDS", 34, 250, 300, 140);
  61.     btnQuit = MakeButton("QUIT", 51, 250, 330, 140);
  62.     mes (USER) {
  63.         DeleteAllButtons();
  64.         if (MesP2 == btnStart) {
  65.             Game();
  66.         } else if (MesP2 == btnRecords) {
  67.             ShowRanking(-1);
  68.             mes (USER) {
  69.                 MovePic(picScreen, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, picMainWnd);
  70.                 ShowTitle();
  71.                 del_me;
  72.             }
  73.         } else if (MesP2 == btnQuit) {
  74.             PostMes(RBDOWN);
  75.         }
  76.         del_me;
  77.     }
  78. }
  79.  
  80. Initialize()
  81. {
  82.     SetFont(16,"MS Sans Serif",0,0,0,0,400,0);
  83.     TextColor(255, 255, 255);
  84.     TextWrite("Now Loading...", picMainWnd, 275, 250);
  85.     picMap = CreateNewScreen();
  86.     
  87.     // ピクチャー作成
  88.     // 自分の玉
  89.     picCurCast = CreatePic(picDummy, 5, 5);
  90.     MovePic(picDummy, CUR_X, CUR_Y, 5, 5, picCurCast);
  91.     // 爆発
  92.     picExplosion = LoadPic("Explosn.bmp");
  93.     // "GOAL!"
  94.     picGoal = LoadPic("Goal.bmp");
  95.     // "TIME UP!"
  96.     picTimeOut = LoadPic("TimeUp.bmp");
  97.     // メッセージ表示領域
  98.     picMessageBase = CreatePic(picMap, 160, 80);
  99.     MovePic(picMap, 480, 320, 160, 80, picMessageBase);
  100.     picTimeBase = CreatePic(picMap, 80, 16);
  101.     MovePic(picMap, 570, 50, 80, 16, picTimeBase);
  102.     picTime = CreatePic(picMap, 80, 16);
  103.     MovePic(picTimeBase, 0, 0, 80, 16, picTime);
  104.     picScoreBase = CreatePic(picMap, 80, 16);
  105.     MovePic(picMap, 570, 70, 80, 16, picScoreBase);
  106.     picScore = CreatePic(picMap, 80, 16);
  107.     MovePic(picScoreBase, 0, 0, 80, 16, picScore);
  108.     // 音声読み込み
  109.     wavStart1 = LoadRsc("Start1.wav");
  110.     wavStart2 = LoadRsc("Start2.wav");
  111.     wavGoal = LoadRsc("Goal.wav");
  112.     wavExplosion = LoadRsc("Explosn.wav");
  113.     
  114.     sIniFileName = "NvMaze.ini";
  115.     nShowCur = 1;
  116.     mes (RBDOWN) {
  117.         if (nShowCur == 0)
  118.             ShowCur(1);
  119.         IniSave();
  120.         ExitTitle();
  121.     }
  122.     nStages = 4;
  123.     mes (USER) {
  124.         if (MesP1 == -1) {
  125.             if (MesP2 == 1) {
  126.                 Map("map01.bmp", 50, 45, 25);
  127.             } else if (MesP2 == 2) {
  128.                 Map("map02.bmp", 40, 366, 30);
  129.             } else if (MesP2 == 3) {
  130.                 Map("map03.bmp", 353, 165, 40);
  131.             } else if (MesP2 == 4) {
  132.                 Map("map04.bmp", 29, 28, 80);
  133.             }
  134.         }
  135.     }
  136.     IniLoad();
  137.     DrawTexture(picMainWnd);
  138. }
  139.  
  140. Game()
  141. {
  142.     nLife = 2;
  143.     nScore = 0;
  144.     nStage = 1;
  145.     PostMes(USER, -1, nStage);
  146. }
  147.  
  148. str GetTimeStr()
  149. {
  150.     return StrPrint("%.3ld", nLeftTime);
  151. }
  152.  
  153. ShowCurrentTime()
  154. {
  155.     MovePic(picTimeBase, 0, 0, 80, 16, picTime);
  156.     TextWrite(GetTimeStr(), picTime, 0, 0);
  157.     MovePic(picTime, 0, 0, 80, 16, picMainWnd, 570, 70);
  158. }
  159.  
  160. str GetScoreStr()
  161. {
  162.     return StrPrint("%.5ld", nScore);
  163. }
  164.  
  165. str GetStageStr()
  166. {
  167.     return StrPrint("STAGE %ld", nStage);
  168. }
  169.  
  170. ShowCurrentScore()
  171. {
  172.     MovePic(picScoreBase, 0, 0, 80, 16, picScore);
  173.     TextWrite(GetScoreStr(), picScore, 0, 0);
  174.     MovePic(picScore, 0, 0, 80, 16, picMainWnd, 570, 90);
  175. }
  176.  
  177. ShowLife(int pic)
  178. {
  179.     int i;
  180.     for (i = 0; i < nLife; i = i + 1) {
  181.         MovePic(picCurCast, 0, 0, 5, 5, pic, 570 + i * 10, 110 + 8, 0, 0);
  182.     }
  183. }
  184.  
  185. SetNormalFont()
  186. {
  187.     SetFont(20,"Times New Roman",0,0,0,0,300,0);
  188. }
  189.  
  190. Map(str map, int stx, int sty, int timelimit)
  191. {
  192.     int i;
  193.     int cl, ct;
  194.     int pic, bpic;
  195.     SetCurMode(1);
  196.     bpic = CreateBlankPicture(0);
  197.     MovePic(bpic, 0, 0, 640, 400, picMainWnd, 0, 0, 2, 50);
  198.     mes (TIME) {
  199.         step (60) {
  200.             ,
  201.             pic = LoadPic(map);
  202.             DrawTexture(picMap);
  203.             MovePic(pic, 0, 0, 460, 400, picMap);
  204.             DelPic(pic);
  205.             nLeftTime = timelimit;
  206.             TextColor(255, 255, 255);
  207.             SetNormalFont();
  208.             TextWrite(GetStageStr(), picMap, 480, 40);
  209.             TextWrite("TIME", picMap, 480, 70);
  210.             TextWrite("SCORE", picMap, 480, 90);
  211.             TextWrite("LIFE", picMap, 480, 110);
  212.             str s;
  213.             s = GetTimeStr();
  214.             TextWrite(s, picMap, 570, 70);
  215.             s = GetScoreStr();
  216.             TextWrite(s, picMap, 570, 90);
  217.             ShowLife(picMap);
  218.             
  219.             MovePic(picMap, 0, 0, 640, 400, picMainWnd, 0, 0, 2, 50);
  220.             DelPic(bpic);
  221.             mes (TIME) {
  222.                 step (60) {
  223.                     del_us;
  224.                     ,
  225.                     nMapCast = PutCast(picMap, picMainWnd, 0, 0);
  226.                     ShowMessage(0, "青色のスタート地点に");
  227.                     ShowMessage(1, "移動して下さい");
  228.                     mes (MOUSEMOVE) {
  229.                         if (MesP2 < 460 && GetColor(picMap, MesP2, MesP3) == COLOR_START) {
  230.                             ClearMessage();
  231.                             i = GetCurPos();
  232.                             cl = GetLowWord(i) - MesP2;
  233.                             ct = GetHiWord(i) - MesP3;
  234.                             Start(cl, ct, stx, sty, timelimit);
  235.                             del_me;
  236.                         }
  237.                     }
  238.                     del_me;
  239.                 }
  240.             }
  241.         }
  242.     }
  243. }
  244.  
  245. ShowMessage(int line, str s)
  246. {
  247.     SetFont(14,"MS ゴシック",128,0,0,0,400);
  248.     TextWrite(s, picMainWnd, 480, 320 + line * 20);
  249. }
  250.  
  251. ClearMessage()
  252. {
  253.     MovePic(picMessageBase, 0, 0, 160, 80, picMainWnd, 480, 320);
  254. }
  255.  
  256. SetCurMode(int m)
  257. {
  258.     if (nShowCur != m)
  259.         ShowCur(m);
  260.     nShowCur = m;
  261. }
  262.  
  263. Start(int cl, int ct, int stx, int sty, int timelimit)
  264. {
  265.     int i;
  266.     int nLastPointX, nLastPointY;
  267.     SetCurMode(0);
  268.     SetCurPos(cl + stx, ct + sty);
  269.     str s;
  270.     //s = StrPrint("<%ld,%ld,%ld,%ld>", cl, ct, stx, sty);
  271.     //TextWrite(s, picMainWnd, 2, 380);
  272.     nCurCast = PutCast(picCurCast, picMainWnd, stx - 2, sty - 2, 0);
  273.     nLastPointX = stx;
  274.     nLastPointY = sty;
  275.     ShowMessage(0, "黄色の壁にふれないで");
  276.     ShowMessage(1, "赤色のゴールを");
  277.     ShowMessage(2, "目指して下さい");
  278.     TextColor(0xFF,0xFF,0x00);
  279.     SetFont(60,"Times New Roman",0,0,0,0,400);
  280.     mes (TIME) {
  281.         SetCurPos(cl + stx, ct + sty);
  282.         step (20) {
  283.             , , , , ,
  284.             del_me;
  285.         }
  286.     }
  287.     mes (TIME) {
  288.         step (20) {
  289.             ,
  290.             ,
  291.             ClearMessage();
  292.             PlayRsc(wavStart1);
  293.             TextWrite("  3", picMainWnd, 520, 330);
  294.             ,
  295.             ClearMessage();
  296.             PlayRsc(wavStart1);
  297.             TextWrite("  2", picMainWnd, 520, 330);
  298.             ,
  299.             ClearMessage();
  300.             PlayRsc(wavStart1);
  301.             TextWrite("  1", picMainWnd, 520, 330);
  302.             ,
  303.             SetCurPos(cl + stx, ct + sty);
  304.             ClearMessage();
  305.             PlayRsc(wavStart2);
  306.             TextWrite("Go!", picMainWnd, 520, 330);
  307.             //del_us;
  308.             TextColor(0xFF, 0xFF, 0xFF);
  309.             SetNormalFont();
  310.             mes (TIME) {
  311.                 step (20) {
  312.                     ,
  313.                     ClearMessage();
  314.                     del_me;
  315.                 }
  316.             }
  317.             mes (TIME) {
  318.                 step (20) {
  319.                     nLeftTime = nLeftTime - 1;
  320.                     if (nLeftTime < 0) {
  321.                         del_us;
  322.                         TimeOut();
  323.                         del_me;
  324.                     } else {
  325.                         ShowCurrentTime();
  326.                     }
  327.                 }
  328.             }
  329.             mes (MOUSEMOVE) {
  330.                 if (MesP2 < 457) {
  331.                     MoveCast(nCurCast, picCurCast, MesP2 - 2, MesP3 - 2, 0, 5, 5, 0, 0, 0);
  332.                     if (i = HitSearch(nLastPointX, nLastPointY, MesP2, MesP3)) {
  333.                         del_us;
  334.                         if (i == 1) {
  335.                             Crash(MesP2, MesP3);
  336.                         } else if (i == 2) {
  337.                             Goal(timelimit);
  338.                         }
  339.                         del_me;
  340.                     }
  341.                     nLastPointX = MesP2;
  342.                     nLastPointY = MesP3;
  343.                 }
  344.             }
  345.             del_me;
  346.         }
  347.     }
  348. }
  349.  
  350.  
  351. Crash(int x, int y)
  352. {
  353.     int i;
  354.     PlayRsc(wavExplosion);
  355.     i = PutCast(picExplosion, picMainWnd, x - PicWidth(picExplosion) / 2,
  356.         y - PicHeight(picExplosion) / 2, 0xFFFFFF);
  357.     mes (TIME) {
  358.         step (50) {
  359.             ,
  360.             DelCast(i, 1);
  361.             DelCast(nCurCast, 1);
  362.             DelCast(nMapCast, 1);
  363.             nLife = nLife - 1;
  364.             SetCurMode(1);
  365.             if (nLife < 0) {
  366.                 ShowGameOver();
  367.             } else {
  368.                 PostMes(USER, -1, nStage);
  369.             }
  370.             del_me;
  371.         }
  372.     }
  373. }
  374.  
  375. TimeOut()
  376. {
  377.     int i;
  378.     i = PutCast(picTimeOut, picMainWnd, (WINDOW_WIDTH - PicWidth(picTimeOut)) / 2,
  379.         (WINDOW_HEIGHT - PicHeight(picTimeOut)) / 2, 0xFF0000);
  380.     mes (TIME) {
  381.         step (50) {
  382.             ,
  383.             DelCast(i, 1);
  384.             DelCast(nCurCast, 1);
  385.             DelCast(nMapCast, 1);
  386.             nLife = nLife - 1;
  387.             SetCurMode(1);
  388.             if (nLife < 0) {
  389.                 ShowGameOver();
  390.             } else {
  391.                 PostMes(USER, -1, nStage);
  392.             }
  393.             del_me;
  394.         }
  395.     }
  396. }
  397.  
  398. ShowGameOver()
  399. {
  400.     mes (USER) {
  401.         int pic;
  402.         pic = CreateBlankPicture(0);
  403.         SetFont(40,"Times New Roman",0,0,0,0,400);
  404.         TextWrite("Game Over", pic, 240, 180);
  405.         MovePic(pic, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, picMainWnd, 0, 0, 2, 50);
  406.         mes (TIME) {
  407.             step (80) {
  408.                 ,
  409.                 DrawTexture(pic);
  410.                 MovePic(pic, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, picMainWnd);
  411.                 DelPic(pic);
  412.                 ShowTitle();
  413.                 del_me;
  414.             }
  415.         }
  416.         del_me;
  417.     }
  418.     TestRanking();
  419. }
  420.  
  421. TestRanking()
  422. {
  423.     int i, j;
  424.     for (i = 0; i < 10; i = i + 1) {
  425.         if (nScore > ScoreRankScore[i])
  426.             break;
  427.     }
  428.     if (i >= 10) {
  429.         PostMes(USER);
  430.         return;
  431.     }
  432.     for (j = 9; j >= i; j = j - 1) {
  433.         ScoreRankScore[j + 1] = ScoreRankScore[j];
  434.         ScoreRankName[j + 1] = ScoreRankName[j];
  435.         ScoreRankStage[j + 1] = ScoreRankStage[j];
  436.     }
  437.     ScoreRankName[i] = StrInput("名前を入力してください:");
  438.     ScoreRankScore[i] = nScore;
  439.     ScoreRankStage[i] = nStage;
  440.     ShowRanking(i);
  441. }
  442.  
  443. ShowRanking(int myrank)
  444. {
  445.     int pic;
  446.     MovePic(picScreen, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, picMainWnd);
  447.     int btnOK;
  448.     btnOK = MakeButton("OK", 40, 500, 360, 100);
  449.     mes (USER) {
  450.         DeleteAllButtons();
  451.         del_me;
  452.     }
  453.     int i;
  454.     str s;
  455.     SetFont(35,"Arial",128,0,0,0,500);
  456.     TextColor(200, 200, 255);
  457.     TextWrite("RECORDS", picMainWnd, 240, 20);
  458.     SetFont(18,"Arial",128,0,0,0,600);
  459.     TextColor(255, 255, 0);
  460.     TextWrite("Name", picMainWnd, 100, 70);
  461.     TextWrite("Score", picMainWnd, 390, 70);
  462.     TextWrite("Stage", picMainWnd, 490, 70);
  463.     SetFont(18,"MS ゴシック",128,0,0,0,400);
  464.     for (i = 0; i < 10; i = i + 1) {
  465.         if (i == myrank)
  466.             TextColor(255, 127, 127);
  467.         else
  468.             TextColor(255, 255, 255);
  469.         s = StrPrint("%2ld", i + 1);
  470.         TextWrite(s, picMainWnd, 60, 100 + i * 25);
  471.         TextWrite(ScoreRankName[i], picMainWnd, 100, 100 + i * 25);
  472.         s = StrPrint("%.5ld", ScoreRankScore[i]);
  473.         TextWrite(s, picMainWnd, 390, 100 + i * 25);
  474.         if (ScoreRankStage[i] <= nStages) {
  475.             s = StrPrint("%ld", ScoreRankStage[i]);
  476.         } else {
  477.             s = "ALL CLEAR";
  478.         }
  479.         TextWrite(s, picMainWnd, 490, 100 + i * 25);
  480.     }
  481. }
  482.  
  483.  
  484. Goal(int timelimit)
  485. {
  486.     int i;
  487.     PlayRsc(wavGoal);
  488.     i = PutCast(picGoal, picMainWnd, (WINDOW_WIDTH - PicWidth(picGoal)) / 2,
  489.         (WINDOW_HEIGHT - PicHeight(picGoal)) / 2, 0xFF0000);
  490.     mes (TIME) {
  491.         step (50) {
  492.             ,
  493.             DelCast(i, 1);
  494.             DelCast(nCurCast, 1);
  495.             DelCast(nMapCast, 1);
  496.             nStage = nStage + 1;
  497.             SetCurMode(1);
  498.             nScore = nScore + nLeftTime * 10;
  499.             if (nStage > nStages) {
  500.                 ShowGameOver();
  501.             } else {
  502.                 PostMes(USER, -1, nStage);
  503.             }
  504.             del_me;
  505.         }
  506.     }
  507. }
  508.  
  509. int HitSearch(int ax1, int ay1, int ax2, int ay2)
  510. {
  511.     int dx, dy, s, st, c;
  512.     int x1, y1, x2, y2;
  513.     
  514.     x1 = ax1; y1 = ay1; x2 = ax2; y2 = ay2;
  515.     
  516.     c = 0;
  517.     dx = x2 - x1;
  518.     if (dx < 0) dx = -dx;
  519.     dy = y2 - y1;
  520.     if (dy < 0) dy = -dy;
  521.     if (dx > dy) {
  522.         if (x1 > x2) {
  523.             if (y1 > y2) st = 1; else st = -1;
  524.             s = x1; x1 = x2; x2 = s; y1 = y2;
  525.         } else {
  526.             if (y1 < y2) st = 1; else st = -1;
  527.         }
  528.         if ((c = HitPoint(x1, y1)) == 1) {
  529.             return 1;
  530.         }
  531.         s = dx / 2;
  532.         while (1) {
  533.             x1 = x1 + 1;
  534.             if (x1 > x2)
  535.                 break;
  536.             s = s - dy;
  537.             if (s < 0) {
  538.                 s = s + dx; y1 = y1 + st;
  539.             }
  540.             if ((c = HitPoint(x1, y1)) == 1) {
  541.                 return 1;
  542.             }
  543.         }
  544.     } else {
  545.         if (y1 > y2) {
  546.             if (x1 > x2) st = 1; else st = -1;
  547.             s = y1; y1 = y2; y2 = s; x1 = x2;
  548.         } else {
  549.             if (x1 < x2) st = 1; else st = -1;
  550.         }
  551.         if ((c = HitPoint(x1, y1)) == 1) {
  552.             return 1;
  553.         }
  554.         s = dy / 2;
  555.         while (1) {
  556.             y1 = y1 + 1;
  557.             if (y1 > y2)
  558.                 break;
  559.             s = s - dx;
  560.             if (s < 0) {
  561.                 s = s + dy; x1 = x1 + st;
  562.             }
  563.             if ((c = HitPoint(x1, y1)) == 1) {
  564.                 return 1;
  565.             }
  566.         }
  567.     }
  568.     return c;
  569. }
  570.  
  571. int HitPoint(int x, int y)
  572. {
  573.     int c;
  574.     c = GetColor(picMap, x, y);
  575.     if (c == COLOR_WALL)
  576.         c = 1;
  577.     else if (c == COLOR_GOAL)
  578.         c = 2;
  579.     else
  580.         c = 0;
  581.     return c;
  582. }
  583.  
  584. IniSave()
  585. {
  586.     int i;
  587.     str section;
  588.     for (i = 0; i < 10; i = i + 1) {
  589.         section = StrPrint("Record%ld", i);
  590.         WriteIniStr(section, "Name", ScoreRankName[i], sIniFileName);
  591.         WriteIniInt(section, "Score", ScoreRankScore[i], sIniFileName);
  592.         WriteIniInt(section, "Stage", ScoreRankStage[i], sIniFileName);
  593.     }
  594. }
  595.  
  596. IniLoad()
  597. {
  598.     int i;
  599.     str section;
  600.     for (i = 0; i < 10; i = i + 1) {
  601.         section = StrPrint("Record%ld", i);
  602.         ScoreRankName[i] = GetIniStr(section, "Name", "--------", sIniFileName);
  603.         ScoreRankScore[i] = GetIniInt(section, "Score", 0, sIniFileName);
  604.         ScoreRankStage[i] = GetIniInt(section, "Stage", 1, sIniFileName);
  605.     }
  606. }
  607.  
  608.