示例#1
0
static void ShowAllKeys(int index, int change)
{
	int x1, x2, y1, y2;
	
	x1 = CenterX((TextCharWidth('a') * 10)) / 2;
	x2 = x1 * 3;
	
	y1 = (SCREEN_HEIGHT / 2) - (TextHeight() * 10);
	y2 = (SCREEN_HEIGHT / 2) - (TextHeight() * 2);
	
	DisplayKeys(x1, x2, y1, "Player One", &gPlayer1Data, index, change);
	DisplayKeys(x1, x2, y2, "Player Two", &gPlayer2Data, index - 6, change - 6);
	
	y2 += TextHeight() * 8;
	
	TextStringAt(x1, y2, "Map");
	
	if (change == 12)
		DisplayMenuItem(x2, y2, SELECTKEY, index == 12);
	else
		DisplayMenuItem(x2, y2, SDL_GetKeyName(gOptions.mapKey), index == 12);
	
#define DONE	"Done"
	
	y2 += TextHeight () * 2;
	
	DisplayMenuItem(CenterX(TextWidth(DONE)), y2, DONE, index == 13);
}
示例#2
0
int PlayerEquip(void *bkg)
{
	int cmd1, cmd2, prev1 = 0, prev2 = 0;
	int done1 = 0, done2;

	debug(D_NORMAL, "\n");

	done2 = gOptions.twoPlayers ? 0 : 1;
	while (!done1 || !done2) {
		memcpy(GetDstScreen(), bkg, SCREEN_MEMSIZE);
		GetPlayerCmd(&cmd1, &cmd2);
		
		if (KeyDown(keyEsc)) return 0; // hack to exit from menu
		
		if (gOptions.twoPlayers) {
			if (cmd1 == prev1)
				cmd1 = 0;
			else
				prev1 = cmd1;
//      if (!done1) // || !gPlayer1Data.weaponCount < MAX_WEAPONS)
			done1 = !WeaponSelection(CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1, done1);
			ShowSelection(CenterOfLeft(50), &gPlayer1Data,CHARACTER_PLAYER1);
			ShowPlayerControls(CenterOfLeft(100), &gPlayer1Data);

			if (cmd2 == prev2)
				cmd2 = 0;
			else
				prev2 = cmd2;
//      if (!done2) // || gPlayer2Data.weaponCount < MAX_WEAPONS)
			done2 = !WeaponSelection(CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2, done2);
			ShowSelection(CenterOfRight(50), &gPlayer2Data, CHARACTER_PLAYER2);
			ShowPlayerControls(CenterOfRight(100), &gPlayer2Data);
		} else {
			if (cmd1 == prev1)
				cmd1 = 0;
			else
				prev1 = cmd1;
			if (!done1)	// || gPlayer1Data.weaponCount <= 0)
				done1 =
				    !WeaponSelection(CenterX(80),
						     CHARACTER_PLAYER1,
						     &gPlayer1Data, cmd1,
						     done1);
			ShowSelection(CenterX(80), &gPlayer1Data,
				      CHARACTER_PLAYER1);
			ShowPlayerControls(CenterX(100), &gPlayer1Data);
		}

		CopyToScreen();
	}

	WaitForRelease();

	return 1;
}
示例#3
0
void SoldierInSectorIncompaciated( SOLDIERTYPE *pSoldier, INT16 sGridNo )
{
	INT16 sWorldX, sWorldY;
	UINT8	ubNewDirection;
	INT16 sGoodGridNo;

	if ( !pSoldier->bInSector )
	{
		return;
	}

	// OK, look for sutable placement....
	sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, STAND_FALLFORWARD_STOP, sGridNo, 5, &ubNewDirection, FALSE );

	sWorldX = CenterX( sGoodGridNo );
	sWorldY = CenterY( sGoodGridNo );

	EVENT_SetSoldierPosition( pSoldier, sWorldX, sWorldY );

	EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
	EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );

	//pSoldier->bDesiredDirection = pSoldier->bDirection;

	EVENT_InitNewSoldierAnim( pSoldier, STAND_FALLFORWARD_STOP, 1, TRUE );
}
示例#4
0
/**
 * This fills in the fields of the New proto based on the
 * fields of the Old proto.
 *
 * @param New new proto to be filled in
 * @param Old old proto to be converted
 * 
 *  Globals: none
 * 
 * Exceptions: none
 * History: Mon Nov 26 09:45:39 1990, DSJ, Created.
 */
