Пример #1
0
int Engine::Draw(Context& context)
{
	// Create a graphics and set it to our system
	Graphics* graph = GetSystem<Graphics>(SystemType::Sys_Graphics);
	if (graph == nullptr) return false;

	// Create the game logic and set it to our system
	GameLogic* logic = GetSystem<GameLogic>(SystemType::Sys_Logic);
	if (logic == nullptr)
		return false;

	// Begin the Draw
	graph->BeginDraw();

	// Draw the game logic
	logic->Draw(context);

	Rect2D r(100, 100, 200, 200);
	RENDERER->DrawRect(r, 2.f);

	// End the Draw
	graph->EndDraw();

	return true;
}
Пример #2
0
void BeginSimulation(void)
{
	char str[32];
	int brokenTime,
		FixedTime,
		TechCount,
		RunTime;
	float DiscardDataTime;
	HWND progressbar = GetDlgItem(HDialog,IDC_PROGRESS1);
	//Accept User Input
	GetDlgItemText(HDialog, IDC_EDIT1, str, 32);
	brokenTime = atoi(str);
	if(brokenTime == NULL)
		brokenTime = 8;
	
	GetDlgItemText(HDialog, IDC_EDIT2, str, 32);
	FixedTime = atoi(str);
	if(FixedTime == NULL)
		FixedTime = 30;
	
	GetDlgItemText(HDialog, IDC_EDIT4, str, 32);
	TechCount = atoi(str);
	if(TechCount == NULL)
		TechCount = 10;
	
	GetDlgItemText(HDialog, IDC_EDIT5, str, 32);
	RunTime = atoi(str);
	if(RunTime == NULL || RunTime <= 2)
	{
		RunTime = 2;
		SetDlgItemText(HDialog, IDC_EDIT5,(LPCSTR)"2");
	}
	DiscardDataTime = 1;
	DiscardDataTime *= 120000;
	bool exit = false;
	RECT rect;
	GameLogic GL;
	RECT rect2;
	int wdRect;
	GetClientRect(HOutput, &rect);
	wdRect = rect.right - rect.left;
	rect2.left = -wdRect / 2;
	rect2.right =  wdRect / 2;
	wdRect = rect.bottom - rect.top;
	rect2.bottom = -(wdRect/2);
	rect2.top = -rect2.bottom;
	RAND->Set((float)time(NULL));
	GL.Init(5,10,4,2,3,1,2);
	float temp = 0;
	SendMessage(progressbar,PBM_SETRANGE,0,MAKELPARAM(0,100));
	SendMessage(progressbar,PBM_SETSTEP,(WPARAM) 1, 0);
	SendMessage(progressbar,PBM_SETBARCOLOR,(WPARAM) 0,MAKELPARAM(0,RGB(255,0,0)));
	//SendDlgItemMessage(progressbar,IDC_PROGRESS1,PBM_SETRANGE,0,100);
	//SendDlgItemMessage(progressbar,IDC_PROGRESS1,PBM_SETBARCOLOR,0,RGB(0,255,0));
	SendDlgItemMessage(progressbar,IDC_PROGRESS1,PBM_SETSTATE,PBST_NORMAL,0);
	SendDlgItemMessage(progressbar,IDC_PROGRESS1,PBM_SETMARQUEE,1,0);
	//SendDlgItemMessage(progressbar,IDC_PROGRESS1,PBM_SETSTEP,10,0);
	//SendMessage(progressbar,PBM_STEPIT,0,0);
	MS->ResetClock();
	int temp1;
	//11 hours a day 7 days a week for 30 days in minutes
	int MaxRunTime = 138600;
	float HasDiscarded = false;
	while(MS->GetClock() < 138600)
	{
		if(!HasDiscarded && MS->GetClock() >= DiscardDataTime)
		{
			//GD->Reset();
			HasDiscarded = true;
		}
		if((int)temp < (int)((MS->GetClock() / 138600)*100.0f))
		{
			SendMessage(progressbar,PBM_STEPIT,0,0);
			temp = (float)MS->GetClock() / 138600 * 100.0f;
		}
		GL.Update(.016f);
		GL.Draw();
		temp1 = (int)MS->GetClock();
	}
	//AM->Complete();
	OM->Clear();
	AM->Clear();
}