Thread: Digital Clock

Results 1 to 15 of 17

Threaded View

  1. #1
    GameTrainerMaker's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    465
    Reputation
    17
    Thanks
    514

    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

    Last edited by GameTrainerMaker; 08-22-2010 at 03:48 PM.

  2. The Following User Says Thank You to GameTrainerMaker For This Useful Post:

    whit (08-22-2010)

Similar Threads

  1. Replies: 2
    Last Post: 05-29-2010, 12:07 AM
  2. [Tutorial]VB2008! How To Make Digital Clock On Your Form!
    By almog6666 in forum Visual Basic Programming
    Replies: 3
    Last Post: 04-09-2009, 01:55 PM
  3. Digital Coders Public Hack
    By Luigid in forum WarRock - International Hacks
    Replies: 4
    Last Post: 06-08-2007, 01:08 AM
  4. Electronic Digital
    By Dave84311 in forum General
    Replies: 5
    Last Post: 06-06-2006, 01:07 PM