📄 gamegame.java
字号:
pScouts[ix].enemy.xspeed = (short) (GARand() % ( 4 + 1) - 4 / 2);
pScouts[ix].enemy.yspeed = (short) (GARand() % ( 2 + 1));
}
else if (pScouts[ix].enemy.ypos >= terrainHeight - 3 )
{
pScouts[ix].enemy.xspeed = (short) (GARand() % ( 4 + 1) - 4 / 2);
pScouts[ix].enemy.yspeed = (short) -(GARand() % ( 2 + 1));
}
else if (pScouts[ix].enemy.FrameIx == 0 && pScouts[ix].enemy.status == 1 )
{
pScouts[ix].enemy.xspeed = (short) (GARand() % ( 4 + 1) - 4 / 2);
pScouts[ix].enemy.yspeed = (short) ((GARand() % ( 2 + 1) - 2 / 2) / 2);
}
pScouts[ix].enemy.reflectable.collidable.object.xpos = pScouts[ix].enemy.xpos;
pScouts[ix].enemy.reflectable.collidable.object.ypos = pScouts[ix].enemy.ypos;
}
}
return Cnt;
}
/**
* Transform a kidnapper to a super alien
*
* @param pKidnapper The kidnapper to transform
* @param The index of the kidnaper in the kidnapper list
*
*/
boolean
DefTransformToSuperalien(DefKidnapper_t pKidnapper,
short index)
{
DefGameState_t pGame = DefGlobalState_p.GameState;
byte ix;
byte alienIx=0;
;
for (ix = 0; ix < 4 ; ix++)
{
if (pGame.pEnemies.pSuperAliens[ix].enemy.Valid == false)
{
pGame.nrOfSuperAliens++;
;
pGame.pEnemies.pSuperAliens[ix].enemy.reflectable.collidable.object.pAppearance = pGame.superAlienAnimation.pAppearance[0];
pGame.pEnemies.pSuperAliens[ix].enemy.reflectable.collidable.explosionType = ET_Medium;
pGame.pEnemies.pSuperAliens[ix].enemy.status = 8 ;
pGame.pEnemies.pSuperAliens[ix].enemy.pAnim = pGame.superAlienAnimation;
pGame.pEnemies.pSuperAliens[ix].enemy.FrameIx = (byte) ix;
pGame.pEnemies.pSuperAliens[ix].madCounter = 0;
pGame.pEnemies.pSuperAliens[ix].enemy.reflectable.radarAppearance = RA_Broad;
pGame.pEnemies.pSuperAliens[ix].enemy.reflectable.collidable.score = 25 ;
pGame.pEnemies.pSuperAliens[ix].enemy.xpos = pKidnapper.enemy.xpos;
pGame.pEnemies.pSuperAliens[ix].enemy.ypos = pKidnapper.enemy.ypos;
pGame.pEnemies.pSuperAliens[ix].enemy.xspeed = 0;
pGame.pEnemies.pSuperAliens[ix].enemy.yspeed = 0;
pGame.pEnemies.pSuperAliens[ix].enemy.reflectable.collidable.object.xpos = pKidnapper.enemy.xpos;
pGame.pEnemies.pSuperAliens[ix].enemy.reflectable.collidable.object.ypos = pKidnapper.enemy.ypos;
pGame.pEnemies.pSuperAliens[ix].enemy.Valid = true;
pGame.pEnemies.pSuperAliens[ix].enemy.enemyType = 4 ;
alienIx = ix;
break;
}
}
pKidnapper.pHuman.reflectable.radarAppearance = RA_Not_Available;
if (ix == 4 )
{
pKidnapper.enemy.status = 8 ;
pKidnapper.enemy.reflectable.radarAppearance = RA_Medium;
pKidnapper.pHuman = null;
return (false);
}
pKidnapper.enemy.status = 0 ;
;
DefKillEnemy(pKidnapper.enemy, (byte) index, pKidnapper, false);
;
pGame.pEnemies.enemyOrder[pGame.pEnemies.nrOfEnemies] = 4 ;
pGame.pEnemies.enemyNr[pGame.pEnemies.nrOfEnemies] = alienIx;
pGame.pEnemies.nrOfEnemies++;
return (true);
}
/**
*
*
*
* @param pKidnapper
* @param pHumans
* @param nrOfHumans
* @param pWorld
*
* @returns
*/
boolean
DefDoKidnapp(DefKidnapper_t pKidnapper,
DefHuman_t[] pHumans,
short nrOfHumans,
DefWorld_t pWorld)
{
DefHuman_t pHuman;
short ix;
for (ix = 0; ix < nrOfHumans; ix++)
{
if (pHumans[ix].status == 1 )
{
pHuman = pHumans[ix];
short[] tmpX = new short[1];
short[] tmpY = new short[1];
tmpX[0] = pKidnapper.enemy.xspeed;
tmpY[0] = pKidnapper.enemy.yspeed;
if (DefCalculateSpeeds(pKidnapper.enemy.xpos,
pKidnapper.enemy.ypos,
pHuman.reflectable.collidable.object.xpos,
pHuman.reflectable.collidable.object.ypos,
(short)100, tmpX, tmpY, (short)2 , (short)1 , (byte)0, pWorld))
{
pKidnapper.enemy.xspeed = tmpX[0];
pKidnapper.enemy.yspeed = tmpY[0];
pKidnapper.pHuman = pHuman;
pKidnapper.enemy.status = 5 ;
return true;
}
else {
pKidnapper.enemy.xspeed = tmpX[0];
pKidnapper.enemy.yspeed = tmpY[0];
}
break;
}
}
return false;
}
/**
* EnemyFireShot - Inserts and initializes a shot in the enemy shot array
*
* @param shots pointer to the shots
* @param nrOfShots the number of shots
* @param xpos the starting x position of the shot to insert
* @param ypos the starting y position of the shot to insert
* @param xspeed the horizontal speed of the shot to insert
* @param yspeed the vertical speed of the shot to insert
*
*/
void
DefEnemyFireShot(DefTheShot_t[] shots,
short nrOfShots,
short xpos,
short ypos,
short xspeed,
short yspeed)
{
short ix;
short iy;
short idx = 0;
ix = nrOfShots;
for (iy = 0; iy < nrOfShots; iy++)
{
if (shots[idx].shot.timeToLive == 0)
{
ix = iy;
iy = nrOfShots;
}
idx++;
}
if (ix < nrOfShots)
{
shots[idx].shot.timeToLive = 50 ;
shots[idx].shot.object.xpos = xpos;
shots[idx].shot.object.ypos = ypos;
shots[idx].xspeed = xspeed;
shots[idx].yspeed = yspeed;
}
}
/**
* Draws all the mines
*
*/
void
DefDrawMines(DefMine_t[] pMines,
short nrOfMines,
DefWorld_t pWorld)
{
short ix;
for (ix = 0; ix < nrOfMines; ix++)
{
if (pMines[ix].Valid)
{
DefDrawObject(pMines[ix].collidable.object, pWorld);
}
}
}
/**
* Updates the mines
*
*/
void
DefUpdateMines(DefMine_t[] pMines,
short nrOfMines)
{
short ix;
for (ix = 0; ix < nrOfMines; ix++)
{
if (pMines[ix].Valid)
{
pMines[ix].collidable.object.pAppearance = pMines[ix].pAnim.pAppearance[pMines[ix].FrameIx];
pMines[ix].FrameDelayCnt++;
if (pMines[ix].FrameDelayCnt >= pMines[ix].FrameDelay)
{
pMines[ix].FrameDelayCnt = 0;
pMines[ix].FrameIx = (byte)((pMines[ix].FrameIx + 1) % pMines[ix].pAnim.nrOfFrames);
}
}
}
}
/**
* Inserts and initializes a mine in the mine array.
*
*/
void
DefDropMine(short xpos,
short ypos,
DefMine_t[] pMines,
short nrOfMines)
{
short ix;
for (ix = 0; ix < nrOfMines; ix++)
{
if (pMines[ix].Valid == false)
{
pMines[ix].Valid = true;
pMines[ix].collidable.object.xpos = xpos;
pMines[ix].collidable.object.ypos = ypos;
break;
}
}
}
/**
* Initiates all mines by setting Valid to FALSE
*
*/
void
DefInitMines(DefMine_t[] pMines,
short nrOfMines)
{
short ix;
for (ix = 0; ix < nrOfMines; ix++)
{
pMines[ix].Valid = false;
}
}
/**
* Handle the key press event
*
*/
boolean
DefGameKeyPressed(byte key)
{
if (DefGlobalState_p.GameState.status == 1 )
{
DefGlobalState_p.GameState.gamePaused = false;
DefGlobalState_p.GameState.SplashTickCount = (byte)200 ;
DefHideReady();
if (DefGlobalState_p.GameState.pEnemies.nrOfEnemies == 0)
{
DefGlobalState_p.GameState.statusData = 0;
}
if (key == KeyNo )
{
DefChangeState(FS_End);
}
return true;
}
if (DefGlobalState_p.GameState.status == 4 )
{
if (DefGlobalState_p.GameState.statusData < 1)
{
DefGlobalState_p.GameState.gamePaused = false;
DefGlobalState_p.GameState.SplashTickCount = (byte) 200 ;
DefGlobalState_p.GameState.statusData = 0;
DefHideBonusScreen();
}
return (true);
}
if (!DefGlobalState_p.GameState.gamePaused)
{
switch (key)
{
case KeyLeft :
case KeyFour :
DefGlobalState_p.GameState.pPlayer.steerLeft = true;
DefGlobalState_p.GameState.pPlayer.steerRight = false;
break;
case KeyRight :
case KeySix :
DefGlobalState_p.GameState.pPlayer.steerRight = true;
DefGlobalState_p.GameState.pPlayer.steerLeft = false;
break;
case KeyTwo :
case KeyUp :
DefGlobalState_p.GameState.pPlayer.steerUp = true;
DefGlobalState_p.GameState.pPlayer.steerDown = false;
break;
case KeyEight :
case KeyDown :
DefGlobalState_p.GameState.pPlayer.steerDown = true;
DefGlobalState_p.GameState.pPlayer.steerUp = false;
break;
case KeyOne :
DefGlobalState_p.GameState.pPlayer.steerUp = true;
DefGlobalState_p.GameState.pPlayer.steerDown = false;
DefGlobalState_p.GameState.pPlayer.steerLeft = true;
DefGlobalState_p.GameState.pPlayer.steerRight = false;
break;
case KeyThree :
DefGlobalState_p.GameState.pPlayer.steerUp = true;
DefGlobalState_p.GameState.pPlayer.steerDown = false;
DefGlobalState_p.GameState.pPlayer.steerRight = true;
DefGlobalState_p.GameState.pPlayer.steerLeft = false;
break;
case KeySeven :
DefGlobalState_p.GameState.pPlayer.steerDown = true;
DefGlobalState_p.GameState.pPlayer.steerUp = false;
DefGlobalState_p.GameState.pPlayer.steerLeft = true;
DefGlobalState_p.GameState.pPlayer.steerRight = false;
break;
case KeyNine :
DefGlobalState_p.GameState.pPlayer.steerDown = true;
DefGlobalState_p.GameState.pPlayer.steerUp = false;
DefGlobalState_p.GameState.pPlayer.steerRight = true;
DefGlobalState_p.GameState.pPlayer.steerLeft = false;
break;
case KeyYes :
case KeyFive :
DefGlobalState_p.GameState.pShots.newPlayerShot = true;
break;
case KeyStar :
DefGlobalState_p.GameState.droppedBomb = true;
break;
case KeyNo :
DefSaveGame();
DefChangeState(FS_End);
break;
case KeyClear :
GAMsgBox( ( 1214 + 0 ) , MessageBoxSmall, 0 );
DefGlobalState_p.GameState.gamePaused = true;
break;
}
}
else
{
if (key != KeyFlipClose && key != KeyFlipOpen)
{
DefGlobalState_p.GameState.gamePaused = false;
}
}
return (true);
}
/**
* Handle the key press release event
*
*/
void
DefGameKeyReleased(byte key)
{
switch (key)
{
case KeyLeft :
case KeyFour :
DefGlobalState_p.GameState.pPlayer.steerLeft = false;
break;
case KeyRight :
case KeySix :
DefGlobalState_p.GameState.pPlayer.steerRight = false;
break;
case KeyTwo :
case KeyUp :
DefGlobalState_p.GameState.pPlayer.steerUp = false;
break;
case KeyEight :
case KeyDown :
DefGlobalState_p.GameState.pPlayer.steerDown = false;
break;
case KeyOne :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -