home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1999 February
/
VPR9902A.BIN
/
FFILLY
/
UG
/
game.tfy
< prev
next >
Wrap
Text File
|
1998-04-30
|
10KB
|
363 lines
#define GS_MAIN 0
#define GS_PLAY 1
#define GS_POSE 2
#define GS_DEMO 3
#define GS_BUSY 4
#define GS_END 5
#define AN_WAIT 0
#define AN_MOUNT 1
#define AN_MOUNTED 2
#define AN_MOVE_G 3
#define AN_MOVE_B 4
#define AN_PUNCH 5
#define AN_DAMAGE 6
#define AN_KICK 7
#define AN_TUCKLE 8
#define AN_TUCKLED 9
#define AN_MPUNCH 10
#define AN_MPUNCHED 11
#define AN_WIN 100
#define AN_DEF 101
#define KM_BASE 0
#define KM_MOVE 1
#define KM_DAMAGE 2
#define KM_PUNCH 3
#define KM_KICK_0 4
#define KM_KICK_1 5
#define KM_TUCKLE 6
#define KM_MOUNT 7
#define KM_MPUNCH 8
#define KM_MOUNTED 9
#define KM_DEF 10
#define WV_HIT 0
#define WV_END 1
str prgTitle;
str dfName, hfName;
int gStatus;
int trColor;
int ASX, ASY;
int ASW, ASH;
int gageW, gageH;
int buffImage;
int backImage;
int backW, backH;
int blackImage;
// scroll
int hsVal, vsVal;
int hsMax, vsMax;
int constX;
int startX, startY;
int charaSize;
int C_PW[], C_PH[];
int winner;
int isMount;
int objSize; // painted obj
int LR;
int paintOrder[];
int C_Type[]; // ...picture index
int C_Pic[];
int C_Ene[], C_EneMax[];
int C_Hakai[];
int C_AN[]; // current action number
int C_Koma[];
int C_X[], C_Y[];
int C_W[], C_H[];
int C_sX[], C_sY[];
// koma
int komaSize;
int K_sX[], K_sY[];
int K_W[], K_H[];
// fkoma
int F_Pic;
int fire_On[];
int F_X[], F_Y[];
int F_sX[], F_sY[];
int F_W[], F_H[];
int soundSize;
int sound[];
int sound_On;
int device;
// init ---------------------------------------------------------------
int initGame( int pic ) {
int i;
trColor = 0xffffff;
dfName = "ug.dat";
readSetting( dfName );
gStatus = GS_MAIN;
LR = 0;
device = 1;
C_Type[0] = 0; C_Type[1] = 2;
for ( i = 0; i < 2; i = i + 1 ) {
F_sX[i] = 0; F_sY[i] = 0; F_W[i] = 70; F_H[i] = 70;
}
setFB( 0 );
winner = 0;
loadRes( pic );
paintBlackImage( blackImage, ASW, ASH, prgTitle );
} // method end
// load ---------------------------------------------------------------
int loadRes( int pic ) {
int i;
buffImage = CreatePic( pic, ASW, ASH );
backImage = LoadPic( StrPrint( "back.%s", picExt ) );
backW = PicWidth( backImage );
backH = PicHeight( backImage );
blackImage = CreatePic( pic, ASW, ASH );
F_Pic = LoadPic( StrPrint( "beam.%s", picExt ) );
for ( i = 0; i < soundSize; i = i + 1 ) {
sound[i] = LoadRsc( StrPrint( "sound%ld.wav", i ) );
}
} // method end
// RELEASE ------------------------------------------------------------
int releaseRes() {
int i;
DelPic( buffImage );
DelPic( backImage );
DelPic( blackImage );
DelPic( F_Pic );
for( i=0; i < soundSize; i=i+1 ){ DelRsc( sound[i] ); }
} // method end
// bi -----------------------------------------------------------------
int paintBlackImage( int pic, int w, int h, str string ) {
int i, j;
int bx, by, bw, bh;
int tx, ty;
bw = w / 10; bh = h / 5;
SetLineSize(1);
SetPaintColor( 0x400000 );
DrawRect( pic, 0, 0, w, h, 0,0 );
SetPaintColor( 0xffffff );
for ( i = 0; i < 10; i = i + 1 ) {
for ( j = 0; j < 5; j = j + 1 ) {
bx = i * bw + 2; by = j * bh + 2;
DrawCircle( pic, bx, by, bx + bw - 4, by + bh - 4, 0, 0 );
}
}
tx = ( w / 2 ) - StrLen( string ) * 30 / 2 - 5;
ty = bh + ( bh / 2 );
paintBText( pic, tx, ty, 60, 255, 128, 0, string );
} // method end
// start --------------------------------------------------------------
int startGame( int pic ) {
int i;
int c_pic;
int x, y;
str string;
gStatus = GS_BUSY;
if ( M_Open == 1 ) { MCI( "play BGM from 0" ); }
// PICTURE
for ( i = 0; i < 2; i = i + 1 ) {
C_Pic[i] = LoadPic( StrPrint( "Chara%ld.%s", C_Type[i], picExt ) );
C_PW[i] = PicWidth( C_Pic[i] );
C_PH[i] = PicHeight( C_Pic[i] );
}
i = 1;
c_pic = CreatePic( C_Pic[i], C_PW[i], C_PH[i] );
ReversePic( C_Pic[i], 0,0, C_PW[i],C_PH[i], c_pic, 0,0 );
DelPic( C_Pic[i] ); C_Pic[i] = c_pic;
// POS
C_X[0] = backW/2 - ASW/2 + startX;
C_X[1] = backW/2 + ASW/2 - startX;
constX = C_X[LR] - ( backW/2 - ASW/2 );
// INIT PARA
for ( i = 0; i < 2; i = i + 1 ) {
readCharaData( dfName, i, C_Type[i] );
setStandBase( i );
fire_On[i] = 0;
}
objSize = 2; sound_On = -1; winner = -1; isMount = 0;
updateBI( pic );
paintGage( pic );
runGameMes( pic );
string = "KEYDOWN TO START";
x = ASX + ASW/2 - StrLen( string ) * 15 / 2;
y = ASY + 30;
paintBText( pic, x, y, 30, 255,0,0, string );
mes( KEY_DOWN ) {
mes( TIME ) { // FOR CLICK INTERVAL
step( 1 ) { del_us; , gStatus = GS_PLAY; del_me; }
}
}
} // method end
// end ----------------------------------------------------------------
int endGame( int pic ) {
int i;
gStatus = GS_END;
mes( TIME ) {
step( 10 ) {
,
for ( i = 0; i < 2; i = i + 1 ){ DelPic( C_Pic[i] ); }
MovePic( blackImage, 0, 0, ASW, ASH, pic, ASX, ASY, 2, 20 );
,,
C_Ene[0] = 0; C_Ene[1] = 0;
paintGage( pic );
gStatus = GS_MAIN;
del_me;
}
}
} // method end
// engine -------------------------------------------------------------
int runGameMes( int pic ) {
int ecn;
if ( LR == 0 ) { ecn = 1; } else { ecn = 0; }
/*
mes( LBDOWN ){
if ( gStatus == GS_PLAY && C_AN[ LR ] <= AN_MOUNT &&
MesP2 > ASX && MesP2 < ASX + ASW && MesP3 > ASY && MesP3 < ASY + ASH ) {
MouseDown( LR );
}
}
*/
mes( KEY_DOWN ) {
if ( gStatus == GS_PLAY && C_AN[ LR ] <= AN_MOUNT ) { KeyDown( LR ); }
}
runCPU( ecn );
mes( TIME ) {
if ( gStatus == GS_END || gStatus == GS_DEMO ) { // END ENGINE
del_us;
if ( M_Open == 1 ) { MCI( "stop BGM" ); }
if ( gStatus == GS_DEMO ) { Action_Demo( pic, winner ); } // DEMO
del_me;
}
if ( gStatus == GS_PLAY ) { step ( 3 ) { updateBI( pic ); } }
if ( M_Open == 1 ) { // BGM LOOP
step ( 10 ) { ,
if ( StrtoInt( StrMCI( "status BGM position" ) ) >= M_length ) {
MCI( "play BGM from 0" );
}
}
}
} // mes TIME end
} // method end
// update -------------------------------------------------------------
int updateBI( int pic ) {
int i, n;
if ( gStatus != GS_DEMO ) {
if ( winner == -1 ) { checkBorder(); }
if ( isMount == 0 ) {
for ( i = 0; i < objSize; i = i + 1 ) {
if ( C_AN[i] != AN_WAIT ) { playAction( i, C_AN[i] ); }
}
}
else if ( C_AN[ winner ] != AN_MOUNT ) { playAction( winner, C_AN[ winner ] ); }
}
setScrollValue( LR );
MovePic( backImage, hsVal, vsVal, ASW, ASH, buffImage, 0, 0 );
for ( i = 0; i < objSize; i = i + 1 ) {
n = paintOrder[i];
MovePic( C_Pic[n], C_sX[n], C_sY[n], C_W[n], C_H[n],
buffImage, C_X[n] - hsVal - C_W[n]/2, C_Y[n] - vsVal - C_H[n]/2, 0, trColor );
}
for ( i = 0; i < 2; i = i + 1 ) {
if ( fire_On[i] == 1 ) {
MovePic( F_Pic, F_sX[i], F_sY[i], F_W[i], F_H[i],
buffImage, F_X[i] - hsVal - F_W[i]/2, F_Y[i] - vsVal - F_H[i]/2, 0, trColor );
}
fire_On[i] = 0;
}
if( sound_On != -1 ){
paintGage( pic );
PlayRsc( sound[ sound_On ] );
sound_On = -1;
}
MovePic( buffImage, 0, 0, ASW, ASH, pic, ASX, ASY );
} // method end
// checkBorder --------------------------------------------------------
int checkBorder() {
int i;
if ( C_X[1] - C_X[0] < K_W[ KM_BASE ] * 4 / 5 &&
C_AN[0] == AN_WAIT && C_AN[1] == AN_WAIT ) {
C_AN[0] = AN_MOVE_B; C_AN[1] = AN_MOVE_B;
}
if ( C_X[0] < K_W[ KM_BASE ] / 2 && C_AN[0] == AN_WAIT ) {
C_AN[0] = AN_MOVE_G;
}
if ( C_X[1] > backW - K_W[ KM_BASE ] / 2 && C_AN[1] == AN_WAIT ) {
C_AN[1] = AN_MOVE_G;
}
} // method end
// set scroll----------------------------------------------------------
int setScrollValue( int i ) {
if ( C_X[i] < constX ) { hsVal = 0; }
else if ( constX <= C_X[i] && C_X[i] < backW - ASW + constX )
{ hsVal = C_X[i] - constX; }
else if( backW - ASW + constX <= C_X[i] ) { hsVal = backW - ASW; }
vsVal = 0;
} // method end
// gage ---------------------------------------------------------------
int paintGage( int pic ) {
int elen, x, y; y = 10;
// LEFT
if ( C_Ene[0] > 0 ) {
elen = RealtoInt( InttoReal( C_Ene[0] )
/ InttoReal( C_EneMax[0] ) * InttoReal( gageW ) );
}
else{ elen = 0; }
if ( elen > gageW ) { elen = gageW; }
x = ASX;
paintButton( pic, x + elen,y, gageW - elen, gageH, 0x000000, -2, -2 ); // BLACK
if ( C_Ene[0] > 0 ){
paintButton( pic, x,y, elen,gageH, 0xffff00, -2, -2 );
}
// RIGHT
if ( C_Ene[1] > 0 ) {
elen = RealtoInt( InttoReal( C_Ene[1] )
/ InttoReal( C_EneMax[1] ) * InttoReal( gageW ) );
}
else{ elen = 0; }
if ( elen > gageW ) { elen = gageW; }
x = ASX +ASW - gageW;
paintButton( pic, x, y, gageW - elen, gageH, 0x000000, -2, -2 ); // BLACK
if ( C_Ene[1] > 0 ) {
paintButton( pic, x + ( gageW-elen ), y, elen, gageH, 0xffff00, -2, -2 );
}
} // method end