Example #1
0
static BOOLEAN
RestartMenu (MENU_STATE *pMS)
{
	TimeCount TimeOut;

	ReinitQueue (&race_q[0]);
	ReinitQueue (&race_q[1]);

	SetContext (ScreenContext);

	GLOBAL (CurrentActivity) |= CHECK_ABORT;
	if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
			&& GET_GAME_STATE (UTWIG_BOMB_ON_SHIP)
			&& !GET_GAME_STATE (UTWIG_BOMB))
	{	// player blew himself up with Utwig bomb
		SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0);

		SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND / 8)
				+ ONE_SECOND / 60);
		SetContextBackGroundColor (
				BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
		ClearDrawable ();
		FlushColorXForms ();

		TimeOut = ONE_SECOND / 8;
	}
	else
	{
		TimeOut = ONE_SECOND / 2;

		if (LOBYTE (LastActivity) == WON_LAST_BATTLE)
		{
			GLOBAL (CurrentActivity) = WON_LAST_BATTLE;
			Victory ();
			Credits (TRUE);

			FreeGameData ();
			
			GLOBAL (CurrentActivity) = CHECK_ABORT;
		}
	}

	LastActivity = 0;
	NextActivity = 0;

	// TODO: This fade is not always necessary, especially after a splash
	//   screen. It only makes a user wait.
	SleepThreadUntil (FadeScreen (FadeAllToBlack, TimeOut));
	if (TimeOut == ONE_SECOND / 8)
		SleepThread (ONE_SECOND * 3);

	pMS->CurFrame = CaptureDrawable (LoadGraphic (RESTART_PMAP_ANIM));

	DrawRestartMenuGraphic (pMS);
	GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
	SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
	SetDefaultMenuRepeatDelay ();
	DoInput (pMS, TRUE);
	
	StopMusic ();
	if (pMS->hMusic)
	{
		DestroyMusic (pMS->hMusic);
		pMS->hMusic = 0;
	}

	Flash_terminate (pMS->flashContext);
	pMS->flashContext = 0;
	DestroyDrawable (ReleaseDrawable (pMS->CurFrame));
	pMS->CurFrame = 0;

	if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
		return (FALSE); // timed out

	if (GLOBAL (CurrentActivity) & CHECK_ABORT)
		return (FALSE); // quit

	TimeOut = FadeScreen (FadeAllToBlack, ONE_SECOND / 2);
	
	SleepThreadUntil (TimeOut);
	FlushColorXForms ();

	SeedRandomNumbers ();

	return (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE);
}
Example #2
0
static BOOLEAN
RestartMenu (PMENU_STATE pMS)
{
	DWORD TimeOut;
	BYTE black_buf[1];

	ReinitQueue (&race_q[0]);
	ReinitQueue (&race_q[1]);

	black_buf[0] = FadeAllToBlack;

	SetContext (ScreenContext);

	GLOBAL (CurrentActivity) |= CHECK_ABORT;
	if (GLOBAL_SIS (CrewEnlisted) == (COUNT)~0
			&& GET_GAME_STATE (UTWIG_BOMB_ON_SHIP)
			&& !GET_GAME_STATE (UTWIG_BOMB))
	{	// player blew himself up with Utwig bomb
		BYTE white_buf[] = {FadeAllToWhite};

		SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 0);

		SleepThreadUntil (XFormColorMap ((COLORMAPPTR)white_buf,
				ONE_SECOND / 8) + ONE_SECOND / 60);
		SetContextBackGroundColor (BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
		ClearDrawable ();
		FlushColorXForms ();

		TimeOut = ONE_SECOND / 8;
	}
	else
	{
		TimeOut = ONE_SECOND / 2;

		if (LOBYTE (LastActivity) == WON_LAST_BATTLE)
		{
			GLOBAL (CurrentActivity) = WON_LAST_BATTLE;
			Victory ();
			Credits (TRUE);

			FreeGameData ();
			
			TimeOut = ONE_SECOND / 2;
			GLOBAL (CurrentActivity) = CHECK_ABORT;
		}
	}

	LastActivity = NextActivity = 0;

	SleepThreadUntil (XFormColorMap ((COLORMAPPTR)black_buf, TimeOut));
	if (TimeOut == ONE_SECOND / 8)
		SleepThread (ONE_SECOND * 3);
	DrawRestartMenuGraphic (pMS);
	FlushInput ();
	GLOBAL (CurrentActivity) &= ~CHECK_ABORT;
	SetMenuSounds (MENU_SOUND_UP | MENU_SOUND_DOWN, MENU_SOUND_SELECT);
	DoInput (pMS, TRUE);
	
	StopMusic ();
	if (pMS->hMusic)
	{
		DestroyMusic (pMS->hMusic);
		pMS->hMusic = 0;
	}

	LockMutex (GraphicsLock);
	SetFlashRect (NULL_PTR, (FRAME)0);
	UnlockMutex (GraphicsLock);
	DestroyDrawable (ReleaseDrawable (pMS->CurFrame));

	if (GLOBAL (CurrentActivity) == (ACTIVITY)~0)
		return (FALSE); // timed out

	if (GLOBAL (CurrentActivity) & CHECK_ABORT)
		return (FALSE); // quit

	TimeOut = XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND / 2);
	
	SleepThreadUntil (TimeOut);
	FlushColorXForms ();

	SeedRandomNumbers ();

	return (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE);
}
Example #3
0
/*
===================
=
= GameLoop
=
===================

This function controls the flow between states of the game.

It loads previous saved games, setup levels states, controls the
flow between levels, including when player loses or when completes the game,
and checks if the result of the current game is a highscore.

The "real" game loop (player actions in like moving, killing, etc.) is in the
PlayLoop function.
*/
void GameLoop (void)
{
	int i,xl,yl,xh,yh;
	char num[20];
	boolean	died;
#ifdef MYPROFILE
	/* clock_t type variables
	   may register times, 
		start and and times 
		could be used to measure 
		the speed of the graphics system.
		Speed is measured in fps- frames per second.
*/
	clock_t start,end;
#endif

restartgame:
	ClearMemory (); 
	SETFONTCOLOR(0,15);
	DrawPlayScreen ();
	died = false;
restart:
	do
	{
		if (!loadedgame)
		  gamestate.score = gamestate.oldscore;
		DrawScore();

		startgame = false;
		if (loadedgame)
			loadedgame = false;
		else
			SetupGameLevel ();

#ifdef SPEAR
		if (gamestate.mapon == 20)	// give them the key allways
		{
			gamestate.keys |= 1;
			DrawKeys ();
		}
#endif

		ingame = true;
		StartMusic ();
		PM_CheckMainMem ();
		if (!died)
			PreloadGraphics ();
		else
			died = false;

		fizzlein = true;
		DrawLevel ();

startplayloop:
		PlayLoop ();

#ifdef SPEAR
		if (spearflag)
		{
			SD_StopSound();
			SD_PlaySound(GETSPEARSND);
			if (DigiMode != sds_Off)
			{
				long lasttimecount = TimeCount;

				while(TimeCount < lasttimecount+150)
				//while(DigiPlaying!=false)
					SD_Poll();
			}
			else
				SD_WaitSoundDone();

			ClearMemory ();
			gamestate.oldscore = gamestate.score;
			gamestate.mapon = 20;
			SetupGameLevel ();
			StartMusic ();
			PM_CheckMainMem ();
			player->x = spearx;
			player->y = speary;
			player->angle = spearangle;
			spearflag = false;
			Thrust (0,0);
			goto startplayloop;
		}
#endif

		StopMusic ();
		ingame = false;

		if (demorecord && playstate != ex_warped)
			FinishDemoRecord ();

		if (startgame || loadedgame)
			goto restartgame;

		switch (playstate)
		{
		case ex_completed:
		case ex_secretlevel:
			gamestate.keys = 0;
			DrawKeys ();
			VW_FadeOut ();

			ClearMemory ();

			LevelCompleted ();		// do the intermission
#ifdef SPEARDEMO
			if (gamestate.mapon == 1)
			{
				died = true;			// don't "get psyched!"

				VW_FadeOut ();

				ClearMemory ();

				CheckHighScore (gamestate.score,gamestate.mapon+1);

				#pragma warn -sus
				#ifndef JAPAN
				_fstrcpy(MainMenu[viewscores].string,STR_VS);
				#endif
				MainMenu[viewscores].routine = CP_ViewScores;
				#pragma warn +sus

				return;
			}
#endif

#ifdef JAPDEMO
			if (gamestate.mapon == 3)
			{
				died = true;			// don't "get psyched!"

				VW_FadeOut ();

				ClearMemory ();

				CheckHighScore (gamestate.score,gamestate.mapon+1);

				#pragma warn -sus
				#ifndef JAPAN
				_fstrcpy(MainMenu[viewscores].string,STR_VS);
				#endif
				MainMenu[viewscores].routine = CP_ViewScores;
				#pragma warn +sus

				return;
			}
#endif

			gamestate.oldscore = gamestate.score;

#ifndef SPEAR
			//
			// COMING BACK FROM SECRET LEVEL
			//
			if (gamestate.mapon == 9)
				gamestate.mapon = ElevatorBackTo[gamestate.episode];	// back from secret
			else
			//
			// GOING TO SECRET LEVEL
			//
			if (playstate == ex_secretlevel)
				gamestate.mapon = 9;
#else

#define FROMSECRET1		3
#define FROMSECRET2		11

			//
			// GOING TO SECRET LEVEL
			//
			if (playstate == ex_secretlevel)
				switch(gamestate.mapon)
				{
				 case FROMSECRET1: gamestate.mapon = 18; break;
				 case FROMSECRET2: gamestate.mapon = 19; break;
				}
			else
			//
			// COMING BACK FROM SECRET LEVEL
			//
			if (gamestate.mapon == 18 || gamestate.mapon == 19)
				switch(gamestate.mapon)
				{
				 case 18: gamestate.mapon = FROMSECRET1+1; break;
				 case 19: gamestate.mapon = FROMSECRET2+1; break;
				}
#endif
			else
			//
			// GOING TO NEXT LEVEL
			//
				gamestate.mapon++;


			break;

		case ex_died:
			Died ();
			died = true;			// don't "get psyched!"

			if (gamestate.lives > -1)
				break;				// more lives left

			VW_FadeOut ();

			ClearMemory ();

			CheckHighScore (gamestate.score,gamestate.mapon+1);

			#pragma warn -sus
			#ifndef JAPAN
			_fstrcpy(MainMenu[viewscores].string,STR_VS);
			#endif
			MainMenu[viewscores].routine = CP_ViewScores;
			#pragma warn +sus

			return;

		case ex_victorious:

#ifndef SPEAR
			VW_FadeOut ();
#else
			VL_FadeOut (0,255,0,17,17,300);
#endif
			ClearMemory ();

			Victory ();

			ClearMemory ();

			CheckHighScore (gamestate.score,gamestate.mapon+1);

			#pragma warn -sus
			#ifndef JAPAN
			_fstrcpy(MainMenu[viewscores].string,STR_VS);
			#endif
			MainMenu[viewscores].routine = CP_ViewScores;
			#pragma warn +sus

			return;

		default:
			ClearMemory ();
			break;
		}

	} while (1);

}
Example #4
0
int main()
{
   bool fl_end			= false,							// индикатор конца игры
   fl_hod_gamer	= false,							// индикатор хода игрока
   fl_hod_comp		= false,							// индикатор хода компа
   fl_err			= false;							// индикатор ошибки
   int a=0,b=0/*,end*/,                                            // просто переменные
   Npos=-1,                                           // номер известной позиции
   win=0,                                              // победитель
   count=1,                                            // счётчик ходов
   gamerX=-1,                                         // столбик игрока
   gamerY=-1,                                         // строка игрока
   compX=-1,                                          // столбик компа
   compY=-1;                                          // строка компа

   sys_clear_screen();
   printf_color(0x0d, "X-O by Denis Zgursky, 2005\nHelloOS port by Ilya Skriblovsky\n\n");
   printf_color(0x0d, "Controls:\n  W\nA S D   Enter\n\n");

   while(fl_end==false && count<=5)
   {
      // выводим сетку
      draw_field();

      //      int i;
      //      for( i=0;i<8;i++)
      //      {
      //         int j;
      //         for( j=0;j<8;j++)
      //            printf("%c",setka[i][j]);
      //         printf("\n");
      //      }

      // "обнуляем" переменные

      fl_hod_gamer=false;
      fl_hod_comp=false;
      gamerX=-1;
      gamerY=-1;
      compX=-1;
      compY=-1;

      // ход игрока: заполняем Field и setka

      while(fl_hod_gamer==false)
      {
         while (1)
         {
            char k = sys_getch();
            if (k == 0x0d)
            {
               gamerY = cury;
               gamerX = curx;
               break;
            }
            switch (k)
            {
               case 'w': if (cury > 0) cury--; break;
               case 's': if (cury < 2) cury++; break;
               case 'a': if (curx > 0) curx--; break;
               case 'd': if (curx < 2) curx++; break;
            }
            draw_field();
         }


         if(Field[gamerY][gamerX]==0)
         {
            Field[gamerY][gamerX]=2;
            switch(gamerY)
            {
               case 0:
                  b=gamerY+2;
                  break;
               case 1:
                  b=gamerY+3;
                  break;
               case 2:
                  b=gamerY+4;
                  break;
            }
            switch(gamerX)
            {
               case 0:
                  a=gamerX+2;
                  break;
               case 1:
                  a=gamerX+3;
                  break;
               case 2:
                  a=gamerX+4;
                  break;
            }
            setka[b][a]='X';
            fl_hod_gamer=true;
         }
         //         }
   }

   // если пятый ход, то проверяем на возможность победы и заканчиваем

   if(count==5)
   {
      fl_end=true;
      fl_hod_comp=true;
      win=Victory(Field);
   }

   // анализ первого хода

   if(count==1)
   {
      if((gamerY==0 && gamerX==0) ||
            (gamerY==0 && gamerX==2) ||
            (gamerY==2 && gamerX==0) ||
            (gamerY==2 && gamerX==2))
      {
         compY=1;
         compX=1;
      }
      if((gamerY==0 && gamerX==1) ||
            (gamerY==2 && gamerX==1))
      {
         compY=gamerY;
         compX=gamerX-1;
      }
      if((gamerY==1 && gamerX==0) ||
            (gamerY==1 && gamerX==2))
      {
         compY=gamerY+1;
         compX=gamerX;
      }
      if(gamerY==1 && gamerX==1)
      {
         compY=0;
         compX=2;
      }
      fl_hod_comp=true;
   }

   // проверка на выигрыш/проигрыш

   if(fl_hod_comp==false)
   {
      win=Victory(Field);
      if(win==1 || win==2)
      {
         fl_hod_comp=true;
         fl_end=true;
      }
   }

   // проверка на возможность выигрыша

   if(fl_hod_comp==false)
   {
      opr(Field,1,&compY,&compX);
      if(compY!=-1 && compX!=-1) fl_hod_comp=true;
   }

   // прверка на возможность проигрыша

   if(fl_hod_comp==false)
   {
      opr(Field,2,&compY,&compX);
      if(compY!=-1 && compX!=-1) fl_hod_comp=true;
   }

   // прверка на схожесть с известной позицией

   if(fl_hod_comp==false)
   {
      Npos=pos(Field);
      if(Npos!=-1)
      {
         prod(Npos,&compY,&compX);
         fl_hod_comp=true;
      }
   }

   // просто ход

   if(fl_hod_comp==false)
   {
      hod(Field,&compY,&compX);
      fl_hod_comp=true;
   }

   // заносим запись в Field и в setka, иначе ошибка

   if(fl_hod_comp==true && fl_end==false && compY!=-1 && compX!=-1)
   {
      Field[compY][compX]=1;
      switch(compY)
      {
         case 0:
            b=compY+2;
            break;
         case 1:
            b=compY+3;
            break;
         case 2:
            b=compY+4;
            break;
      }
      switch(compX)
      {
         case 0:
            a=compX+2;
            break;
         case 1:
            a=compX+3;
            break;
         case 2:
            a=compX+4;
            break;
      }
      setka[b][a]='O';
   }
   else
   {
      if(fl_end==false)
      {
         fl_err=true;
         fl_end=true;
      }
   }

   // проверяем не победил ли комп после своего хода

   if(fl_err==false && fl_hod_comp==true)
   {
      win=Victory(Field);
      if(win==1 || win==2)
         fl_end=true;
   }
   count++;
}

// если нет ошибки то выводим результат

if(fl_err==false)
{
   int i;
   for( i=0;i<8;i++)
   {
      int j;
      for( j=0;j<8;j++)
         printf("%c",setka[i][j]);
      printf("\n");
   }
   switch(win)
   {
      case 0:
         printf("Drawn game\n");
         break;
      case 1:
         printf("I win! :)\n");
         break;
      case 2:
         printf("Your win! :(\n");
         break;
   }
}
else
{
   printf("Error!Sorry!");
}

return 0;
}
Example #5
0
int *Think(int x,int y)
{
    int Coor[2]= {},LandForm[8][6]= {},m=0,n=0,t=0;
    struct Chess_unit *TK_unit,Current;

    Current.x=x;                             /* 将当前的棋子坐标存到 current 结构体中 */
    Current.y=y;

    for(m=y; m>y-5; m--)                     /* 向上扫描 */
    {
        n++;
        if(m<0)  break;
        LandForm[0][n]=Coording[x][m];
        fprintf(fp_out," %d:%d=%d ",x,m,LandForm[0][n]);
    }
    fprintf(fp_out,"\n");
    n=0;
    for(m=y; m<y+5; m++)                    /* 向下扫描 */
    {
        n++;
        if(m>15) break;
        LandForm[1][n]=Coording[x][m];
        fprintf(fp_out," %d:%d=%d ",x,m,LandForm[1][n]);
    }
    fprintf(fp_out,"\n");
    n=0;
    for(m=x; m>x-5; m--)                    /* 向左扫描 */
    {
        n++;
        if(m<0) break;
        LandForm[2][n]=Coording[m][y];
        fprintf(fp_out," %d:%d=%d ",m,y,LandForm[2][n]);
    }
    fprintf(fp_out,"\n");
    n=0;
    for(m=x; m<x+5; m++)                   /* 向右扫描 */
    {
        n++;
        if(m>15)  break;
        LandForm[3][n]=Coording[m][y];
        fprintf(fp_out," %d:%d=%d ",m,y,LandForm[3][n]);
    }
    fprintf(fp_out,"\n");
    n=0;
    for(m=x,t=y; m>x-5; m--,t--)           /* 向左上扫描 */
    {
        n++;
        if(m<0||t<0) break;
        LandForm[4][n]=Coording[m][t];
        fprintf(fp_out," %d:%d=%d ",m,t,LandForm[4][n]);
    }
    fprintf(fp_out,"\n");
    n=0;
    for(m=x,t=y; m<x+5; m++,t++)           /* 向右下扫描 */
    {
        n++;
        if(m>15||t>15)  break;
        LandForm[5][n]=Coording[m][t];
        fprintf(fp_out," %d:%d=%d ",m,t,LandForm[5][n]);
    }
    fprintf(fp_out,"\n");
    n=0;
    for(m=x,t=y; m<x+5; m++,t--)           /* 向右上扫描 */
    {
        n++;
        if(m>15||t<0)  break;
        LandForm[6][n]=Coording[m][t];
        fprintf(fp_out," %d:%d=%d ",m,t,LandForm[6][n]);
    }
    fprintf(fp_out,"\n");
    n=0;
    for(m=x,t=y; m>x-5; m--,t++)           /* 向左下扫描 */
    {
        n++;
        if(m<0||t>15)  break;
        LandForm[7][n]=Coording[m][t];
        fprintf(fp_out," %d:%d=%d ",m,t,LandForm[7][n]);
    }
    fprintf(fp_out,"\n");

    Victory(LandForm);   /* 调用本函数判断是否赢棋 */



    Coor[0]=(1+rand()%14)*30+5;
    Coor[1]=(1+rand()%14)*30+5;
    return Coor;
}
Example #6
0
void CheckKeys (void)
{
	//extern id0_boolean_t autofire;

	if (screenfaded)			// don't do anything with a faded screen
		return;

#if 0
//
// pause key wierdness can't be checked as a scan code
//
	if (Paused)
	{
		CenterWindow (8,3);
		US_PrintCentered ("PAUSED");
		VW_UpdateScreen ();
//		SD_MusicOff();
		IN_Ack();
//		SD_MusicOn();
		Paused = false;
		// (REFKEEN) Minor difference from vanilla Catacomb
		if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL);	// Clear accumulated mouse movement
		//if (MousePresent) Mouse(MDelta);	// Clear accumulated mouse movement
	}
	else
	if (Keyboard[sc_Enter])			// P = pause with no screen disruptioon
	{
//		SD_MusicOff();
		DisplaySMsg("PAUSED",NULL);
		IN_Ack();
//		SD_MusicOn();
		// (REFKEEN) Minor difference from vanilla Catacomb
		if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL);	// Clear accumulated mouse movement
		//if (MousePresent) Mouse(MDelta);	// Clear accumulated mouse movement
	}
	else
	if (Keyboard[sc_S])
	{
		id0_char_t *Text[] = {{"Slow Mode ON"},{"Slow Mode OFF"}};

		SlowMode ^= 1;
		extravbls = SlowMode << 3;
		CenterWindow (8,3);
		US_PrintCentered (Text[SlowMode]);
		VW_UpdateScreen ();
//		SD_MusicOff();
		IN_Ack();
//		SD_MusicOn();
		// (REFKEEN) Minor difference from vanilla Catacomb
		if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL);	// Clear accumulated mouse movement
		//if (MousePresent) Mouse(MDelta);	// Clear accumulated mouse movement
	}
