home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 February
/
VPR9702A.ISO
/
FFILLY
/
NVM61028
/
NVMAZE.TFY
< prev
next >
Wrap
Text File
|
1996-10-27
|
13KB
|
608 lines
// NvMaze.tfy
//
// Nervous Maze ver.96.10.28
// Copyright(c) 1996 Kacha
#info INAM "Nervous Maze"
#info IART "Kacha"
#info ICOP "(C)1996 Kacha"
#info VIDO "640x400,256色"
#info IGNR "joy"
#info MDFY "Ask me"
#info TRNS "Ask me"
#info JINT "Ask me"
#info GRPC "Kacha.VER04011@niftyserve.or.jp"
#info VOIC "Kacha.VER04011@niftyserve.or.jp"
#info CONT "Kacha.VER04011@niftyserve.or.jp"
#info PROD "Kacha.VER04011@niftyserve.or.jp"
#include "NmWnd.tfy"
#include "NmBtn.tfy"
#define CUR_X 48
#define CUR_Y 20
#define COLOR_WALL 0x00FFFF
#define COLOR_GOAL 0x0000FF
#define COLOR_START 0xFF0000
int picCurCast;
int nShowCur, nMapCast, nCurCast;
int picMap, picExplosion, picGoal, picTimeOut;
int picMessageBase, picTimeBase, picScoreBase, picTime, picScore;
int wavStart1, wavStart2, wavGoal, wavExplosion;
str ScoreRankName[];
int ScoreRankScore[];
int ScoreRankStage[];
str sIniFileName;
int nLife, nLeftTime, nScore, nStage, nStages;
main()
{
OpenMainWindow();
InitializeButton();
Initialize();
ShowTitle();
}
ShowTitle()
{
int btnStart, btnQuit, btnRecords;
SetFont(50,"Times New Roman",0,0,0,0,400,1);
TextColor(200, 200, 255);
TextWrite("Nervous Maze", picMainWnd, 190, 100);
SetFont(18,"Times New Roman",0,0,0,0,400,0);
TextColor(255, 255, 255);
TextWrite("Copyright (c) 1996 Kacha", picMainWnd, 450, 370);
btnStart = MakeButton("START", 44, 250, 270, 140);
btnRecords = MakeButton("RECORDS", 34, 250, 300, 140);
btnQuit = MakeButton("QUIT", 51, 250, 330, 140);
mes (USER) {
DeleteAllButtons();
if (MesP2 == btnStart) {
Game();
} else if (MesP2 == btnRecords) {
ShowRanking(-1);
mes (USER) {
MovePic(picScreen, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, picMainWnd);
ShowTitle();
del_me;
}
} else if (MesP2 == btnQuit) {
PostMes(RBDOWN);
}
del_me;
}
}
Initialize()
{
SetFont(16,"MS Sans Serif",0,0,0,0,400,0);
TextColor(255, 255, 255);
TextWrite("Now Loading...", picMainWnd, 275, 250);
picMap = CreateNewScreen();
// ピクチャー作成
// 自分の玉
picCurCast = CreatePic(picDummy, 5, 5);
MovePic(picDummy, CUR_X, CUR_Y, 5, 5, picCurCast);
// 爆発
picExplosion = LoadPic("Explosn.bmp");
// "GOAL!"
picGoal = LoadPic("Goal.bmp");
// "TIME UP!"
picTimeOut = LoadPic("TimeUp.bmp");
// メッセージ表示領域
picMessageBase = CreatePic(picMap, 160, 80);
MovePic(picMap, 480, 320, 160, 80, picMessageBase);
picTimeBase = CreatePic(picMap, 80, 16);
MovePic(picMap, 570, 50, 80, 16, picTimeBase);
picTime = CreatePic(picMap, 80, 16);
MovePic(picTimeBase, 0, 0, 80, 16, picTime);
picScoreBase = CreatePic(picMap, 80, 16);
MovePic(picMap, 570, 70, 80, 16, picScoreBase);
picScore = CreatePic(picMap, 80, 16);
MovePic(picScoreBase, 0, 0, 80, 16, picScore);
// 音声読み込み
wavStart1 = LoadRsc("Start1.wav");
wavStart2 = LoadRsc("Start2.wav");
wavGoal = LoadRsc("Goal.wav");
wavExplosion = LoadRsc("Explosn.wav");
sIniFileName = "NvMaze.ini";
nShowCur = 1;
mes (RBDOWN) {
if (nShowCur == 0)
ShowCur(1);
IniSave();
ExitTitle();
}
nStages = 4;
mes (USER) {
if (MesP1 == -1) {
if (MesP2 == 1) {
Map("map01.bmp", 50, 45, 25);
} else if (MesP2 == 2) {
Map("map02.bmp", 40, 366, 30);
} else if (MesP2 == 3) {
Map("map03.bmp", 353, 165, 40);
} else if (MesP2 == 4) {
Map("map04.bmp", 29, 28, 80);
}
}
}
IniLoad();
DrawTexture(picMainWnd);
}
Game()
{
nLife = 2;
nScore = 0;
nStage = 1;
PostMes(USER, -1, nStage);
}
str GetTimeStr()
{
return StrPrint("%.3ld", nLeftTime);
}
ShowCurrentTime()
{
MovePic(picTimeBase, 0, 0, 80, 16, picTime);
TextWrite(GetTimeStr(), picTime, 0, 0);
MovePic(picTime, 0, 0, 80, 16, picMainWnd, 570, 70);
}
str GetScoreStr()
{
return StrPrint("%.5ld", nScore);
}
str GetStageStr()
{
return StrPrint("STAGE %ld", nStage);
}
ShowCurrentScore()
{
MovePic(picScoreBase, 0, 0, 80, 16, picScore);
TextWrite(GetScoreStr(), picScore, 0, 0);
MovePic(picScore, 0, 0, 80, 16, picMainWnd, 570, 90);
}
ShowLife(int pic)
{
int i;
for (i = 0; i < nLife; i = i + 1) {
MovePic(picCurCast, 0, 0, 5, 5, pic, 570 + i * 10, 110 + 8, 0, 0);
}
}
SetNormalFont()
{
SetFont(20,"Times New Roman",0,0,0,0,300,0);
}
Map(str map, int stx, int sty, int timelimit)
{
int i;
int cl, ct;
int pic, bpic;
SetCurMode(1);
bpic = CreateBlankPicture(0);
MovePic(bpic, 0, 0, 640, 400, picMainWnd, 0, 0, 2, 50);
mes (TIME) {
step (60) {
,
pic = LoadPic(map);
DrawTexture(picMap);
MovePic(pic, 0, 0, 460, 400, picMap);
DelPic(pic);
nLeftTime = timelimit;
TextColor(255, 255, 255);
SetNormalFont();
TextWrite(GetStageStr(), picMap, 480, 40);
TextWrite("TIME", picMap, 480, 70);
TextWrite("SCORE", picMap, 480, 90);
TextWrite("LIFE", picMap, 480, 110);
str s;
s = GetTimeStr();
TextWrite(s, picMap, 570, 70);
s = GetScoreStr();
TextWrite(s, picMap, 570, 90);
ShowLife(picMap);
MovePic(picMap, 0, 0, 640, 400, picMainWnd, 0, 0, 2, 50);
DelPic(bpic);
mes (TIME) {
step (60) {
del_us;
,
nMapCast = PutCast(picMap, picMainWnd, 0, 0);
ShowMessage(0, "青色のスタート地点に");
ShowMessage(1, "移動して下さい");
mes (MOUSEMOVE) {
if (MesP2 < 460 && GetColor(picMap, MesP2, MesP3) == COLOR_START) {
ClearMessage();
i = GetCurPos();
cl = GetLowWord(i) - MesP2;
ct = GetHiWord(i) - MesP3;
Start(cl, ct, stx, sty, timelimit);
del_me;
}
}
del_me;
}
}
}
}
}
ShowMessage(int line, str s)
{
SetFont(14,"MS ゴシック",128,0,0,0,400);
TextWrite(s, picMainWnd, 480, 320 + line * 20);
}
ClearMessage()
{
MovePic(picMessageBase, 0, 0, 160, 80, picMainWnd, 480, 320);
}
SetCurMode(int m)
{
if (nShowCur != m)
ShowCur(m);
nShowCur = m;
}
Start(int cl, int ct, int stx, int sty, int timelimit)
{
int i;
int nLastPointX, nLastPointY;
SetCurMode(0);
SetCurPos(cl + stx, ct + sty);
str s;
//s = StrPrint("<%ld,%ld,%ld,%ld>", cl, ct, stx, sty);
//TextWrite(s, picMainWnd, 2, 380);
nCurCast = PutCast(picCurCast, picMainWnd, stx - 2, sty - 2, 0);
nLastPointX = stx;
nLastPointY = sty;
ShowMessage(0, "黄色の壁にふれないで");
ShowMessage(1, "赤色のゴールを");
ShowMessage(2, "目指して下さい");
TextColor(0xFF,0xFF,0x00);
SetFont(60,"Times New Roman",0,0,0,0,400);
mes (TIME) {
SetCurPos(cl + stx, ct + sty);
step (20) {
, , , , ,
del_me;
}
}
mes (TIME) {
step (20) {
,
,
ClearMessage();
PlayRsc(wavStart1);
TextWrite(" 3", picMainWnd, 520, 330);
,
ClearMessage();
PlayRsc(wavStart1);
TextWrite(" 2", picMainWnd, 520, 330);
,
ClearMessage();
PlayRsc(wavStart1);
TextWrite(" 1", picMainWnd, 520, 330);
,
SetCurPos(cl + stx, ct + sty);
ClearMessage();
PlayRsc(wavStart2);
TextWrite("Go!", picMainWnd, 520, 330);
//del_us;
TextColor(0xFF, 0xFF, 0xFF);
SetNormalFont();
mes (TIME) {
step (20) {
,
ClearMessage();
del_me;
}
}
mes (TIME) {
step (20) {
nLeftTime = nLeftTime - 1;
if (nLeftTime < 0) {
del_us;
TimeOut();
del_me;
} else {
ShowCurrentTime();
}
}
}
mes (MOUSEMOVE) {
if (MesP2 < 457) {
MoveCast(nCurCast, picCurCast, MesP2 - 2, MesP3 - 2, 0, 5, 5, 0, 0, 0);
if (i = HitSearch(nLastPointX, nLastPointY, MesP2, MesP3)) {
del_us;
if (i == 1) {
Crash(MesP2, MesP3);
} else if (i == 2) {
Goal(timelimit);
}
del_me;
}
nLastPointX = MesP2;
nLastPointY = MesP3;
}
}
del_me;
}
}
}
Crash(int x, int y)
{
int i;
PlayRsc(wavExplosion);
i = PutCast(picExplosion, picMainWnd, x - PicWidth(picExplosion) / 2,
y - PicHeight(picExplosion) / 2, 0xFFFFFF);
mes (TIME) {
step (50) {
,
DelCast(i, 1);
DelCast(nCurCast, 1);
DelCast(nMapCast, 1);
nLife = nLife - 1;
SetCurMode(1);
if (nLife < 0) {
ShowGameOver();
} else {
PostMes(USER, -1, nStage);
}
del_me;
}
}
}
TimeOut()
{
int i;
i = PutCast(picTimeOut, picMainWnd, (WINDOW_WIDTH - PicWidth(picTimeOut)) / 2,
(WINDOW_HEIGHT - PicHeight(picTimeOut)) / 2, 0xFF0000);
mes (TIME) {
step (50) {
,
DelCast(i, 1);
DelCast(nCurCast, 1);
DelCast(nMapCast, 1);
nLife = nLife - 1;
SetCurMode(1);
if (nLife < 0) {
ShowGameOver();
} else {
PostMes(USER, -1, nStage);
}
del_me;
}
}
}
ShowGameOver()
{
mes (USER) {
int pic;
pic = CreateBlankPicture(0);
SetFont(40,"Times New Roman",0,0,0,0,400);
TextWrite("Game Over", pic, 240, 180);
MovePic(pic, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, picMainWnd, 0, 0, 2, 50);
mes (TIME) {
step (80) {
,
DrawTexture(pic);
MovePic(pic, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, picMainWnd);
DelPic(pic);
ShowTitle();
del_me;
}
}
del_me;
}
TestRanking();
}
TestRanking()
{
int i, j;
for (i = 0; i < 10; i = i + 1) {
if (nScore > ScoreRankScore[i])
break;
}
if (i >= 10) {
PostMes(USER);
return;
}
for (j = 9; j >= i; j = j - 1) {
ScoreRankScore[j + 1] = ScoreRankScore[j];
ScoreRankName[j + 1] = ScoreRankName[j];
ScoreRankStage[j + 1] = ScoreRankStage[j];
}
ScoreRankName[i] = StrInput("名前を入力してください:");
ScoreRankScore[i] = nScore;
ScoreRankStage[i] = nStage;
ShowRanking(i);
}
ShowRanking(int myrank)
{
int pic;
MovePic(picScreen, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, picMainWnd);
int btnOK;
btnOK = MakeButton("OK", 40, 500, 360, 100);
mes (USER) {
DeleteAllButtons();
del_me;
}
int i;
str s;
SetFont(35,"Arial",128,0,0,0,500);
TextColor(200, 200, 255);
TextWrite("RECORDS", picMainWnd, 240, 20);
SetFont(18,"Arial",128,0,0,0,600);
TextColor(255, 255, 0);
TextWrite("Name", picMainWnd, 100, 70);
TextWrite("Score", picMainWnd, 390, 70);
TextWrite("Stage", picMainWnd, 490, 70);
SetFont(18,"MS ゴシック",128,0,0,0,400);
for (i = 0; i < 10; i = i + 1) {
if (i == myrank)
TextColor(255, 127, 127);
else
TextColor(255, 255, 255);
s = StrPrint("%2ld", i + 1);
TextWrite(s, picMainWnd, 60, 100 + i * 25);
TextWrite(ScoreRankName[i], picMainWnd, 100, 100 + i * 25);
s = StrPrint("%.5ld", ScoreRankScore[i]);
TextWrite(s, picMainWnd, 390, 100 + i * 25);
if (ScoreRankStage[i] <= nStages) {
s = StrPrint("%ld", ScoreRankStage[i]);
} else {
s = "ALL CLEAR";
}
TextWrite(s, picMainWnd, 490, 100 + i * 25);
}
}
Goal(int timelimit)
{
int i;
PlayRsc(wavGoal);
i = PutCast(picGoal, picMainWnd, (WINDOW_WIDTH - PicWidth(picGoal)) / 2,
(WINDOW_HEIGHT - PicHeight(picGoal)) / 2, 0xFF0000);
mes (TIME) {
step (50) {
,
DelCast(i, 1);
DelCast(nCurCast, 1);
DelCast(nMapCast, 1);
nStage = nStage + 1;
SetCurMode(1);
nScore = nScore + nLeftTime * 10;
if (nStage > nStages) {
ShowGameOver();
} else {
PostMes(USER, -1, nStage);
}
del_me;
}
}
}
int HitSearch(int ax1, int ay1, int ax2, int ay2)
{
int dx, dy, s, st, c;
int x1, y1, x2, y2;
x1 = ax1; y1 = ay1; x2 = ax2; y2 = ay2;
c = 0;
dx = x2 - x1;
if (dx < 0) dx = -dx;
dy = y2 - y1;
if (dy < 0) dy = -dy;
if (dx > dy) {
if (x1 > x2) {
if (y1 > y2) st = 1; else st = -1;
s = x1; x1 = x2; x2 = s; y1 = y2;
} else {
if (y1 < y2) st = 1; else st = -1;
}
if ((c = HitPoint(x1, y1)) == 1) {
return 1;
}
s = dx / 2;
while (1) {
x1 = x1 + 1;
if (x1 > x2)
break;
s = s - dy;
if (s < 0) {
s = s + dx; y1 = y1 + st;
}
if ((c = HitPoint(x1, y1)) == 1) {
return 1;
}
}
} else {
if (y1 > y2) {
if (x1 > x2) st = 1; else st = -1;
s = y1; y1 = y2; y2 = s; x1 = x2;
} else {
if (x1 < x2) st = 1; else st = -1;
}
if ((c = HitPoint(x1, y1)) == 1) {
return 1;
}
s = dy / 2;
while (1) {
y1 = y1 + 1;
if (y1 > y2)
break;
s = s - dx;
if (s < 0) {
s = s + dy; x1 = x1 + st;
}
if ((c = HitPoint(x1, y1)) == 1) {
return 1;
}
}
}
return c;
}
int HitPoint(int x, int y)
{
int c;
c = GetColor(picMap, x, y);
if (c == COLOR_WALL)
c = 1;
else if (c == COLOR_GOAL)
c = 2;
else
c = 0;
return c;
}
IniSave()
{
int i;
str section;
for (i = 0; i < 10; i = i + 1) {
section = StrPrint("Record%ld", i);
WriteIniStr(section, "Name", ScoreRankName[i], sIniFileName);
WriteIniInt(section, "Score", ScoreRankScore[i], sIniFileName);
WriteIniInt(section, "Stage", ScoreRankStage[i], sIniFileName);
}
}
IniLoad()
{
int i;
str section;
for (i = 0; i < 10; i = i + 1) {
section = StrPrint("Record%ld", i);
ScoreRankName[i] = GetIniStr(section, "Name", "--------", sIniFileName);
ScoreRankScore[i] = GetIniInt(section, "Score", 0, sIniFileName);
ScoreRankStage[i] = GetIniInt(section, "Stage", 1, sIniFileName);
}
}