Digital Clock

Posts 115 of 17 · Page 1 of 2
Digital Clock
Code:
void Paint_Part_horizontal(int iX, int iY, bool bActive)
{
	Vertex_t vertPart_waagrecht[6] = 
	{
		Vertex_t(Vector2D(iX,iY+2)),
		Vertex_t(Vector2D(iX+2,iY)),
		Vertex_t(Vector2D(iX+22,iY)),
		Vertex_t(Vector2D(iX+24,iY+2)),
		Vertex_t(Vector2D(iX+22,iY+4)),
		Vertex_t(Vector2D(iX+2,iY+4))
	};
	DWORD dwColor = bActive ? 0xFF0000FF : 0x323232FF;

	g_pDraw->drawFilledPolygon(6,vertPart_waagrecht,dwColor);
}

void cTools::Paint_Part_vertical(int iX, int iY, bool bActive)
{
	Vertex_t vertPart_senkrecht[6] = 
	{
		Vertex_t(Vector2D(iX+2,iY)),
		Vertex_t(Vector2D(iX+4,iY+2)),
		Vertex_t(Vector2D(iX+4,iY+22)),
		Vertex_t(Vector2D(iX+2,iY+24)),
		Vertex_t(Vector2D(iX,iY+22)),
		Vertex_t(Vector2D(iX,iY+2))
	};
	DWORD dwColor = bActive ? 0xFF0000FF : 0x323232FF;

	g_pDraw->drawFilledPolygon(6,vertPart_senkrecht,dwColor);
}

void cTools::Paint_eighth(int iX, int iY, int iZiffer)
{
	/*
	  1
	  _
   0 | | 2
	  - 3
   6 | | 4
	  -
	  5
	*/
	bool bActive[7];
	switch (iZiffer)
	{
	case 0:
		bActive[0] = 1; bActive[1] = 1; bActive[2] = 1; bActive[3] = 0; bActive[4] = 1; bActive[5] = 1; bActive[6] = 1;
		break;
	case 1:
		bActive[0] = 0; bActive[1] = 0; bActive[2] = 1; bActive[3] = 0; bActive[4] = 1; bActive[5] = 0; bActive[6] = 0;
		break;
	case 2:
		bActive[0] = 0; bActive[1] = 1; bActive[2] = 1; bActive[3] = 1; bActive[4] = 0; bActive[5] = 1; bActive[6] = 1;
		break;
	case 3:
		bActive[0] = 0; bActive[1] = 1; bActive[2] = 1; bActive[3] = 1; bActive[4] = 1; bActive[5] = 1; bActive[6] = 0;
		break;
	case 4:
		bActive[0] = 1; bActive[1] = 0; bActive[2] = 1; bActive[3] = 1; bActive[4] = 1; bActive[5] = 0; bActive[6] = 0;
		break;
	case 5:
		bActive[0] = 1; bActive[1] = 1; bActive[2] = 0; bActive[3] = 1; bActive[4] = 1; bActive[5] = 1; bActive[6] = 0;
		break;
	case 6:
		bActive[0] = 1; bActive[1] = 1; bActive[2] = 0; bActive[3] = 1; bActive[4] = 1; bActive[5] = 1; bActive[6] = 1;
		break;
	case 7:
		bActive[0] = 0; bActive[1] = 1; bActive[2] = 1; bActive[3] = 0; bActive[4] = 1; bActive[5] = 0; bActive[6] = 0;
		break;
	case 8:
		bActive[0] = 1; bActive[1] = 1; bActive[2] = 1; bActive[3] = 1; bActive[4] = 1; bActive[5] = 1; bActive[6] = 1;
		break;
	case 9:
		bActive[0] = 1; bActive[1] = 1; bActive[2] = 1; bActive[3] = 1; bActive[4] = 1; bActive[5] = 1; bActive[6] = 0;
		break;
	default:
		bActive[0] = 0; bActive[1] = 0; bActive[2] = 0; bActive[3] = 0; bActive[4] = 0; bActive[5] = 0; bActive[6] = 0;
		break;
	}

	Paint_Part_vertical(iX,iY+2,bActive[0]); // 0
	Paint_Part_horizontal(iX+2,iY,bActive[1]); // 1
	Paint_Part_vertical(iX+24,iY+2,bActive[2]); // 2
	Paint_Part_horizontal(iX+2,iY+24,bActive[3]); // 3
	Paint_Part_vertical(iX+24,iY+26,bActive[4]); // 4
	Paint_Part_horizontal(iX+2,iY+48,bActive[5]); // 5
	Paint_Part_vertical(iX,iY+26,bActive[6]); // 6
}

void cTools::PaintClockDigital(int iX, int iY)
{
	if (!m_pEngine->IsInGame())
		return;

	/*
	Hauptkasten
	*/
	g_pDraw->fillRGBA(iX-1, iY-1, 202, 62, 0x323232FF); // grauer Rand
	g_pDraw->fillRGBA(iX, iY, 200, 60, 0x000000FF); // schwarze Hauptfläche

	/*
	Ränder für die Zahlengruppen
	*/
	g_pDraw->drawBorder(iX+2, iY+2, 60, 56, 1, 0x323232FF); // links
	g_pDraw->drawBorder(iX+70, iY+2, 60, 56, 1, 0x323232FF); // mitte
	g_pDraw->drawBorder(iX+138, iY+2, 60, 56, 1, 0x323232FF); // rechts

	/*
	Punkte dazwischen
	*/
	g_pDraw->drawFilledCircle(iX+66, iY+18, 2, 0x323232FF); // links oben
	g_pDraw->drawFilledCircle(iX+66, iY+42, 2, 0x323232FF); // links unten
	g_pDraw->drawFilledCircle(iX+134, iY+18, 2, 0x323232FF); // rechts oben
	g_pDraw->drawFilledCircle(iX+134, iY+42, 2, 0x323232FF); // rechts unten

	/*
	Zeit holen
	*/
	tm *current_tm;
	time_t current_time;

	time(&current_time);
	current_tm = localtime(&current_time);

	/*
	Stunden
	*/
	int iHour_tenner_numeral = current_tm->tm_hour / 10;
	int iHour_one_numeral = current_tm->tm_hour % 10;

	Paint_eighth(iX+3, iY+4, iHour_tenner_numeral);
	Paint_eighth(iX+33, iY+4, iHour_one_numeral);

	/*
	Minuten
	*/
	int iMin_tenner_numeral = current_tm->tm_min / 10;
	int iMin_one_numeral = current_tm->tm_min % 10;

	Paint_eighth(iX+71, iY+4, iMin_tenner_numeral);
	Paint_eighth(iX+101, iY+4, iMin_one_numeral);

	/*
	Sekunden
	*/
	int iSec_tenner_numeral = current_tm->tm_sec / 10;
	int iSec_one_numeral = current_tm->tm_sec % 10;

	Paint_eighth(iX+139, iY+4, iSec_tenner_numeral);
	Paint_eighth(iX+169, iY+4, iSec_one_numeral);
}
CREDITS NOT TO ME

Umm You Really Like Clocks../
Lol!! yea i hate playing any game, then not relising the time..
thks for the ss..
Leeched is leeched.
Death go away noob.

Blood sorry!! i forgot to add the credits
aha nice. But its easier to use xfire's time :P
Nice clock. Beats my shitty one D:
To fucking big XD
Doesnt have all required functions but cool.
Quote Originally Posted by whatup777 View Post
Doesnt have all required functions but cool.
FUCKING GOOGLE.COM
I know Im just letting people know.
Posts 115 of 17 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?