Beispiel #1
0
	void BaseBall() {
		Init();
		ScreenInit();

		int key;
		clock_t CurTime;

		while (1)
		{
			// 키입력 발생 시 수행
			if (_kbhit())
			{
				key = _getch();

				if (key == 'q' || key == 'Q')
					break;			

				KeyControl(key); // Key 입력 시 수행
			}

			Update();
			Render();

			while (1)
			{
				CurTime = clock();
				if (CurTime - G_OldTime > DelayT)
				{
					G_OldTime = CurTime;
					break;
				}
			}
		}

	}
void main()
{
	int Key;

	ScreenInit();
	Init();

	while (1)
	{
		if (_kbhit())
		{
			Key = _getch();

			if (Key == 'q' || Key=='Q')
				break;

			if (Key == SPACE)
			{
				//게임 시작 / 일시정지 
				switch (GameStatus)
				{
				case START:
					GameStatus = INIT;
					break;

				case RUNNING:
					GameStatus = STOP;
					break;

				case GO:
					GameStatus = RUNNING;
					break;

				case STOP:
					GameStatus = RUNNING;
					break;
				}
			}

			if (GameStatus != GO && GameStatus != STOP)
				KeyControl(Key);

		}

		Update();
		Render();

	}

	Release();
	ScreenRelease();
}
Beispiel #3
0
	void EqualCard()
	{
		int key;
		clock_t CurTime;

		Init();
		ScreenInit();

		while (1)
		{
			if (_kbhit()) // key 입력이 있으면
			{
				key = _getch();

				if ((key == 'q') || (key == 'Q'))
				{
					Stage.Level = 0;
					break;
				}

				// key 조작
				KeyControl(key);

			}

			Update();
			Render();

			while (1)
			{
				CurTime = clock();
				if (CurTime - G_OldTime > DelayT)
				{
					G_OldTime = CurTime;
					break;
				}
			}
		}

	}