#endif


// F2 - SOUND OPTIONS
//
	if (Keyboard[sc_F2])
	{
		id0_int_t height=7;
		id0_boolean_t ChoiceMade = false;

		if (AdLibPresent)
			height++;

		VW_FixRefreshBuffer();
		CenterWindow(22,height);
		US_Print( "\n        1 )  NO SOUND \n");
		US_Print(   "        2 )  PC  AUDIO \n");

		if (AdLibPresent)
			US_Print("        3 ) ADLIB AUDIO\n");

		US_Print( "\n       ESC)    EXIT    ");
		VW_UpdateScreen();

		// REFKEEN - Alternative controllers support
		extern BE_ST_ControllerMapping g_ingame_altcontrol_mapping_soundoptions;
		g_ingame_altcontrol_mapping_soundoptions.buttons[BE_ST_CTRL_BUT_X].mapClass = AdLibPresent ? BE_ST_CTRL_MAP_KEYSCANCODE : BE_ST_CTRL_MAP_NONE; // A bit of patching
		BE_ST_AltControlScheme_Push();
		BE_ST_AltControlScheme_PrepareControllerMapping(&g_ingame_altcontrol_mapping_soundoptions);

		// Switch audio device ON/OFF & load sounds if there
		// was a change in the device.

		do {

			if (Keyboard[1]) 								// ESC - Exit
				ChoiceMade = true;
			else
			if (Keyboard[2]) 							 	// 1 - No Sound
			{
				SD_SetSoundMode(sdm_Off);
				ChoiceMade = true;
			}
			else
			if (Keyboard[3])  							// 2 - PC Audio
			{
				SD_SetSoundMode(sdm_PC);
//				if (oldsoundmode != sdm_PC)
					CA_LoadAllSounds();
				ChoiceMade = true;
			}
			else
			if ((Keyboard[4]) &&	AdLibPresent)		// 3 - AdLib Audio
			{
				SD_SetSoundMode(sdm_AdLib);
//				if (oldsoundmode != sdm_AdLib)
					CA_LoadAllSounds();
				ChoiceMade = true;
			}

			BE_ST_ShortSleep();

		} while (!ChoiceMade);

		// REFKEEN - Alternative controllers support
		BE_ST_AltControlScheme_Pop();

		tics = realtics = 1;
		IN_ClearKeysDown();
	}

