示例#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
文件: Main.cpp 项目: mjowned/AIproj
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;
}
示例#4
0
文件: Main.cpp 项目: Gijs-W/kmint1
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;
}
示例#5
0
int main()
{

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

	//10 nodes
	//Per klik een stap van het korste pad;//checkje voor buurnode;
	//druk op 1 haasje verplaaytst
	application->SetTargetFPS(60);
	application->SetColor(Color(255, 10, 40, 255));

	NodeMap map{ application };
	map.setStates();
	char cowStatus[200];
	char rabitStatus[200];

	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_SPACE:
					map.Update();
					break;
				default:
					break;
				}
			}
		}
		
#ifdef __APPLE__
		strcpy(cowStatus, "Koe status = "); // copy string one into the result.
		strcat(cowStatus, map.getKoe()->getState()->stateToText());
		strcpy(rabitStatus, "Haas status = "); // copy string one into the result.
		strcat(rabitStatus, map.getHaas()->getState()->stateToText());
#else

		strcpy_s(cowStatus,"Koe status = "); // copy string one into the result.
		strcat_s(cowStatus,map.getKoe()->getState()->stateToText());
		strcpy_s(rabitStatus, "Haas status = "); // copy string one into the result.
		strcat_s(rabitStatus, map.getHaas()->getState()->stateToText());
#endif

        map.getHaas()->calculateChancePercentage();

		std::string sleepChance = "Sleep%: " + std::to_string(map.getHaas()->getSleepChancePercentage());
		std::string findChance = " Find%: " + std::to_string(map.getHaas()->getFindChancePercentage());
		std::string wanderchance = " Wander%: " + std::to_string(map.getHaas()->getWanderChancePercentage());
        std::string huntchance = " Hunt%: " + std::to_string(map.getHaas()->getHuntChancePercentage());

		
		std::string cowCaught = " Cow catched: " + std::to_string(map.getKoe()->getCaught());
		std::string rabitCaught = " Rabbit Catched:  " + std::to_string(map.getHaas()->getCaught());
		application->SetColor(Color(0, 0, 0, 255));
		application->DrawText("Opdracht week 1: Bryan + Andy", 120, 500);
		
		application->DrawText(cowStatus, 120, 540);
		application->DrawText(rabitStatus, 120, 560);

		application->DrawText(cowCaught, 500, 460);
		application->DrawText(rabitCaught, 500, 500);
		application->DrawText(sleepChance + findChance + wanderchance + huntchance, 140, 460);
       

		application->RenderGameObjects();
		application->EndTick();

		application->SetColor(Color(255, 255, 255, 255));

	}

	return EXIT_SUCCESS;
}