void MakeNewFromOld(PROTO New, PROTOTYPE *Old) {
  New->X = CenterX(Old->Mean);
  New->Y = CenterY(Old->Mean);
  New->Length = LengthOf(Old->Mean);
  New->Angle = OrientationOf(Old->Mean);
  FillABC(New);
} /* MakeNewFromOld */
示例#5
0
void SoldierInSectorRepair( SOLDIERTYPE *pSoldier, INT16 sGridNo )
{
	INT16 sWorldX, sWorldY;
	UINT8	ubNewDirection;
	INT16 sGoodGridNo;

	if ( !pSoldier->bInSector )
	{
		return;
	}

	// OK, look for sutable placement....
	sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, BEING_REPAIRMAN, sGridNo, 5, &ubNewDirection, FALSE );

	sWorldX = CenterX( sGoodGridNo );
	sWorldY = CenterY( sGoodGridNo );

	EVENT_SetSoldierPosition( pSoldier, sWorldX, sWorldY );

	EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
	EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );

	//pSoldier->bDesiredDirection = pSoldier->bDirection;

	if ( !IS_MERC_BODY_TYPE( pSoldier ) )
	{
		EVENT_InitNewSoldierAnim( pSoldier, STANDING, 1, TRUE );
	}
	else
	{
		EVENT_InitNewSoldierAnim( pSoldier, BEING_REPAIRMAN, 1, TRUE );
	}
}
/*----------------------------------------------------------------------------
						Public Code
-----------------------------------------------------------------------------*/
void DisplayProtoList(const char* ch, LIST protolist) {
  void* window = c_create_window("Char samples", 50, 200,
                                 520, 520, -130.0, 130.0, -130.0, 130.0);
  LIST proto = protolist;
  iterate(proto) {
    PROTOTYPE* prototype = reinterpret_cast<PROTOTYPE *>(first_node(proto));
    if (prototype->Significant)
      c_line_color_index(window, Green);
    else if (prototype->NumSamples == 0)
      c_line_color_index(window, Blue);
    else if (prototype->Merged)
      c_line_color_index(window, Magenta);
    else
      c_line_color_index(window, Red);
    float x = CenterX(prototype->Mean);
    float y = CenterY(prototype->Mean);
    double angle = OrientationOf(prototype->Mean) * 2 * M_PI;
    float dx = static_cast<float>(LengthOf(prototype->Mean) * cos(angle) / 2);
    float dy = static_cast<float>(LengthOf(prototype->Mean) * sin(angle) / 2);
    c_move(window, (x - dx) * 256, (y - dy) * 256);
    c_draw(window, (x + dx) * 256, (y + dy) * 256);
    if (prototype->Significant)
      tprintf("Green proto at (%g,%g)+(%g,%g) %d samples\n",
              x, y, dx, dy, prototype->NumSamples);
    else if (prototype->NumSamples > 0 && !prototype->Merged)
      tprintf("Red proto at (%g,%g)+(%g,%g) %d samples\n",
              x, y, dx, dy, prototype->NumSamples);
  }
  c_make_current(window);
}
示例#7
0
void DrawKeycards(HUD *hud)
{
	int keyFlags[] =
	{
		FLAGS_KEYCARD_YELLOW,
		FLAGS_KEYCARD_GREEN,
		FLAGS_KEYCARD_BLUE,
		FLAGS_KEYCARD_RED
	};
	int i;
	int xOffset = -30;
	int xOffsetIncr = 20;
	int yOffset = 20;
	for (i = 0; i < 4; i++)
	{
		if (hud->mission->KeyFlags & keyFlags[i])
		{
			const Pic *pic = KeyPickupClass(hud->mission->keyStyle, i)->Pic;
			Blit(
				&gGraphicsDevice,
				pic,
				Vec2iNew(CenterX(pic->size.x) - xOffset, yOffset));
		}
		xOffset += xOffsetIncr;
	}
}
示例#8
0
文件: Player.cpp 项目: Beulard/beul
void Player::DropWeapon(World& w){
    if(weapon != NULL){
        w.map->AddItem(weapon->GetID(), CenterX(), CenterY());
        delete weapon;

        weapon = NULL;
    }
}
示例#9
0
int PlayerEquip(void *bkg)
{
	int done1 = 0, done2;

	debug(D_NORMAL, "\n");

	done2 = gOptions.twoPlayers ? 0 : 1;
	while (!done1 || !done2)
	{
		int cmd1 = 0;
		int cmd2 = 0;
		InputPoll(&gJoysticks, &gKeyboard);
		memcpy(GetDstScreen(), bkg, GraphicsGetMemSize(&gGraphicsDevice.cachedConfig));
		GetPlayerCmd(&cmd1, &cmd2, 1);

		if (KeyIsPressed(&gKeyboard, keyEsc)) return 0; // hack to exit from menu

		if (gOptions.twoPlayers)
		{
			done1 = !WeaponSelection(CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1, done1);
			ShowSelection(CenterOfLeft(50), &gPlayer1Data,CHARACTER_PLAYER1);
			ShowPlayerControls(CenterOfLeft(100), &gConfig.Input.PlayerKeys[0]);

			done2 = !WeaponSelection(CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2, done2);
			ShowSelection(CenterOfRight(50), &gPlayer2Data, CHARACTER_PLAYER2);
			ShowPlayerControls(CenterOfRight(100), &gConfig.Input.PlayerKeys[1]);
		}
		else
		{
			done1 = !WeaponSelection(CenterX(80), CHARACTER_PLAYER1, &gPlayer1Data, cmd1, done1);
			ShowSelection(CenterX(80), &gPlayer1Data, CHARACTER_PLAYER1);
			ShowPlayerControls(CenterX(100), &gConfig.Input.PlayerKeys[0]);
		}

		CopyToScreen();
		SDL_Delay(10);
	}

	return 1;
}
示例#10
0
int PlayerSelection(int twoPlayers, void *bkg)
{
	int cmd1, cmd2, prev1 = 0, prev2 = 0;
	int mode1, mode2;

	mode1 = MODE_MAIN;
	mode2 = twoPlayers ? MODE_MAIN : MODE_DONE;

	SetPlayer(0, &gPlayer1Data);
	SetPlayer(1, &gPlayer2Data);

	while (mode1 != MODE_DONE || mode2 != MODE_DONE) {
		memcpy(GetDstScreen(), bkg, SCREEN_MEMSIZE);
		GetPlayerCmd(&cmd1, &cmd2);
		
		if (KeyDown(keyEsc)) return 0; // hack to allow exit
		
		if (twoPlayers) {
			if (cmd1 == prev1)
				cmd1 = 0;
			else
				prev1 = cmd1;

			mode1 = MakeSelection(mode1, CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1);

			if (cmd2 == prev2)
				cmd2 = 0;
			else
				prev2 = cmd2;

			mode2 = MakeSelection(mode2, CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2);
		} else {
			if (cmd1 == prev1)
				cmd1 = 0;
			else
				prev1 = cmd1;

			mode1 = MakeSelection(mode1, CenterX(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1);
		}

		CopyToScreen();
	}

	WaitForRelease();

	return 1;
}
示例#11
0
/*
	死んだときの処理(人型)
*/
void KariudoKen::Die()
{
		// ヒロインの位置によってx軸の速度を決める
		mSpX = -SHINIPATT_SPX;
		Jiki* jiki = GAMECONTROL->GetJiki();
		if( jiki->GetAtHtPointX() < CenterX() )
			mSpX *= -1;

		mStatus = SHINDA;
	
		mBasStatus = SHINI;
		mSpY = -SHINIPATT_SHOSP;
		mAccY = SP->GRAVITY;

		//Finalize();
		DisableAshibaCollision();
}
示例#12
0
void InternalSoldierInSectorSleep( SOLDIERTYPE *pSoldier, INT16 sGridNo, BOOLEAN fDoTransition )
{
	INT16 sWorldX, sWorldY;
	UINT8	ubNewDirection;
	INT16 sGoodGridNo;
	UINT16	usAnim = SLEEPING;

	if ( !pSoldier->bInSector )
	{
		return;
	}

	if ( AM_AN_EPC( pSoldier ) )
	{
	   usAnim = STANDING;
	}

	// OK, look for sutable placement....
	sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, usAnim, sGridNo, 5, &ubNewDirection, FALSE );

	sWorldX = CenterX( sGoodGridNo );
	sWorldY = CenterY( sGoodGridNo );

	EVENT_SetSoldierPosition( pSoldier, sWorldX, sWorldY );

	EVENT_SetSoldierDirection( pSoldier, ubNewDirection );
	EVENT_SetSoldierDesiredDirection( pSoldier, ubNewDirection );

	//pSoldier->bDesiredDirection = pSoldier->bDirection;

	if ( AM_AN_EPC( pSoldier ) )
	{
		EVENT_InitNewSoldierAnim( pSoldier, STANDING, 1, TRUE );
	}
	else
	{
		if ( fDoTransition )
		{
			EVENT_InitNewSoldierAnim( pSoldier, GOTO_SLEEP, 1, TRUE );
		}
		else
		{
			EVENT_InitNewSoldierAnim( pSoldier, SLEEPING, 1, TRUE );
		}
	}
}
示例#13
0
/*---------------------------------------------------------------------------*/
void MakeNewFromOld(PROTO New, PROTOTYPE *Old) {
/*
**  Parameters:
**    New new proto to be filled in
**    Old old proto to be converted
**  Globals: none
**  Operation: This fills in the fields of the New proto based on the
**    fields of the Old proto.
**  Return: none
**  Exceptions: none
**  History: Mon Nov 26 09:45:39 1990, DSJ, Created.
*/
  New->X = CenterX(Old->Mean);
  New->Y = CenterY(Old->Mean);
  New->Length = LengthOf(Old->Mean);
  New->Angle = OrientationOf(Old->Mean);
  FillABC(New);
} /* MakeNewFromOld */
示例#14
0
BOOLEAN TeleportSoldier( SOLDIERTYPE *pSoldier, INT16 sGridNo, BOOLEAN fForce )
{
	INT16 sX, sY;

	// Check dest...
	if ( NewOKDestination( pSoldier, sGridNo, TRUE, 0 ) || fForce )
	{
		// TELEPORT TO THIS LOCATION!
		sX = CenterX( sGridNo );
		sY = CenterY( sGridNo );
		EVENT_SetSoldierPosition( pSoldier, (FLOAT) sX, (FLOAT) sY );	

		pSoldier->sFinalDestination = sGridNo;

		// Make call to FOV to update items...
		RevealRoofsAndItems(pSoldier, TRUE, TRUE, pSoldier->bLevel, TRUE );
	
		// Handle sight!
		HandleSight(pSoldier,SIGHT_LOOK | SIGHT_RADIO);

		// Cancel services...
		GivingSoldierCancelServices( pSoldier );

		// Change light....
		if ( pSoldier->bLevel == 0 )
		{
			if(pSoldier->iLight!=(-1))
				LightSpriteRoofStatus(pSoldier->iLight, FALSE );
		}
		else
		{
			if(pSoldier->iLight!=(-1))
				LightSpriteRoofStatus(pSoldier->iLight, TRUE );
		}
		return( TRUE );
	}

	return( FALSE );
}
示例#15
0
int PlayerSelection(int twoPlayers, void *bkg)
{
	int mode1, mode2;

	mode1 = MODE_MAIN;
	mode2 = twoPlayers ? MODE_MAIN : MODE_DONE;

	SetPlayer(0, &gPlayer1Data);
	SetPlayer(1, &gPlayer2Data);

	KeyInit(&gKeyboard);
	while (mode1 != MODE_DONE || mode2 != MODE_DONE)
	{
		int cmd1 = 0;
		int cmd2 = 0;
		InputPoll(&gJoysticks, &gKeyboard);
		memcpy(GetDstScreen(), bkg, GraphicsGetMemSize(&gGraphicsDevice.cachedConfig));
		GetPlayerCmd(&cmd1, &cmd2, 1);

		if (KeyIsPressed(&gKeyboard, keyEsc)) return 0; // hack to allow exit

		if (twoPlayers)
		{
			mode1 = MakeSelection(mode1, CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1);
			mode2 = MakeSelection(mode2, CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2);
		}
		else
		{
			mode1 = MakeSelection(mode1, CenterX(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1);
		}

		CopyToScreen();
		SDL_Delay(10);
	}

	return 1;
}
示例#16
0
// Add smoke to gridno
// ( Replacement algorithm uses distance away )
void AddSmokeEffectToTile( INT32 iSmokeEffectID, INT8 bType, INT16 sGridNo, INT8 bLevel )
{
    ANITILE_PARAMS	AniParams;
    ANITILE					*pAniTile;
    SMOKEEFFECT     *pSmoke;
    BOOLEAN         fDissipating = FALSE;

    pSmoke = &gSmokeEffectData[ iSmokeEffectID ];

    if ( ( pSmoke->ubDuration - pSmoke->bAge ) < 2 )
    {
        fDissipating = TRUE;
        // Remove old one...
        RemoveSmokeEffectFromTile( sGridNo, bLevel );
    }


    // If smoke effect exists already.... stop
    if ( gpWorldLevelData[ sGridNo ].ubExtFlags[ bLevel ] & ANY_SMOKE_EFFECT )
    {
        return;
    }

    // OK,  Create anitile....
    memset( &AniParams, 0, sizeof( ANITILE_PARAMS ) );
    AniParams.sGridNo							= sGridNo;

    if ( bLevel == 0 )
    {
        AniParams.ubLevelID						= ANI_STRUCT_LEVEL;
    }
    else
    {
        AniParams.ubLevelID						= ANI_ONROOF_LEVEL;
    }


    AniParams.sDelay							= (INT16)( 300 + Random( 300 ) );

    if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
    {
        AniParams.sStartFrame					= (INT16)0;
    }
    else
    {
        AniParams.sStartFrame					= (INT16)Random( 5 );
    }


    // Bare bones flags are...
//	AniParams.uiFlags							= ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_OPTIMIZEFORSMOKEEFFECT | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING;
    //AniParams.uiFlags							= ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING;


    if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
    {
        AniParams.uiFlags	= ANITILE_PAUSED | ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING;
    }
    else
    {
        AniParams.uiFlags	= ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING | ANITILE_ALWAYS_TRANSLUCENT;
    }

    AniParams.sX									= CenterX( sGridNo );
    AniParams.sY									= CenterY( sGridNo );
    AniParams.sZ									= (INT16)0;

    // Use the right graphic based on type..
    switch( bType )
    {
    case NORMAL_SMOKE_EFFECT:

        if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
        {
            strcpy( AniParams.zCachedFile, "TILECACHE\\smkechze.STI" );
        }
        else
        {
            if ( fDissipating )
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\smalsmke.STI" );
            }
            else
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\SMOKE.STI" );
            }
        }
        break;

    case TEARGAS_SMOKE_EFFECT:

        if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
        {
            strcpy( AniParams.zCachedFile, "TILECACHE\\tearchze.STI" );
        }
        else
        {
            if ( fDissipating )
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\smaltear.STI" );
            }
            else
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\TEARGAS.STI" );
            }
        }
        break;

    case MUSTARDGAS_SMOKE_EFFECT:

        if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
        {
            strcpy( AniParams.zCachedFile, "TILECACHE\\mustchze.STI" );
        }
        else
        {
            if ( fDissipating )
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\smalmust.STI" );
            }
            else
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\MUSTARD2.STI" );
            }
        }
        break;

    case CREATURE_SMOKE_EFFECT:

        if ( !( gGameSettings.fOptions[ TOPTION_ANIMATE_SMOKE ] ) )
        {
            strcpy( AniParams.zCachedFile, "TILECACHE\\spit_gas.STI" );
        }
        else
        {
            if ( fDissipating )
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\spit_gas.STI" );
            }
            else
            {
                strcpy( AniParams.zCachedFile, "TILECACHE\\spit_gas.STI" );
            }
        }
        break;

    }

    // Create tile...
    pAniTile = CreateAnimationTile( &AniParams );

    // Set world flags
    gpWorldLevelData[ sGridNo ].ubExtFlags[ bLevel ] |= FromSmokeTypeToWorldFlags( bType );

    // All done...

    // Re-draw..... :(
    SetRenderFlags(RENDER_FLAG_FULL);
}
示例#17
0
static int NameSelection(int x, int index, struct PlayerData *data,
			 int cmd)
{
	int i;
	int y;

	//char s[2];
	static char letters[] =
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ !#?:.-0123456789";
	static char smallLetters[] =
		"abcdefghijklmnopqrstuvwxyz !#?:.-0123456789";
	static int selection[2] = { -1, -1 };

	// Kludge since Watcom won't let me initialize selection with a strlen()
	if (selection[0] < 0)
		selection[0] = selection[1] = strlen(letters);

	if (cmd & CMD_BUTTON1)
	{
		if (selection[index] == (int)strlen(letters))
		{
			SoundPlay(&gSoundDevice, SND_LAUNCH);
			return 0;
		}

		if (strlen(data->name) < sizeof(data->name) - 1) {
			int l = strlen(data->name);
			data->name[l + 1] = 0;
			if (l > 0 && data->name[l - 1] != ' ')
				data->name[l] =
				    smallLetters[selection[index]];
			else
				data->name[l] = letters[selection[index]];
			SoundPlay(&gSoundDevice, SND_MACHINEGUN);
		}
		else
		{
			SoundPlay(&gSoundDevice, SND_KILL);
		}
	}
	else if (cmd & CMD_BUTTON2)
	{
		if (data->name[0]) {
			data->name[strlen(data->name) - 1] = 0;
			SoundPlay(&gSoundDevice, SND_BANG);
		}
		else
		{
			SoundPlay(&gSoundDevice, SND_KILL);
		}
	}
	else if (cmd & CMD_LEFT)
	{
		if (selection[index] > 0)
		{
			selection[index]--;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}
	else if (cmd & CMD_RIGHT)
	{
		if (selection[index] < (int)strlen(letters))
		{
			selection[index]++;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	} else if (cmd & CMD_UP) {
		if (selection[index] > 9) {
			selection[index] -= 10;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}
	else if (cmd & CMD_DOWN)
	{
		if (selection[index] < (int)strlen(letters) - 9)
		{
			selection[index] += 10;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
		else if (selection[index] < (int)strlen(letters))
		{
			selection[index] = strlen(letters);
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}

	#define ENTRY_COLS	10
	#define	ENTRY_SPACING	12

	y = CenterY(((CDogsTextHeight() * ((strlen(letters) - 1) / ENTRY_COLS) )));

	if (gOptions.twoPlayers && index == CHARACTER_PLAYER1)
	{
		x = CenterOf(
			0,
			gGraphicsDevice.cachedConfig.ResolutionWidth / 2
			,
			(ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}
	else if (gOptions.twoPlayers && index == CHARACTER_PLAYER2)
	{
		x = CenterOf(
			gGraphicsDevice.cachedConfig.ResolutionWidth / 2,
			gGraphicsDevice.cachedConfig.ResolutionWidth,
			(ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}
	else
	{
		x = CenterX((ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}

	// Draw selection

	//s[1] = 0;
	for (i = 0; i < (int)strlen(letters); i++)
	{
		//s[0] = letters[i];

		CDogsTextGoto(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			 y + (i / ENTRY_COLS) * CDogsTextHeight());

		if (i == selection[index])
			CDogsTextCharWithTable(letters[i], &tableFlamed);
		else
			CDogsTextChar(letters[i]);
/*
		DisplayMenuItem(x + (i % 10) * 12,
				80 + (i / 10) * CDogsTextHeight(), s,
				i == selection[index]);
*/
	}

	DisplayMenuItem(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			y + (i / ENTRY_COLS) * CDogsTextHeight(),
			endChoice, i == selection[index]);

	return 1;
}
示例#18
0
int SelectOptions(int cmd)
{
	static int index = 0;
	char s[10];
	int x, y;

	if (cmd == CMD_ESC)
		return MODE_MAIN;
	if (AnyButton(cmd) || Left(cmd) || Right(cmd)) {
		switch (index) {
		case 0:
			gOptions.playersHurt = !gOptions.playersHurt;
			PlaySound(SND_KILL, 0, 255);
			break;
		case 1:
			gOptions.displayFPS = !gOptions.displayFPS;
			PlaySound(SND_FLAMER, 0, 255);
			break;
		case 2:
			gOptions.displayTime = !gOptions.displayTime;
			PlaySound(SND_LAUNCH, 0, 255);
			break;
		case 3:
			if (gOptions.copyMode == COPY_REPMOVSD)
				gOptions.copyMode = COPY_DEC_JNZ;
			else
				gOptions.copyMode = COPY_REPMOVSD;
			PlaySound(SND_EXPLOSION, 0, 255);
			break;
		case 4:
			if (Left(cmd) && gOptions.brightness > -10)
				gOptions.brightness--;
			else if (Right(cmd) && gOptions.brightness < 10)
				gOptions.brightness++;
			else
				break;

			PlaySound(SND_POWERGUN, 0, 255);
			PaletteAdjust();
			break;
		case 5:
			if (gOptions.xSplit == 0) {
				gOptions.xSplit = SPLIT_X;
				gOptions.ySplit = SPLIT_Y;
			} else {
				gOptions.xSplit = gOptions.ySplit = 0;
			}

			PlaySound(SND_KILL3, 0, 255);

			break;
		case 6:
			if (Left(cmd)) {
				if (Button1(cmd) && Button2(cmd))
					gCampaign.seed -= 1000;
				else if (Button1(cmd))
					gCampaign.seed -= 10;
				else if (Button2(cmd))
					gCampaign.seed -= 100;
				else
					gCampaign.seed--;
			} else if (Right(cmd)) {
				if (Button1(cmd) && Button2(cmd))
					gCampaign.seed += 1000;
				else if (Button1(cmd))
					gCampaign.seed += 10;
				else if (Button2(cmd))
					gCampaign.seed += 100;
				else
					gCampaign.seed++;
			}

			break;
		case 7:
			if (Left(cmd)) {
				if (gOptions.difficulty > DIFFICULTY_VERYEASY)
						gOptions.difficulty--;
			} else if (Right(cmd)) {
				if (gOptions.difficulty < DIFFICULTY_VERYHARD)
						gOptions.difficulty++;
			}

			if (gOptions.difficulty > DIFFICULTY_VERYHARD) gOptions.difficulty = DIFFICULTY_VERYHARD;
			if (gOptions.difficulty < DIFFICULTY_VERYEASY) gOptions.difficulty = DIFFICULTY_VERYEASY;

			break;
		case 8:
			gOptions.slowmotion = !gOptions.slowmotion;

			break;
		case 9:
			if (Left(cmd)) {
				if (gOptions.density > 25)
					gOptions.density -= 25;
			} else if (Right(cmd)) {
				if (gOptions.density < 200)
					gOptions.density += 25;
			}

			break;
		case 10:
			if (Left(cmd)) {
				if (gOptions.npcHp > 25)
					gOptions.npcHp -= 25;
			} else if (Right(cmd)) {
				if (gOptions.npcHp < 200)
					gOptions.npcHp += 25;
			}

			break;
		case 11:
			if (Left(cmd)) {
				if (gOptions.playerHp > 25)
					gOptions.playerHp -= 25;
			} else if (Right(cmd)) {
				if (gOptions.playerHp < 200)
					gOptions.playerHp += 25;
			}

			break;
		case 12:
			Gfx_HintToggle(HINT_FULLSCREEN);
			InitVideo();

			break;

		case 13:
			{
				GFX_Mode *m = NULL;

				if (Left(cmd)) {
					m = Gfx_ModePrev();
				} else if (Right(cmd)) {
					m = Gfx_ModeNext();
				}

				if (m) {
					debug(D_NORMAL, "new mode? %d x %d\n", m->w, m->h);
					Gfx_SetHint(HINT_WIDTH, m->w);
					Gfx_SetHint(HINT_HEIGHT, m->h);
				}
			}

			break;

		case 14:
			{
				int fac = Gfx_GetHint(HINT_SCALEFACTOR);

				if (Left(cmd)) {
					fac--;
				} else if (Right(cmd)) {
					fac++;
				}

				if (fac >= 1 && fac <= 4) {
					Gfx_SetHint(HINT_SCALEFACTOR, (const int)fac);
					InitVideo();
				}
			}

			break;

		default:
			PlaySound(SND_BANG, 0, 255);

			return MODE_MAIN;
		}
	}

	if (Up(cmd)) {
		index--;
		if (index < 0)
			index = OPTIONS_COUNT - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Down(cmd)) {
		index++;
		if (index >= OPTIONS_COUNT)
			index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}

	TextStringSpecial("Game Options:", TEXT_XCENTER | TEXT_TOP, 0, (SCREEN_WIDTH / 12));
	
	x = CenterX(MenuWidth(optionsMenu, OPTIONS_COUNT));
	y = CenterY(MenuHeight(optionsMenu, OPTIONS_COUNT));
	
	DisplayMenuAt(x - 20, y, optionsMenu, OPTIONS_COUNT, index);

	x += MenuWidth(optionsMenu, OPTIONS_COUNT);
	x += 10;
	
	TextStringAt(x, y, gOptions.playersHurt ? "Yes" : "No");
	TextStringAt(x, y + TextHeight(),
		     gOptions.displayFPS ? "On" : "Off");
	TextStringAt(x, y + 2 * TextHeight(),
		     gOptions.displayTime ? "On" : "Off");
	TextStringAt(x, y + 3 * TextHeight(),
		     gOptions.copyMode ==
		     COPY_REPMOVSD ? "rep movsd" : "dec/jnz");
	sprintf(s, "%d", gOptions.brightness);
	TextStringAt(x, y + 4 * TextHeight(), s);
	TextStringAt(x, y + 5 * TextHeight(),
		     gOptions.xSplit ? "No" : "Yes");
	sprintf(s, "%u", gCampaign.seed);
	TextStringAt(x, y + 6 * TextHeight(), s);

	switch (gOptions.difficulty) {
		case DIFFICULTY_VERYEASY:
			strcpy(s, "Easiest");
			break;
		case DIFFICULTY_EASY:
			strcpy(s, "Easy");
			break;
		case DIFFICULTY_HARD:
			strcpy(s, "Hard");
			break;
		case DIFFICULTY_VERYHARD:
			strcpy(s, "Very hard");
			break;
		default:
			strcpy(s, "Normal");
			break;
	}

	TextStringAt(x, y + 7 * TextHeight(), s);
	TextStringAt(x, y + 8 * TextHeight(),
		     gOptions.slowmotion ? "Yes" : "No");
	sprintf(s, "%u%%", gOptions.density);
	TextStringAt(x, y + 9 * TextHeight(), s);
	sprintf(s, "%u%%", gOptions.npcHp);
	TextStringAt(x, y + 10 * TextHeight(), s);
	sprintf(s, "%u%%", gOptions.playerHp);
	TextStringAt(x, y + 11 * TextHeight(), s);
	sprintf(s, "%s", Gfx_GetHint(HINT_FULLSCREEN) ? "Yes" : "No");
	TextStringAt(x, y + 12 * TextHeight(), s);
	sprintf(s, "%dx%d", Gfx_GetHint(HINT_WIDTH), Gfx_GetHint(HINT_HEIGHT));
	TextStringAt(x, y + 13 * TextHeight(), s);
	sprintf(s, "%dx", Gfx_GetHint(HINT_SCALEFACTOR));
	TextStringAt(x, y + 14 * TextHeight(), s);


	return MODE_OPTIONS;
}
示例#19
0
int SelectControls(int cmd)
{
	static int index = 0;
	int x, y;

	if (cmd == CMD_ESC)
		return MODE_MAIN;
	if (AnyButton(cmd) || Left(cmd) || Right(cmd)) {
		PlaySound(rand() % SND_COUNT, 0, 255);
		switch (index) {
		case 0:
			ChangeControl(&gPlayer1Data, &gPlayer2Data);
			break;

		case 1:
			ChangeControl(&gPlayer2Data, &gPlayer1Data);
			break;

		case 2:
			gOptions.swapButtonsJoy1 = !gOptions.swapButtonsJoy1;
			break;

		case 3:
			gOptions.swapButtonsJoy2 = !gOptions.swapButtonsJoy2;
			break;

		case 4:
			return MODE_KEYS;

		case 5:
			InitSticks();
			AutoCalibrate();
			break;

		default:
			return MODE_MAIN;
		}
	}
	if (Up(cmd)) {
		index--;
		if (index < 0)
			index = CONTROLS_COUNT - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Down(cmd)) {
		index++;
		if (index >= CONTROLS_COUNT)
			index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}

	TextStringSpecial("Configure Controls:", TEXT_XCENTER | TEXT_TOP, 0, (SCREEN_WIDTH / 12));	
	
	x = CenterX(MenuWidth(controlsMenu, CONTROLS_COUNT));
	y = CenterY(MenuHeight(controlsMenu, CONTROLS_COUNT));
	
	DisplayMenuAt(x - 20, y, controlsMenu, CONTROLS_COUNT, index);
	
	x += MenuWidth(controlsMenu, CONTROLS_COUNT);
	x += 10;

	DisplayControl(x, y, gPlayer1Data.controls);
	DisplayControl(x, y + TextHeight(), gPlayer2Data.controls);
	TextStringAt(x, y + 2 * TextHeight(), gOptions.swapButtonsJoy1 ? "Yes" : "No");
	TextStringAt(x, y + 3 * TextHeight(), gOptions.swapButtonsJoy2 ? "Yes" : "No");
	return MODE_CONTROLS;
}
示例#20
0
 const Point2 Center() const 
 { 
   return Point2(CenterX(), CenterY()); 
 }
示例#21
0
void MenuDisplaySubmenus(menu_t *menu)
{
	int i;
	int x = 0, yStart = 0;
	int maxWidth = 0;

	switch (menu->type)
	{
	// TODO: refactor the three menu types (normal, options, campaign) into one
	case MENU_TYPE_NORMAL:
	case MENU_TYPE_OPTIONS:
		{
			int isCentered = menu->type == MENU_TYPE_NORMAL;
			int xOptions;
			for (i = 0; i < menu->u.normal.numSubMenus; i++)
			{
				int width = CDogsTextWidth(menu->u.normal.subMenus[i].name);
				if (width > maxWidth)
				{
					maxWidth = width;
				}
			}
			x = CenterX(maxWidth);
			if (!isCentered)
			{
				x -= 20;
			}
			yStart = CenterY(menu->u.normal.numSubMenus * CDogsTextHeight());
			xOptions = x + maxWidth + 10;

			// Display normal menu items
			for (i = 0; i < menu->u.normal.numSubMenus; i++)
			{
				int y = yStart + i * CDogsTextHeight();
				menu_t *subMenu = &menu->u.normal.subMenus[i];

				// Display menu item
				const char *name = subMenu->name;
				if (i == menu->u.normal.index)
				{
					CDogsTextStringWithTableAt(x, y, name, &tableFlamed);
				}
				else
				{
					CDogsTextStringAt(x, y, name);
				}

				// display option value
				if (subMenu->type == MENU_TYPE_SET_OPTION_TOGGLE ||
					subMenu->type == MENU_TYPE_SET_OPTION_RANGE ||
					subMenu->type == MENU_TYPE_SET_OPTION_SEED ||
					subMenu->type == MENU_TYPE_SET_OPTION_UP_DOWN_VOID_FUNC_VOID ||
					subMenu->type == MENU_TYPE_SET_OPTION_RANGE_GET_SET ||
					subMenu->type == MENU_TYPE_SET_OPTION_CHANGE_CONTROL ||
					subMenu->type == MENU_TYPE_VOID_FUNC_VOID)
				{
					int optionInt = MenuOptionGetIntValue(subMenu);
					switch (subMenu->u.option.displayStyle)
					{
					case MENU_OPTION_DISPLAY_STYLE_INT:
						CDogsTextIntAt(xOptions, y, optionInt);
						break;
					case MENU_OPTION_DISPLAY_STYLE_YES_NO:
						CDogsTextStringAt(xOptions, y, optionInt ? "Yes" : "No");
						break;
					case MENU_OPTION_DISPLAY_STYLE_ON_OFF:
						CDogsTextStringAt(xOptions, y, optionInt ? "On" : "Off");
						break;
					case MENU_OPTION_DISPLAY_STYLE_STR_FUNC:
						CDogsTextStringAt(xOptions, y, subMenu->u.option.uFunc.str());
						break;
					case MENU_OPTION_DISPLAY_STYLE_INT_TO_STR_FUNC:
						CDogsTextStringAt(xOptions, y, subMenu->u.option.uFunc.intToStr(optionInt));
						break;
					default:
						break;
					}
				}
			}
		}
		break;
	case MENU_TYPE_CAMPAIGNS:
		{
			int y = CenterY(12 * CDogsTextHeight());

		#define ARROW_UP	"\036"
		#define ARROW_DOWN	"\037"

			if (menu->u.normal.scroll != 0)
			{
				DisplayMenuItem(
					CenterX(CDogsTextWidth(ARROW_UP)),
					y - 2 - CDogsTextHeight(),
					ARROW_UP,
					0);
			}

			for (i = menu->u.normal.scroll;
				i < MIN(menu->u.normal.scroll + 12, menu->u.normal.numSubMenus);
				i++)
			{
				int isSelected = i == menu->u.normal.index;
				menu_t *subMenu = &menu->u.normal.subMenus[i];
				const char *name = subMenu->name;
				// TODO: display subfolders
				DisplayMenuItem(
					CenterX(CDogsTextWidth(name)), y, name, isSelected);

				if (isSelected)
				{
					char s[255];
					const char *filename = subMenu->u.campaign.filename;
					int isBuiltin = subMenu->u.campaign.isBuiltin;
					sprintf(s, "( %s )", isBuiltin ? "Internal" : filename);
					CDogsTextStringSpecial(
						s,
						TEXT_XCENTER | TEXT_BOTTOM,
						0,
						gGraphicsDevice.cachedConfig.ResolutionWidth / 12);
				}

				y += CDogsTextHeight();
			}

			if (i < menu->u.normal.numSubMenus - 1)
			{
				DisplayMenuItem(
					CenterX(CDogsTextWidth(ARROW_DOWN)),
					y + 2,
					ARROW_DOWN,
					0);
			}
		}
		break;
	case MENU_TYPE_KEYS:
		{
			int xKeys;
			x = CenterX((CDogsTextCharWidth('a') * 10)) / 2;
			xKeys = x * 3;
			yStart = (gGraphicsDevice.cachedConfig.ResolutionHeight / 2) - (CDogsTextHeight() * 10);

			for (i = 0; i < menu->u.normal.numSubMenus; i++)
			{
				int y = yStart + i * CDogsTextHeight();
				int isSelected = i == menu->u.normal.index;
				menu_t *subMenu = &menu->u.normal.subMenus[i];

				const char *name = subMenu->name;
				if (isSelected &&
					subMenu->type != MENU_TYPE_SET_OPTION_CHANGE_KEY)
				{
					CDogsTextStringWithTableAt(x, y, name, &tableFlamed);
				}
				else
				{
					CDogsTextStringAt(x, y, name);
				}

				if (subMenu->type == MENU_TYPE_SET_OPTION_CHANGE_KEY)
				{
					const char *keyName;
					if (menu->u.normal.changeKeyMenu == subMenu)
					{
						keyName = "Press a key";
					}
					else if (subMenu->u.changeKey.code == KEY_CODE_MAP)
					{
						keyName = SDL_GetKeyName(gConfig.Input.PlayerKeys[0].Keys.map);
					}
					else
					{
						keyName = SDL_GetKeyName(InputGetKey(
							subMenu->u.changeKey.keys,
							subMenu->u.changeKey.code));
					}
					DisplayMenuItem(xKeys, y, keyName, isSelected);
				}
			}
		}
		break;
	default:
		assert(0);
		break;
	}
}
示例#22
0
void AddSoldierToSectorGridNo( SOLDIERTYPE *pSoldier, INT16 sGridNo, UINT8 ubDirection, BOOLEAN fUseAnimation, UINT16 usAnimState, UINT16 usAnimCode )
{
	INT16 sWorldX, sWorldY;
	INT16 sNewGridNo;
	UINT8	ubNewDirection;
	UINT8	ubInsertionCode;
	BOOLEAN fUpdateFinalPosition = TRUE;


	// Add merc to gridno
	sWorldX = CenterX( sGridNo );
	sWorldY = CenterY( sGridNo );

	// Set reserved location!
	pSoldier->sReservedMovementGridNo = NOWHERE;

	// Save OLD insertion code.. as this can change...
	ubInsertionCode = pSoldier->ubStrategicInsertionCode;

	// Remove any pending animations
	pSoldier->usPendingAnimation = NO_PENDING_ANIMATION;
	pSoldier->usPendingAnimation2 = NO_PENDING_ANIMATION;
	pSoldier->ubPendingDirection = NO_PENDING_DIRECTION;
	pSoldier->ubPendingAction		 = NO_PENDING_ACTION;

	//If we are not loading a saved game
	if( (gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
	{
		// Set final dest to be the same...
		fUpdateFinalPosition = FALSE;
	}


	// If this is a special insertion location, get path!
	if ( ubInsertionCode == INSERTION_CODE_ARRIVING_GAME )
	{
		EVENT_SetSoldierPositionAndMaybeFinalDestAndMaybeNotDestination( pSoldier, sWorldX, sWorldY, fUpdateFinalPosition, fUpdateFinalPosition );
		EVENT_SetSoldierDirection( pSoldier, ubDirection );
		EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection );
	}
	else if ( ubInsertionCode == INSERTION_CODE_CHOPPER )
	{

	}
	else
	{
		EVENT_SetSoldierPositionAndMaybeFinalDestAndMaybeNotDestination( pSoldier, sWorldX, sWorldY, fUpdateFinalPosition, fUpdateFinalPosition );

		//if we are loading, dont set the direction ( they are already set )
		if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
		{
			EVENT_SetSoldierDirection( pSoldier, ubDirection );

			EVENT_SetSoldierDesiredDirection( pSoldier, ubDirection );
		}
	}

	if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
	{
		if ( !( pSoldier->uiStatusFlags & SOLDIER_DEAD ) )
		{
			if ( pSoldier->bTeam == gbPlayerNum )
			{
				RevealRoofsAndItems( pSoldier, TRUE, FALSE, pSoldier->bLevel, TRUE );

        // ATE: Patch fix: If we are in an non-interruptable animation, stop!
        if ( pSoldier->usAnimState == HOPFENCE )
        {
          pSoldier->fInNonintAnim = FALSE;
          SoldierGotoStationaryStance( pSoldier );
        }

				EVENT_StopMerc( pSoldier, sGridNo, ubDirection );
			}
		}

		// If just arriving, set a destination to walk into from!
		if ( ubInsertionCode == INSERTION_CODE_ARRIVING_GAME )
		{
			// Find a sweetspot near...
			sNewGridNo = FindGridNoFromSweetSpot( pSoldier, gMapInformation.sNorthGridNo, 4, &ubNewDirection );
			EVENT_GetNewSoldierPath( pSoldier, sNewGridNo, WALKING );		
		}

		// If he's an enemy... set presence
		if ( !pSoldier->bNeutral && (pSoldier->bSide != gbPlayerNum ) )
		{
      // ATE: Added if not bloodcats
      // only do this once they are seen.....
      if ( pSoldier->ubBodyType != BLOODCAT )
      {
			  SetEnemyPresence( );
      }
		}
	}

	if ( !( pSoldier->uiStatusFlags & SOLDIER_DEAD ) )
	{
		//if we are loading a 'pristine' map ( ie, not loading a saved game )
		if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
		{
			// ATE: Double check if we are on the roof that there is a roof there!
			if ( pSoldier->bLevel == 1 )
			{
				if ( !FindStructure( pSoldier->sGridNo, STRUCTURE_ROOF ) )
				{
					SetSoldierHeight( pSoldier, (FLOAT)( 0 )  );
				}
			}

			if ( ubInsertionCode != INSERTION_CODE_ARRIVING_GAME )
			{
				// default to standing on arrival
				if ( pSoldier->usAnimState != HELIDROP )
				{
					if ( fUseAnimation )
					{
						EVENT_InitNewSoldierAnim( pSoldier, usAnimState, usAnimCode, TRUE );
					}
					else if ( pSoldier->ubBodyType != CROW )
					{
						EVENT_InitNewSoldierAnim( pSoldier, STANDING, 1, TRUE );
					}
				}

				// ATE: if we are below OK life, make them lie down!
				if ( pSoldier->bLife < OKLIFE )
				{
					SoldierInSectorIncompaciated( pSoldier, pSoldier->sInsertionGridNo );
				}
				else if ( pSoldier->fMercAsleep == TRUE )
				{
					InternalSoldierInSectorSleep( pSoldier, pSoldier->sInsertionGridNo, FALSE );
				}
				else if ( pSoldier->bAssignment == PATIENT )
				{
					SoldierInSectorPatient( pSoldier, pSoldier->sInsertionGridNo );
				}
				else if ( pSoldier->bAssignment == DOCTOR )
				{
					SoldierInSectorDoctor( pSoldier, pSoldier->sInsertionGridNo );
				}
				else if ( pSoldier->bAssignment == REPAIR )
				{
					SoldierInSectorRepair( pSoldier, pSoldier->sInsertionGridNo );
				}

        // ATE: Make sure movement mode is up to date!
  			pSoldier->usUIMovementMode =  GetMoveStateBasedOnStance( pSoldier, gAnimControl[ pSoldier->usAnimState ].ubEndHeight );	

			}
		}
		else
		{
			// THIS ALL SHOULD HAVE BEEN HANDLED BY THE FACT THAT A GAME WAS LOADED

			//EVENT_InitNewSoldierAnim( pSoldier, pSoldier->usAnimState, pSoldier->usAniCode, TRUE );

			// if the merc had a final destination, get the merc walking there
			//if( pSoldier->sFinalDestination != pSoldier->sGridNo )
			//{
			//	EVENT_GetNewSoldierPath( pSoldier, pSoldier->sFinalDestination, pSoldier->usUIMovementMode );
			//}
		}
	}
}
示例#23
0
int SelectVolume(int cmd)
{
	static int index = 0;
	char s[10];
	int x, y;

	if (cmd == CMD_ESC)
		return MODE_MAIN;

	if (AnyButton(cmd) && index == VOLUME_COUNT - 1)
		return MODE_MAIN;

	if (Left(cmd)) {
		switch (index) {
			case 0:
				if (FXVolume() > 8)
					SetFXVolume(FXVolume() - 8);
				break;
			case 1:
				if (MusicVolume() > 8)
					SetMusicVolume(MusicVolume() - 8);
				break;
			case 2:
				if (FXChannels() > 2)
					SetFXChannels(FXChannels() - 2);
				break;
			case 3:
				break;
		}

		PlaySound(SND_SWITCH, 0, 255);
	} else if (Right(cmd)) {
		switch (index) {
			case 0:
				if (FXVolume() < 64)
					SetFXVolume(FXVolume() + 8);
				break;
			case 1:
				if (MusicVolume() < 64)
					SetMusicVolume(MusicVolume() + 8);
				break;
			case 2:
				if (FXChannels() < 8)
					SetFXChannels(FXChannels() + 2);
				break;
			case 3:
				break;
		}

		PlaySound(SND_SWITCH, 0, 255);
	} else if (Up(cmd)) {
		index--;

		if (index < 0)
			index = VOLUME_COUNT - 1;

		PlaySound(SND_SWITCH, 0, 255);
	} else if (Down(cmd)) {
		index++;

		if (index >= VOLUME_COUNT)
			index = 0;

		PlaySound(SND_SWITCH, 0, 255);
	}

	TextStringSpecial("Configure Sound:", TEXT_XCENTER | TEXT_TOP, 0, (SCREEN_WIDTH / 12));
	
	x = CenterX(MenuWidth(volumeMenu, VOLUME_COUNT));
	y = CenterY(MenuHeight(volumeMenu, VOLUME_COUNT));
	
	DisplayMenuAt(x - 20, y, volumeMenu, VOLUME_COUNT, index);
	
	x += MenuWidth(volumeMenu, VOLUME_COUNT);
	x += 10;	

	sprintf(s, "%d", FXVolume() / 8);
	TextStringAt(x, y, s);
	sprintf(s, "%d", MusicVolume() / 8);
	TextStringAt(x, y + TextHeight(), s);
	sprintf(s, "%d", FXChannels());
	TextStringAt(x, y + 2 * TextHeight(), s);
	TextStringAt(x, y + 3 * TextHeight(), "No");

	return MODE_VOLUME;
}
示例#24
0
文件: game.c 项目: insin/cdogs-wii
void StatusDisplay(void)
{
	char s[50];
	static time_t ot = -1;
	static time_t t = 0;
	static time_t td = 0;

	PlayerStatus(PLACE_LEFT, &gPlayer1Data, gPlayer1);
	if (gOptions.twoPlayers)
		PlayerStatus(PLACE_RIGHT, &gPlayer2Data, gPlayer2);

	if (!gPlayer1 && !gPlayer2) {
		if (!gCampaign.dogFight)
			TextStringAtCenter("Game Over!");
		else
			TextStringAtCenter("Double Kill!");
	}

	else if (MissionCompleted()) {
		sprintf(s, "Pickup in %d seconds\n",
			(gMission.pickupTime + 69) / 70);
		TextStringAtCenter(s);
	}

	if (gameIsPaused) {
		if (escExits)
			TextStringAtCenter("Press Esc again to quit");
		else
			TextStringAtCenter("Paused");
	}

	if (messageTicks > 0)
		TextStringSpecial(message, TEXT_XCENTER | TEXT_TOP, 0, 20);

	if (gOptions.displayFPS) {
		sprintf(s, "FPS: %d", fps);
		TextStringSpecial(s, TEXT_RIGHT | TEXT_BOTTOM, 10, 10);
	}
	if (gOptions.displayTime) {
		sprintf(s, "%02d:%02d", timeHours, timeMinutes);
		TextStringSpecial(s, TEXT_LEFT | TEXT_BOTTOM, 10, 10);
	}

#define KEY_WIDTH(n) (PicWidth(&cGeneralPics[gMission.keyPics[n]]))

	if (gMission.flags & FLAGS_KEYCARD_YELLOW)
		DrawKeycard(CenterX(KEY_WIDTH(0)) - 30, 20, &cGeneralPics[gMission.keyPics[0]]);
	if (gMission.flags & FLAGS_KEYCARD_GREEN)
		DrawKeycard(CenterX(KEY_WIDTH(1)) - 10, 20, &cGeneralPics[gMission.keyPics[1]]);
	if (gMission.flags & FLAGS_KEYCARD_BLUE)
		DrawKeycard(CenterX(KEY_WIDTH(2)) + 10, 20, &cGeneralPics[gMission.keyPics[2]]);
	if (gMission.flags & FLAGS_KEYCARD_RED)
		DrawKeycard(CenterX(KEY_WIDTH(3)) + 30, 20, &cGeneralPics[gMission.keyPics[3]]);

	if (ot == -1 || missionTime == 0) /* set the original time properly */
		ot = time(NULL);

	t = time(NULL);

	if (!gameIsPaused) {
		td = t - ot;
	}

	sprintf(s, "%d:%02d", (int)(td / 60), (int)(td % 60));
	TextStringSpecial(s, TEXT_TOP | TEXT_XCENTER, 0, 5);

	MissionStatus();
}
示例#25
0
int SelectCampaign(int dogFight, int cmd)
{
	static int campaignIndex = 0;
	static int dogfightIndex = 0;
	int count, x, y, i, j;
	struct FileEntry *list = dogFight ? dogfightList : campaignList;
	char *prefix = dogFight ? "dogfights/" : "missions/";
	int *index = dogFight ? &dogfightIndex : &campaignIndex;
	struct FileEntry *f;

	for (count = 0, f = list; f != NULL; f = f->next, count++);

	if (cmd == CMD_ESC)
		return MODE_MAIN;

	if (AnyButton(cmd)) {
		for (i = 0, f = list; f != NULL && i < *index;
		     f = f->next, i++);

		if (f && f->name[0]) {
			if (customSetting.missions)
				free(customSetting.missions);
			if (customSetting.characters)
				free(customSetting.characters);
			memset(&customSetting, 0, sizeof(customSetting));

			if (LoadCampaign(GetDataFilePath(join(prefix,f->name)), &customSetting, 0, 0) ==
			    CAMPAIGN_OK)
				gCampaign.setting = &customSetting;
			else
				SetupBuiltin(dogFight, 0);
		} else if (f)
			SetupBuiltin(dogFight, f->data);
		else {
			SetupBuiltin(dogFight, 0);
		}

//  gCampaign.seed = 0;
		PlaySound(SND_HAHAHA, 0, 255);
		printf(">> Entering MODE_PLAY\n");
		return MODE_PLAY;
	}
	
	if (Left(cmd) || Up(cmd)) {
		(*index)--;
		if (*index < 0)
			*index = count - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Right(cmd) || Down(cmd)) {
		(*index)++;
		if (*index >= count)
			*index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}	
	
	if (dogFight)
		TextStringSpecial("Select a dogfight scenario:", TEXT_TOP | TEXT_XCENTER, 0, (SCREEN_WIDTH / 12));
	else
		TextStringSpecial("Select a campaign:", TEXT_TOP | TEXT_XCENTER, 0, (SCREEN_WIDTH / 12));

	x = CenterX(240);
	y = CenterY(12 * TextHeight());
	
#define ARROW_UP	"\036"
#define ARROW_DOWN	"\037"
	
	for (i = 0, f = list; f != NULL && i <= *index - 12; f = f->next, i++);

	if (i)
		DisplayMenuItem(CenterX(TextWidth(ARROW_UP)), y - 2 - TextHeight(), ARROW_UP, 0);

	for (j = 0; f != NULL && j < 12; f = f->next, i++, j++) {
		DisplayMenuItem(CenterX(TextWidth(f->info)), y, f->info, i == *index);
		
		if (i == *index) {
			char s[255];

			if (strlen(f->name) == 0)
				sprintf(s, "( Internal )");
			else
				sprintf(s, "( %s )", f->name);

			TextStringSpecial(s, TEXT_XCENTER | TEXT_BOTTOM, 0, (SCREEN_WIDTH / 12));
		}
			
		y += TextHeight();
	}

	if (f)
		DisplayMenuItem(CenterX(TextWidth(ARROW_DOWN)), y + 2, ARROW_DOWN, 0);
		
	return dogFight ? MODE_DOGFIGHT : MODE_CAMPAIGN;
}
示例#26
0
void KariudoKen::_Move()
{
	SetAnim( mStatus );

	// 自機の位置を取得
	int jx = GAMECONTROL->GetJiki()->GetAtHtPointX();
	int jy = GAMECONTROL->GetJiki()->GetAtHtPointY();

	// ----当たりの処理
	MapAtHt();

	if( mStatus != SHINDA )
		Ataridp();


	switch( mStatus ){
		case ARUKI: {
			// ----自機の位置を確認
			float sax = jx - CenterX();
			float say = jy - CenterY();
			float sa = sqrt(sax*sax + say*say);

			if( sa < KARIKENKGHANI ){
				mStatus = WAIT1;
			}

			break;
		}
		
		case WAIT1:
			mSpX = 0;
			WAIT_TIMER(mKgTimer, KARIKENWTM1);
			mStatus = KOGEKI;
			WAIT_END
			break;

		case KOGEKI:
			if( mAniNoX == 2 &&  !mSeFl ){//SE
				//SE
				if( !IsGamenGai() )
					GAMECONTROL->GetSoundController()->PlaySE("audio\\se\\se_ken_atack.wav");
				mSeFl = true;
			}
			mSpX = 0;
			mMuki = CenterX() < jx;
			if( mDousaEnd ){
				mStatus = WAIT2;
				mSeFl = false;
			}
			break;
	
		case WAIT2:
			mSpX = 0;
			WAIT_TIMER(mKgTimer, KARIKENWTM2);
			mStatus = ARUKI;
			WAIT_END
			break;
	}
	
	Draw();

	mSpX += mAccX;
	mSpY += mAccY;
	mX	 += mSpX + mAshibaSpX;
	mY	 += mSpY;

	// 当たり判定のフレーム
	if( mStatus != SHINDA )
		HtFrame();
}
示例#27
0
static int NameSelection(int x, int index, struct PlayerData *data,
			 int cmd)
{
	int i;
	int y;

	char s[2];
	static char letters[] =
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ !#?:.-0123456789";
	static char smallLetters[] =
		"abcdefghijklmnopqrstuvwxyz !#?:.-0123456789";
	static int selection[2] = { -1, -1 };

	// Kludge since Watcom won't let me initialize selection with a strlen()
	if (selection[0] < 0)
		selection[0] = selection[1] = strlen(letters);

	if (cmd & CMD_BUTTON1) {
		if (selection[index] == strlen(letters)) {
			PlaySound(SND_LAUNCH, 0, 255);
			return 0;
		}

		if (strlen(data->name) < sizeof(data->name) - 1) {
			int l = strlen(data->name);
			data->name[l + 1] = 0;
			if (l > 0 && data->name[l - 1] != ' ')
				data->name[l] =
				    smallLetters[selection[index]];
			else
				data->name[l] = letters[selection[index]];
			PlaySound(SND_MACHINEGUN, 0, 255);
		} else
			PlaySound(SND_KILL, 0, 255);
	} else if (cmd & CMD_BUTTON2) {
		if (data->name[0]) {
			data->name[strlen(data->name) - 1] = 0;
			PlaySound(SND_BANG, 0, 255);
		} else
			PlaySound(SND_KILL, 0, 255);
	} else if (cmd & CMD_LEFT) {
		if (selection[index] > 0) {
			selection[index]--;
			PlaySound(SND_DOOR, 0, 255);
		}
	} else if (cmd & CMD_RIGHT) {
		if (selection[index] < strlen(letters)) {
			selection[index]++;
			PlaySound(SND_DOOR, 0, 255);
		}
	} else if (cmd & CMD_UP) {
		if (selection[index] > 9) {
			selection[index] -= 10;
			PlaySound(SND_DOOR, 0, 255);
		}
	} else if (cmd & CMD_DOWN) {
		if (selection[index] < strlen(letters) - 9) {
			selection[index] += 10;
			PlaySound(SND_DOOR, 0, 255);
		} else if (selection[index] < strlen(letters)) {
			selection[index] = strlen(letters);
			PlaySound(SND_DOOR, 0, 255);
		}
	}

	#define ENTRY_COLS	10
	#define	ENTRY_SPACING	12
	
	y = CenterY(((TextHeight() * ((strlen(letters) - 1) / ENTRY_COLS) )));

	if (gOptions.twoPlayers && index == CHARACTER_PLAYER1)
		x = CenterOf(0, (SCREEN_WIDTH / 2), ((ENTRY_SPACING * (ENTRY_COLS - 1)) + TextCharWidth('a')));
	else if (gOptions.twoPlayers && index == CHARACTER_PLAYER2)
		x = CenterOf((SCREEN_WIDTH / 2), (SCREEN_WIDTH), ((ENTRY_SPACING * (ENTRY_COLS - 1)) + TextCharWidth('a')));
	else
		x = CenterX(((ENTRY_SPACING * (ENTRY_COLS - 1)) + TextCharWidth('a')));

	// Draw selection

	s[1] = 0;
	for (i = 0; i < strlen(letters); i++) {
		s[0] = letters[i];

		TextGoto(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			 y + (i / ENTRY_COLS) * TextHeight());

		if (i == selection[index])
			TextCharWithTable(letters[i], &tableFlamed);
		else
			TextChar(letters[i]);
/*
		DisplayMenuItem(x + (i % 10) * 12,
				80 + (i / 10) * TextHeight(), s,
				i == selection[index]);
*/
	}

	DisplayMenuItem(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			y + (i / ENTRY_COLS) * TextHeight(),
			endChoice, i == selection[index]);

	return 1;
}