// F5 - CALIBRATE JOYSTICK
//
	if (Keyboard[sc_F5])
	{
		CalibrateJoystick(0);
		tics = realtics = 1;
		IN_ClearKeysDown();
	}

deadloop:;
// ESCAPE - quits game
//
	if ((Keyboard[sc_Escape]) || (Flags & FL_DEAD))
	{
		id0_char_t ch;

		DisplaySMsg("Options", NULL);
		status_flag = S_NONE;


		if (Flags & FL_DEAD)
		{
			id0_char_t choices[] = {sc_Escape,sc_R,sc_N,sc_Q,0};
			ch = DisplayMsg("Restore          New          Quit",choices);
		}
		else
		{
			id0_char_t choices[] = {sc_Escape,sc_S,sc_R,sc_N,sc_Q,0};
			ch = DisplayMsg("Save       Restore       New       Quit",choices);
		}
		DrawText(true);

		switch (ch)
		{
			case sc_S:
				if (!(Flags & FL_DEAD))
					Keyboard[sc_F3] = true;
			break;

			case sc_R:
				Keyboard[sc_F4] = true;
			break;

			case sc_N:
				DisplaySMsg("Starting anew", NULL);
				VW_WaitVBL(60);
				playstate = ex_resetgame;
				Flags &= ~FL_DEAD;
			break;

			case sc_Q:
				// REFKEEN - Alternative controllers support
				{
					extern BE_ST_ControllerMapping g_ingame_altcontrol_mapping_inackback;
					BE_ST_AltControlScheme_Push();
					BE_ST_AltControlScheme_PrepareControllerMapping(&g_ingame_altcontrol_mapping_inackback);
					// REFKEEN - We don't pop this since we quit...
				}
				DisplaySMsg("FARE THEE WELL!", NULL);
				VW_WaitVBL(120);
				if (!Flags & FL_QUICK)
					VW_FadeOut();
				NormalScreen();
				FreeUpMemory();
				Quit(NULL);
			break;
		}
		tics = realtics = 1;
	}

