Пример #1
0
int main(int args[])
{
	//auto window = Window::CreateSDLWindow();
	auto application = new FWApplication();
	if (!application->GetWindow())
	{
		LOG("Couldn't create window...");
		return EXIT_FAILURE;
	}
	
	application->SetTargetFPS(60);
	application->SetColor(Color(255, 10, 40, 255));
	
	Cow * moe = new Cow();
	Graph * graph = new Graph();
	while (application->IsRunning())
	{
		application->StartTick();

		SDL_Event event;
		while (SDL_PollEvent(&event))
		{
			switch (event.type)
			{
			case SDL_QUIT:
				application->Quit();
				break;
			case SDL_KEYDOWN:
				switch (event.key.keysym.sym){
				case false:
					break;

				default:
					break;
				}
			}
		}
		
		application->SetColor(Color(0, 0, 0, 255));
		for (int i = 0; i < graph->getGraphSize(); i++){
			application->AddRenderable(graph->getNode(i));
		}
		for (int i = 0; i < graph->getEdgesSize(); i++){
			Edge * E = graph->getEdge(i);
			application->DrawLine(E->mXA, E->mYA, E->mXB, E->mYB);
		}

		application->AddRenderable(moe);		
		// For the background
		application->SetColor(Color(255, 255, 255, 255));

		application->UpdateGameObjects();
		application->RenderGameObjects();
		application->EndTick();
	}
		
	return EXIT_SUCCESS;
}
Пример #2
0
int main(int args[])
{
	srand(static_cast<unsigned int>(time(nullptr)));						// initialize random seed

	auto application = new FWApplication();
	if (!application->GetWindow())
	{
		LOG("Couldn't create window...");
		return EXIT_FAILURE;
	}

	application->SetTargetFPS(60);
	arena = std::make_shared<Arena>();
	auto dashboard = new Dashboard();

	myTimerID = SDL_AddTimer(delay, MyCallBackFunc, nullptr);
	while (application->IsRunning())
	{
		application->StartTick();

		SDL_Event event;

		while (SDL_PollEvent(&event))
		{
			switch (event.type)
			{
			case SDL_QUIT:
				application->Quit();
				break;
			case SDL_KEYDOWN:

				switch (event.key.keysym.sym){
				case SDLK_0:

					break;

				default:

					break;
				}
				break;
			case SDL_MOUSEBUTTONDOWN:
				break;
			}
		}

		application->SetColor(Color(0, 0, 0, 255));							// White color
		dashboard->Update();
		// For the background
		application->SetColor(Color(255, 255, 255, 255));					// Black color
		application->UpdateGameObjects();
		application->RenderGameObjects();
		application->EndTick();
	}

	return EXIT_SUCCESS;
}
Пример #3
0
void World::Update(float dt)
{
	if(mActive == true)
	{
		UpdateGameObjects(dt);
		SpawnEnemies(dt);
		FireBullets();
		CheckCollision();
	}
}
Пример #4
0
int main(int args[])
{
	//auto window = Window::CreateSDLWindow();
	auto application = new FWApplication();
	if (!application->GetWindow())
	{
		LOG("Couldn't create window...");
		return EXIT_FAILURE;
	}
	
	application->SetTargetFPS(60);
	application->SetColor(Color(255, 10, 40, 255));
	

	//while (true){}
	while (application->IsRunning())
	{
		application->StartTick();

		SDL_Event event;
		while (SDL_PollEvent(&event))
		{
			switch (event.type)
			{
			case SDL_QUIT:
				application->Quit();
				break;
			case SDL_KEYDOWN:
				switch (event.key.keysym.sym){

				default:
					break;
				}
			}
		}
		
		application->SetColor(Color(0, 0, 0, 255));
		application->DrawText("Welcome to KMint", 800 / 2, 600 / 2);
		
		// For the background
		application->SetColor(Color(255, 255, 255, 255));

		application->UpdateGameObjects();
		application->RenderGameObjects();
		application->EndTick();
	}
		
	return EXIT_SUCCESS;
}
Пример #5
0
void EngineRunningBase::Update()
{
  EngineState::Update();

  Assert(m_pLevel.GetPtr());

///  GetEngine()->GetDayNightSky()->Update();

  // Update static scene
  m_pLevel->GetScene()->Update();

  // Update Game Objects before updating the Player. That way
  // the player responds to the position of things _this_ frame,
  // rather than their position in the previous frame.
  UpdateGameObjects();

}
void EngineStatePoolShowShot::Update()
{
  if (m_time < m_maxTime)
  {
    // POOL_ONLINE:
    // DON'T call EngineStatePoolBase::Update();
    // If the timer expires, the shot will be started, but we DON'T want to update
    //  the shot in this state, for consistency with the other (user-controlled) client.

    // If a moving ball is outside of the view frustum, pull the camera back.
    ((PoolCamera*)s_pCamera.GetPtr())->SetPoolPullBackRequired(s_movingBallNotInFrustum);
    s_movingBallNotInFrustum = false;

    GetCamera()->Update();

    if (!IsBirdsEye())
    {
      // Update the camera so it is always above the ball
      float camY = GetCamera()->GetOrientation()->GetY();
      float ballY = GetBall()->GetOrientation()->GetY();
      ballY += 1.0f; // TODO CONFIG
      if (camY < ballY)
      {
        Orientation o = *(GetCamera()->GetOrientation());
        o.SetY(ballY);
        GetCamera()->SetOrientation(o);
      }
    }
    // May call TimerExpired.....
    EngineState::Update();

    if (m_time < m_maxTime)
    {
      Assert(m_pLevel.GetPtr());
////      GetEngine()->GetDayNightSky()->Update();
      m_pLevel->GetScene()->Update();
      UpdateGameObjects();
    }
  }
  else
  {
    // DON'T update game objects
    EngineState::Update();
  }
}
Пример #7
0
int main(int args[])
{

	srand(time(0));
	//auto window = Window::CreateSDLWindow();
	auto application = new FWApplication();
	if (!application->GetWindow())
	{
		LOG("Couldn't create window...");
		return EXIT_FAILURE;
	}

	application->SetTargetFPS(60);
	application->SetColor(Color(255, 10, 40, 255));

	Game* game = new Game(application);

	//while (true){}
	while (application->IsRunning())
	{
		application->StartTick();
		SDL_Event event;
		while (SDL_PollEvent(&event))
		{
			switch (event.type)
			{
			case SDL_QUIT:
				application->Quit();
				break;
			case SDL_KEYDOWN:
				switch (event.key.keysym.scancode){
				case SDL_SCANCODE_SPACE:
					game->Pause();
					break;
				default:
					break;
				}
			}
		}

		application->UpdateGameObjects();
		if (!game->IsPause()){
			game->Update(application->GetDeltaTime());
		}
		application->RenderGameObjects();

		application->SetColor(Color(0, 0, 0, 255));// For the letter colour
		application->DrawTextWithWhiteBorder("[Round] " + std::to_string(game->GetRoundNumber()), SCREEN_WIDTH / 2, 20);
		application->DrawTextWithWhiteBorder("[Seconds Remaining] " + std::to_string(game->GetTimeRemaining()), SCREEN_WIDTH / 2, 40);
		if (game->IsPause()){
			application->DrawTextWithWhiteBorder("[PAUSE]", SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
			application->SetColor(Color(238, 233, 233, 255));// For the background
		}
		else{
			application->SetColor(Color(255, 255, 255, 255));// For the background
		}


		if (game->GameOver()){
			application->Quit();
		}
		application->EndTick();


	}
		
	return EXIT_SUCCESS;
}