Beispiel #4
0
void main()
{
	int key;

	Init();
	ScreenInit();

	while (1)
	{
		if (_kbhit())
		{
			key = _getch();

			if (key == 'q' || key == 'Q')
				break;

			KeyControl(key);

		}

		Update();
		Render();
	}
}
Beispiel #5
0
void FCURun(FCDataBaseDef *FC)
{
   switch (systemState)
   {
   case POWERON:        //Éϵç״̬
      {
         FC->State.Sys.Solo.Started = 0;
         FC->State.Sys.Solo.RelayH = 0;
         FC->State.Sys.Solo.RelayM = 0;
         FC->State.Sys.Solo.RelayL = 0;
         FC->State.Sys.Solo.FloatRelayOn = 1;
         FC->State.Sys.Solo.FloatRelayOff = 0;
         FC->Buff.AnalogOut01 = 0;
         FC->Buff.AnalogOut02 = 0;
         FC->FCpid.ITerm = 0;
         FC->Buff.WorkTimer.OpenTimer = FC->Run.SolenoidValveMax * 100;
         FC->Buff.WorkTimer.CloseTimer = 0;
         systemState = POWERONSTAY;
      }
      break;
   case POWERONSTAY:          //ÉϵçµÈ´ý״̬
      {
         if (!FC->Buff.Flag.solo._1000msFlag)
         {
            return;
         }
         FC->State.Sys.Solo.RelayH = 0;
         FC->State.Sys.Solo.RelayM = 0;
         FC->State.Sys.Solo.RelayL = 0;
         FC->Buff.AnalogOut01 = 0;
         FC->Buff.AnalogOut02 = 0;
         FC->FCpid.ITerm = 0;
         FloatTimerDeal(FC);
      }
      break;
   case CLOSEIDLE:          //¹Ø»ú¿ÕÏÐ״̬
      {
         if (FC->Buff.WorkTimer.OnOffDelayTimer > 0)
         {
            return;
         }
         FC->State.Sys.Solo.RelayH = 0;
         FC->State.Sys.Solo.RelayM = 0;
         FC->State.Sys.Solo.RelayL = 0;
         FC->Buff.AnalogOut01 = 0;
         FC->Buff.AnalogOut02 = 0;
         FC->FCpid.ITerm = 0;
         if (FC->State.Sys.Solo.Started)
         {
            systemState = VALVEDEAL;
//          FC->FCpid.myOutput =
         }
         FloatTimerDeal(FC);
      }
      break;
   case VALVEDEAL:
      {
         KeyControl(FC);
         PIDCompute(&FC->FCpid);
         FanCompute(FC);
         FloatCompute(FC);
         if (!FC->State.Sys.Solo.Started)
         {
            systemState = CLOSEIDLE;
            FC->Buff.WorkTimer.OpenTimer = 0;
            FC->Buff.WorkTimer.CloseTimer = FC->Run.SolenoidValveMax * 100;
         }
         else if (FC->FCpid.myOutput > FC->FCpid.outMax * 30 / 100)
         {
            FC->Buff.WorkTimer.OpenTimer =  FC1.Run.SolenoidValveMax * 100;
            systemState = FANDEAL;
         }
      }
      break;
   case FANDEAL:
      {
         KeyControl(FC);
         PIDCompute(&FC->FCpid);
         if (!FC->State.Sys.Solo.Started)
         {
            systemState = CLOSEIDLE;
            FC->Buff.WorkTimer.OpenTimer = 0;
            FC->Buff.WorkTimer.CloseTimer = FC->Run.SolenoidValveMax * 100;
         }
         if (FC->FCpid.myOutput <= FC->FCpid.outMax * 30 / 100)
         {
            FC->Buff.WorkTimer.OpenTimer =  0;
            systemState = VALVEDEAL;
         }

         FloatTimerDeal(FC);
         FanCompute(FC);
      }
      break;
   }
}
void GameLoop( sf::RenderWindow &app, bool &bczyGra, bool &bMenu )
{
    ResetGame();

    bool pauseGame = false;

    sf::Mouse::setPosition( sf::Vector2i( Width / 2, Height / 2 ), app );
    app.setMouseCursorVisible( false );

    sounds[2].play();

    while ( bczyGra )
    {
        LoopTime = TimeLoop.GetElapsedSeconds();
        TimeLoop.Reset();

        sf::Event event;
        while (app.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                bczyGra = false;
                bMenu = false;
                app.close();
            }
            else if (event.type == sf::Event::Resized)
            {
                ChangeSize( event.size.width, event.size.height );
            }
            else if ( ( event.type == sf::Event::KeyReleased ) &&
                      ( event.key.code == sf::Keyboard::Escape ) ){
                bczyGra = false;
                bMenu = true;
            }

            if ( ( ( event.type == sf::Event::JoystickButtonReleased ) &&
                 ( event.joystickButton.button == 0 ) )  ||
                ( event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::P ) ){
                pauseGame = !pauseGame;
                if ( pauseGame == true ) {
                    app.setMouseCursorVisible( true );
                    sounds[2].pause();
                } else {
                    sf::Mouse::setPosition( sf::Vector2i( Width / 2, Height / 2 ), app );
                    app.setMouseCursorVisible( false );
                    LoopTime = 0.0f;
                    TimeLoop.Reset();
                    sounds[2].play();
                }
            }
        }

        KeyControl( LoopTime, app );
        if ( !pauseGame ) {
            MoveMouse( sf::Mouse::getPosition( app ).x, sf::Mouse::getPosition( app ).y, app );
            MouseControl( LoopTime );
            Joystick( LoopTime, app );
            if ( Player.getLife() < 0 ) {
                bczyGra = false;
                bMenu = true;
            }
            Logika( LoopTime );
            RenderScene();
            app.display();
        }
    }

    sounds[2].stop();
    hud.sendScore();
}