// F1 - DISPLAY HELP
//
	if (Keyboard[sc_F1])
	{
		PrintHelp();

#ifdef TEXT_PRESENTER

		extern PresenterInfo MainHelpText;

		VW_FadeOut();

		FreeUpMemory();
		if (!LoadPresenterScript("HELP.TXT",&MainHelpText))
		{
			VW_FadeIn();
			CenterWindow(30,5);
			US_CPrint("\nError loading HELP file.\n");
			US_CPrint("Press any key.");
			IN_Ack();
			VW_FadeOut();
		}
		else
		{
			VW_SetSplitScreen(200);
			bufferofs = displayofs = screenloc[0];
			VW_Bar(0,0,320,200,0);

			Display640();
			Presenter(&MainHelpText);
			Display320();
		}
		FreePresenterScript(&MainHelpText);
#endif
		VW_SetSplitScreen(120);
		VW_SetScreen(screenloc[0],0);
		screenpage = 0;
		CacheScaleds();

		bufferofs = 0;
		RedrawStatusWindow();
		ThreeDRefresh();
		VW_FadeIn();
		Keyboard[sc_F1] = false;
		tics = realtics = 1;
		IN_ClearKeysDown();
	}

// F3 - SAVE GAME
//
	if ((Keyboard[sc_F3]) && (!(Flags & FL_DEAD)))
	{
		PreFullDisplay();
		GE_SaveGame();
		PostFullDisplay(true);
		tics = realtics = 1;
		IN_ClearKeysDown();
	}

// F4 - LOAD GAME
//
	if (Keyboard[sc_F4])
	{
		PreFullDisplay();
		if (GE_LoadGame())
		{
			loadedgame = true;
			playstate = ex_loadedgame;
			Flags &= ~FL_DEAD;
			lasttext = -1;
			PostFullDisplay(false);
		}
		else
		if (playstate == ex_victorious)
		{
			PostFullDisplay(false);
			Victory(false);
			IN_Ack();
//			gamestate.mapon++;
		}
		else
			PostFullDisplay(true);
		Keyboard[sc_F5] = false;
		tics = realtics = 1;
		IN_ClearKeysDown();
	}

	if (Flags & FL_DEAD)
		goto deadloop;

//
// F10-? debug keys
//
	if (Keyboard[sc_BackSpace])
	{
		DebugKeys();
		// (REFKEEN) Minor difference from vanilla Catacomb
		if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL);	// Clear accumulated mouse movement
		//if (MousePresent) Mouse(MDelta);	// Clear accumulated mouse movement
		lasttimecount = SD_GetTimeCount();
	}
}
Example #7
0
boolean MouseHandler(Game *game, unsigned int mousePressed, int x, int y)
{
	MSGERROR err;
	COORD coord;
	int i, j;
	int distance;
	int boardsize;
	int checker;
	CheckerState state; 
	int playerID;
	PlayerList *plist;
	Player *player;

	if (!game) return 0;
	switch(game->gamestate)
	{
	case GAME_NEWGAME:
		ERRCALL(GetPlayerList(&game->board, &plist));
		
		GetBoardSize(&game->board, &boardsize);
		distance = (BOARDGAME_MAXWIDTH-BOARDGAME_MINWIDTH)/boardsize/2;
		x += BOARDGAME_CHECKERSIZE/2;
		y += BOARDGAME_CHECKERSIZE/2;

		for(i=0; i<boardsize; i++)
		{
			for(j=0; j<8; j++)
			{
				GetCheckersBoardCoord(&coord, j, BOARDGAME_MAXWIDTH-i*distance*2);
				if (CheckMouseCollision(x, y, BOARDGAME_POSX+i*distance+coord.X, BOARDGAME_POSY+i*distance+coord.Y, 20, 20))
				{
					ERRCALL(GetCurrentPlayerID(&game->board, &playerID));
					ERRCALL(GetPlayerList(&game->board, &plist));
					ERRCALL(GetPlayer(plist, playerID, &player));
					if (game->deleteState == 1)
					{
						ERRCALL(DeleteChecker(&game->board, i, j, &playerID, &state));
						switch(state)
						{
						case CHECKERSTATE_SUCCESS:
							game->deleteState = 0;
							ERRCALL(GetCheckerCount(&game->board, playerID, &checker));
							if (checker < 3)
							{
								game->infomessage = 150;
								game->dieplayerevent = 0;
								game->diedplayer = playerID;
								ERRCALL(KickPlayer(plist, playerID));
								ERRCALL(CheckVictory(&game->board, &state));
								if (state == CHECKERSTATE_VICTORY)
								{
									MessageBox(game->hWnd, "Congratulazioni, hai vinto!", "Vittoria", MB_ICONINFORMATION);
									Victory(game);
									return 0;
								}
							}
							NextRoundHandler(game);
							break;
						}
					}
					else if (player->tableCheckersCount > 0) // Se il numero di pedine fuori il campo è maggiore di 0, allora le sposta nel campo da gioco
					{
						ERRCALL(PutChecker(&game->board, i, j, playerID, &state)); // Imposta una pedina
						switch(state)
						{
						case CHECKERSTATE_ALREADYUSED:
							break;
						case CHECKERSTATE_SUCCESS:
							NextRoundHandler(game);
							break;
						case CHECKERSTATE_TRIS:
							game->deleteState = 1;
							break;
						}
					}
					else // altrimenti muove le pedine già esistenti
					{
						ERRCALL(GetChecker(&game->board, i, j, &checker));
						if (checker != CHECKER_EMPTY) // E' stato selezionato un nodo già occupato
						{
							if (checker == playerID) // Controlla se la pedina selezionata in quel punto appartiene al giocatore che deve prendere la pedina
							{
								game->isCheckerSelected = 1; // Ora che la pedina è stata selezionata, ci si prepara per il movimento
								game->gameMoveCheckerIndex = i;		// Coordinate della pedina selezionata
								game->gameMoveCheckerPosition = j;	// Coordinate della pedina selezionata
							}
						}
					}
					return 1;
				}
			}
		}
		break;
	}
	return 0;
}
Example #8
0
bool ShowIntermission(const IntermissionInfo *intermission, bool demoMode)
{
	exitOnAck = demoMode;
	bool gototitle = false;
	bool acked = false;

	// For a cast call we want the bar area to display the names
	if(viewsize > 20)
	{
		const int oldviewsize = viewsize;
		NewViewSize(20);
		viewsize = oldviewsize;
	}

	do
	{
		for(unsigned int i = 0;i < intermission->Actions.Size();++i)
		{
			switch(intermission->Actions[i].type)
			{
				default:
				case IntermissionInfo::IMAGE:
					acked = ShowImage(intermission->Actions[i].action, false);
					break;
				case IntermissionInfo::CAST:
					acked = gototitle = ShowCast((CastIntermissionAction*)intermission->Actions[i].action);
					break;
				case IntermissionInfo::FADER:
					ShowFader((FaderIntermissionAction*)intermission->Actions[i].action);
					break;
				case IntermissionInfo::GOTOTITLE:
					gototitle = true;
					break;
				case IntermissionInfo::TEXTSCREEN:
					acked = ShowTextScreen((TextScreenIntermissionAction*)intermission->Actions[i].action, demoMode);
					break;
				case IntermissionInfo::VICTORYSTATS:
					Victory(true);
					break;
			}

			if(demoMode ? acked : gototitle)
				goto EscSequence;
		}
		if(intermission->Link != NAME_None)
			intermission = IntermissionInfo::Find(intermission->Link);
		else
			break;
	}
	while(intermission);
EscSequence:

	// If we changed the view size, we should reset it now.
	if(viewsize > 20)
		NewViewSize(viewsize);

	if(!gototitle && !demoMode)
	{
		// Hold at the final page until esc is pressed
		IN_ClearKeysDown();

		ControlInfo ci;
		do
		{
			LastScan = 0;
			ReadAnyControl(&ci);
		}
		while(LastScan != sc_Escape && LastScan != sc_Enter && !ci.button1);
	}

	if(demoMode)
	{
		if(acked)
		{
			VW_FadeOut();
			VL_ReadPalette(gameinfo.GamePalette);
			return false;
		}
		else
			return true;
	}
	else
	{
		VL_ReadPalette(gameinfo.GamePalette);
		return !gototitle;
	}
}
Example #9
0
void ThirdCube::Update()
{
	m_pkLight->setPosition(m_pkAppCamera->getPosition());
	m_pkLight->setDirection(m_pkAppCamera->getDirection());

	if( m_nMouseState )
	{
		POINT currentPos;
		GetCursorPos(&currentPos);
		Radian x = Degree((m_RMousePos.x - currentPos.x)*0.5f);
		Radian y = Degree((m_RMousePos.y - currentPos.y)*0.5f);

		m_pkAppCamera->rotate(x, y);

		SetCursorPos(m_RMousePos.x, m_RMousePos.y);
	}

	m_pkAppCamera->update(m_Origin);

	if( m_bVictory )
	{
		Victory();
		return;
	}

	if( m_bAnimation )
	{
		RotateAnimation();
		return;
	}

	if( m_bShuffle )
	{
		PlayShuffle();
		return;
	}

	if( m_bFirstSelect && m_bSecondSelect )
	{
		++m_nCount;
		int select = 0;		//	1=x, 2=y, 3=z
		Vector3 check;
		check.x = m_vMoc.x<0? -m_vMoc.x : m_vMoc.x;
		check.y = m_vMoc.y<0? -m_vMoc.y : m_vMoc.y;
		check.z = m_vMoc.z<0? -m_vMoc.z : m_vMoc.z;
		if( check.x > check.y && check.x > check.z )
			select = 1;
		else if( check.y > check.z )
			select = 2;
		else
			select = 3;
		int rotate = RotateCheck(select);
		//	1=pitch, 2=yaw, 3=roll
		RotateCube(rotate);
		m_bFirstSelect = m_bSecondSelect = false;
		m_vFirstSelect = m_vSecondSelect = Vector3::ZERO;

		m_bRotateSound = true;
		m_bAnimation = true;
	}
}
Example #10
0
bool QuestEncounter::ReadQuestText(QuestGiver &QuestGiver)
{
    sf::Text QuestText(Quests[QuestIterator].Quest.Text, Font);
    QuestText.setPosition(40.0f, 40.0f);
    QuestText.setColor(sf::Color(0, 0, 0));
    QuestText.setStyle(sf::Text::Bold);
    sf::Text ObjectiveText
        (GetEnemyNameFromDatabase("World" + Quests[QuestIterator].Quest.Objective.Map, Quests[QuestIterator].Quest.Objective.ObjectiveID) + " " //TODO PH LOL KOJA INDIREKCIJA
        + IntToString(Quests[QuestIterator].Quest.Objective.CurrentProgress)
        + "/" + IntToString(Quests[QuestIterator].Quest.Objective.ReqProgress), Font),
        AcceptText(Quests[QuestIterator].From ? "Accept" : "Complete", Font),
        Decline(Quests[QuestIterator].From ? "Decline" : "Back", Font);
    AcceptText.setPosition(700.0f, 520.0f);
    ObjectiveText.setColor(sf::Color(0, 0, 0));
    Decline.setPosition(700.0f, 555.0f);
    AcceptText.setColor(sf::Color(0, 0, 0));
    Decline.setColor(sf::Color(0, 0, 0));
    ObjectiveText.setPosition(580.0f, 90.0f);
    ArrowSprite.setPosition(660.0f, 520.0f);

    bool Accept = false;
    while(Window.isOpen()) 
    {
        while(Window.pollEvent(Event))
        {
            if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up))
            {
                if(Accept)
                {
                    Accept = false;
                    ArrowSprite.setPosition(660.0f, 520.0f);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down))
            {
                if(!Accept)
                {
                    Accept = true;
                    ArrowSprite.setPosition(660.0f, 555.0f);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Return))
            {
                switch(Accept)
                {
                case false:
                    switch(Quests[QuestIterator].From)
                    {
                    case true:
                        player.AddQuest(Quests[QuestIterator].Quest);
                        Quests[QuestIterator].From = false;
                        for(auto itr = QuestGiver.Quests.begin(); itr != QuestGiver.Quests.end(); ++itr)
                        {
                            if(itr->ID == Quests[QuestIterator].Quest.ID)
                            {
                                QuestGiver.Quests.erase(itr);
                                return false;
                            }
                        }
                    case false:
                        if(Quests[QuestIterator].Quest.IsComplete())
                        {
                            player.AddCompletedQuest(Quests[QuestIterator].Quest.ID);
                            player.AddItem(GetItemFromDatabase("SavedGame", Quests[QuestIterator].Quest.ItemReward));
                            player.RemoveQuest(Quests[QuestIterator].Quest.ID);
                            if(Quests[QuestIterator].Quest.ID == 10)
                                Victory();
                            Quests.erase(Quests.begin() + QuestIterator);
                            player.SetWealth(player.GetWealth() + 20 * player.GetLevel());
                        }
                        if(Quests.empty())
                            return true;
                    }
                    break;
                case true:
                    return false;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))
            {
                return false;
            }
        }
        Window.clear();
        Window.draw(GUISprite);
        Window.draw(ArrowSprite);
        Window.draw(AcceptText);
        Window.draw(Decline);
        Window.draw(ObjectiveText);
        Window.draw(QuestText);
        Window.display();
    }
    return false;
}