Halloween treats for programmers 2015 : Visual C++



Halloween Treats for Programmers
Scared, eh? Well, this time I really want to scare the code out of you πŸ˜€ That’s why I created a scary program that will keep you from programming this halloween. Go on and have a look at the Halloween Treats for Programmers. It is a Visual C++ program created as a Win32 application.

Halloween Treats for Programmers

  The following images describe the program’s awesomeness. But know this – the real beauty of this program can be appreciated only if you run it on your computer.

Halloween treats for Programmers Halloween treats for Programmers Halloween treats for Programmers

You can also watch the following video which shows the full action of this program :





And now the source code for this program –

Halloween Treats for Programmers – Source Code

 



/*      Title      : WCB Halloween Animation
	Author     : Manish Kumar & Gaurav Anand
	Email      : manish@wincodebits.in
	Written in : Win32(C++)
	IDE Used   : Visual Studio Express 2013
	Copyright(C) Manish Kumar, 2015
*/

#include "stdafx.h"
#include "Halloween.h"

#define MAX_LOADSTRING 100


// Global Variables:
HINSTANCE hInst;					
TCHAR szTitle[MAX_LOADSTRING];				
TCHAR szWindowClass[MAX_LOADSTRING];			

HBITMAP hbmp, hbmp1, hbmp2;
HDC hmemdc, hmemdc1, hmemdc2;
HGDIOBJ holdbmp, holdbmp1, holdbmp2;

int Xinit = 142, Yinit = 170;
int OldX = 142, OldY = 170;
int Xpos = Xinit, Ypos = Yinit;
int Height = 18, Width = 18;
int flag = 0, _flag = 0;
int PicValue = 0;

int count = 0;
int _Animate = 0;

int HALLOWEEN1 = FALSE;
int HALLOWEEN2 = FALSE;
int STEP = 0;

int AnimateW = 0, AnimateI = 0, AnimateN = 0, AnimateD = 0, AnimateO = 0, AnimateS = 0, AnimateC = 0, AnimateE = 0, AnimateB = 0, AnimateT = 0;


PAINTSTRUCT ps;
HDC hdc;


//User Defined Functions

void OnCreate(HWND hWnd);
void OnTimer(HWND hWnd);
void Draw_W(HWND hWnd, int DELAY = 0);
void Draw_I(HWND hWnd, int DELAY = 0);
void Draw_N(HWND hWnd, int DELAY = 0);
void Draw_D(HWND hWnd, int DELAY = 0);
void Draw_O(HWND hWnd, int DELAY = 0);
void Draw_S(HWND hWnd, int DELAY = 0);
void Draw_C(HWND hWnd, int DELAY = 0);
void Draw_E(HWND hWnd, int DELAY = 0);
void Draw_B(HWND hWnd, int DELAY = 0);
void Draw_T(HWND hWnd, int DELAY = 0);
void Animation(HWND hWnd, int cls);
void Pic_Value(HWND hWnd);
void SetBackground(HWND hWnd);


// Forward declarations of functions included in this code module:

ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
	_In_opt_ HINSTANCE hPrevInstance,
	_In_ LPTSTR    lpCmdLine,
	_In_ int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	MSG msg;
	HACCEL hAccelTable;

	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_HALLOWEEN, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	if (!InitInstance(hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_HALLOWEEN));

	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	return (int)msg.wParam;
}


ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);

	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc = WndProc;
	wcex.cbClsExtra = 0;
	wcex.cbWndExtra = 0;
	wcex.hInstance = hInstance;
	wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_HALLOWEEN));
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
	wcex.lpszMenuName = MAKEINTRESOURCE(IDC_HALLOWEEN);
	wcex.lpszClassName = szWindowClass;
	wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

	return RegisterClassEx(&wcex);
}


BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HWND hWnd;

	hInst = hInstance; // Store instance handle in our global variable

	hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX ,
		0, 0, 1200, 700, NULL, NULL, hInstance, NULL);

	if (!hWnd)
	{
		return FALSE;
	}

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

	return TRUE;
}


LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	

	switch (message)
	{
	case WM_COMMAND:
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);

		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:

		hdc = BeginPaint(hWnd, &ps);
		
		SetBackground(hWnd);
		
		EndPaint(hWnd, &ps);

		break;
	case WM_CREATE:
		OnCreate(hWnd);
		break;
	case WM_TIMER:
		OnTimer(hWnd);
		break;
	
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}


INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	switch (message)
	{
	case WM_INITDIALOG:
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
		{
			EndDialog(hDlg, LOWORD(wParam));
			return (INT_PTR)TRUE;
		}
		break;
	}
	return (INT_PTR)FALSE;
}


void OnCreate(HWND hWnd)
{
	HDC hdc;

	// # image 1
	hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_PICTURE1));
	hdc = GetDC(hWnd);
	hmemdc = CreateCompatibleDC(hdc);
	holdbmp = SelectObject(hmemdc, hbmp);
	ReleaseDC(hWnd, hdc);

	// # image 2
	hbmp1 = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_PICTURE2));
	hdc = GetDC(hWnd);
	hmemdc1 = CreateCompatibleDC(hdc);
	holdbmp1 = SelectObject(hmemdc1, hbmp1);
	ReleaseDC(hWnd, hdc);

	// # Background
	hbmp2 = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_PICTURE3));
	hdc = GetDC(hWnd);
	hmemdc2 = CreateCompatibleDC(hdc);
	holdbmp2 = SelectObject(hmemdc2, hbmp2);
	ReleaseDC(hWnd, hdc);

	srand(time(NULL));
	SetTimer(hWnd, 1, 20, NULL);

}

void OnTimer(HWND hWnd)
{
		if (count == 0)
			PlaySound(_T("Data//halloween.wav"), NULL, SND_FILENAME | SND_ASYNC);
		Animation(hWnd, _Animate);
		count++;
		if (count >= 600)
		{
			count = 0;
			_Animate = !_Animate;
		}
}

void Draw_W(HWND hWnd, int DELAY)
{
	HDC hdc;
	hdc = GetDC(hWnd);

		if (AnimateW < 5) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; Xpos += Width / 2; } else if (AnimateW == 5) { Pic_Value(hWnd); Ypos -= Height; Xpos -= Width / 2; } else if (AnimateW >= 6 && AnimateW < 10) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos -= Height; Xpos += Width / 2; } else if (AnimateW == 10) { Pic_Value(hWnd); Ypos += Height; Xpos -= Width / 2; } else if (AnimateW >= 11 && AnimateW < 15) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; Xpos += Width / 2; } else if (AnimateW == 15) { Pic_Value(hWnd); Ypos -= Height; Xpos -= Width / 2; } else if (AnimateW >= 16 && AnimateW < 21)
		{
			Sleep(DELAY);
			Pic_Value(hWnd);
			if (PicValue == 1)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY);
			Ypos -= Height;
			Xpos += Width / 2;
		}
	ReleaseDC(hWnd, hdc);
}


void Draw_I(HWND hWnd, int DELAY)
{
	HDC hdc;
	hdc = GetDC(hWnd);

		if (AnimateI < 5) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Xpos += Width; } else if (AnimateI == 5) { Xpos -= 3 * Width; Ypos += Height; } else if (AnimateI >= 6 && AnimateI < 9) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; } else if (AnimateI == 9) { Xpos -= 2 * Width; } else if (AnimateI >= 10 && AnimateI < 15)
		{
			Sleep(DELAY);
			Pic_Value(hWnd);
			if (PicValue == 1)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY);
			Xpos += Width;
		}
	ReleaseDC(hWnd, hdc);
}

void Draw_N(HWND hWnd, int DELAY)
{
	HDC hdc;
	hdc = GetDC(hWnd);
		if (AnimateN < 5) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos -= Height; } else if (AnimateN == 5) { Ypos += Height; Pic_Value(hWnd); } else if (AnimateN >= 6 && AnimateN < 11) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; Xpos += Width; } else if (AnimateN == 11) { Pic_Value(hWnd); Ypos -= Height; Xpos -= Width; } else if (AnimateN >=12 && AnimateN < 17)
		{
			Sleep(DELAY);
			Pic_Value(hWnd);

			if (PicValue == 1)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY);
			Ypos -= Height;
		}
	ReleaseDC(hWnd, hdc);
}


void Draw_D(HWND hWnd, int DELAY)
{
	HDC hdc;
	double _j;
	hdc = GetDC(hWnd);
		if (AnimateD < 5) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; } if (AnimateD == 5) { Xpos += Width; Ypos -= 3 * Height; } if (AnimateD >= 6 && AnimateD < 13)
		{
			Sleep(DELAY);
			_j = AnimateD - 6;

			Pic_Value(hWnd);

			if (PicValue == 1)
				BitBlt(hdc, Xpos + sin(_j*0.52) * 40, Ypos + cos(_j*0.52) * 40, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos + sin(_j*0.52) * 40, Ypos + cos(_j*0.52) * 40, Width, Height, hmemdc1, 0, 0, SRCCOPY);
		}
	ReleaseDC(hWnd, hdc);
}

void Draw_O(HWND hWnd, int DELAY)
{
	HDC hdc;
	double _j;
	hdc = GetDC(hWnd);
		if (AnimateO < 12)
		{
			Sleep(DELAY);
			Pic_Value(hWnd);
			_j = AnimateO;

			if (PicValue == 1)
				BitBlt(hdc, Xpos + sin(_j*0.52) * 40, Ypos + cos(_j*0.52) * 40, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos + sin(_j*0.52) * 40, Ypos + cos(_j*0.52) * 40, Width, Height, hmemdc1, 0, 0, SRCCOPY);
		}
	ReleaseDC(hWnd, hdc);
}

void Draw_S(HWND hWnd, int DELAY)
{
	HDC hdc;
	hdc = GetDC(hWnd);
		if (AnimateS < 4) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Xpos -= Width; } if (AnimateS == 4) { Pic_Value(hWnd); Xpos += Width; } if (AnimateS > 4 && AnimateS < 8) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; } if (AnimateS == 8) { Pic_Value(hWnd); Ypos -= Height; } if (AnimateS > 8 && AnimateS < 13) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Xpos += Width; } if (AnimateS == 13) { Pic_Value(hWnd); Xpos -= Width; } if (AnimateS > 13 && AnimateS < 17) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; } if (AnimateS == 17) { Pic_Value(hWnd); Ypos -= Height; } if (AnimateS > 17 && AnimateS < 22)
		{
			Sleep(DELAY);
			Pic_Value(hWnd);

			if (PicValue == 1)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY);
			Xpos -= Width;
		}
	ReleaseDC(hWnd, hdc);
}


void Draw_C(HWND hWnd, int DELAY)
{
	HDC hdc;
	double _j;
	hdc = GetDC(hWnd);

		if (AnimateC < 9)
		{
			_j = AnimateC + 5;
			Sleep(DELAY);

		        Pic_Value(hWnd);

			if (PicValue == 1)
				BitBlt(hdc, Xpos + sin(_j*0.52) * 40, Ypos + cos(_j*0.52) * 40, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos + sin(_j*0.52) * 40, Ypos + cos(_j*0.52) * 40, Width, Height, hmemdc1, 0, 0, SRCCOPY);
		}
	ReleaseDC(hWnd, hdc);
}

void Draw_E(HWND hWnd, int DELAY)
{
	HDC hdc;
	hdc = GetDC(hWnd);
		if (AnimateE < 3) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Xpos -= Width; } if (AnimateE == 3) { Xpos += Width; Ypos += Height; } if (AnimateE > 3 && AnimateE < 6) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; } if (AnimateE == 6) { Ypos -= Height; Xpos += Width; } if (AnimateE > 6 && AnimateE < 9) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Xpos += Width; } if (AnimateE == 9) { Xpos -= 3 * Width; Ypos += Height; } if (AnimateE > 9 && AnimateE < 12) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; } if (AnimateE == 12) { Ypos -= Height; Xpos += Width; } if (AnimateE > 12 && AnimateE < 15)
		{
		        Sleep(DELAY);
			Pic_Value(hWnd);
			if (PicValue == 1)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY);
			Xpos += Width;
		}
	ReleaseDC(hWnd, hdc);
}

void Draw_B(HWND hWnd, int DELAY)
{
	HDC hdc;
	double _j, _k;
	hdc = GetDC(hWnd);
		if (AnimateB < 5) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos -= Height; } if (AnimateB == 5) { Xpos += Width; Ypos += 3 * Height; } if (AnimateB > 5 && AnimateB < 9) { _j = AnimateB + 3; Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos + cos(_j*0.52) * 40, Ypos + sin(_j*0.52) * 40, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos + cos(_j*0.52) * 40, Ypos + sin(_j*0.52) * 40, Width, Height, hmemdc1, 0, 0, SRCCOPY); } if (AnimateB == 9) { Sleep(DELAY); Xpos += Width; Ypos -= 8; Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); } if (AnimateB == 10) { Sleep(DELAY); Xpos -= Width; Ypos += 8; Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); } if (AnimateB == 11) { Sleep(DELAY); Xpos += Width; Ypos += 10; Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); } if (AnimateB == 12) { Ypos -= 5; Xpos -= Width; } if (AnimateB > 12 && AnimateB < 16)
		{
		       _k = AnimateB;

			Sleep(DELAY);

			Pic_Value(hWnd);
			if (PicValue == 1)
				BitBlt(hdc, Xpos + cos(_k*0.52) * 40, Ypos + sin(_k*0.52) * 40, Width, Height, hmemdc, 0, 0, SRCCOPY);
			else if (PicValue == 0)
				BitBlt(hdc, Xpos + cos(_k*0.52) * 40, Ypos + sin(_k*0.52) * 40, Width, Height, hmemdc1, 0, 0, SRCCOPY);
		}
	ReleaseDC(hWnd, hdc);
}


void Draw_T(HWND hWnd, int DELAY)
{
	HDC hdc;
	hdc = GetDC(hWnd);
		if (AnimateT < 5) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Xpos += Width; } if (AnimateT == 5) { Xpos -= 3 * Width; Ypos += Height; } if (AnimateT > 5 && AnimateT < 10) { Sleep(DELAY); Pic_Value(hWnd); if (PicValue == 1) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc, 0, 0, SRCCOPY); else if (PicValue == 0) BitBlt(hdc, Xpos, Ypos, Width, Height, hmemdc1, 0, 0, SRCCOPY); Ypos += Height; } ReleaseDC(hWnd, hdc); } void Pic_Value(HWND hWnd) { if (HALLOWEEN1 == FALSE && HALLOWEEN2 == FALSE) { if (PicValue == 1) PicValue = 0; else if (PicValue == 0) PicValue = 1; } else if (HALLOWEEN1 == TRUE && HALLOWEEN2 == TRUE) PicValue = 0; else if (HALLOWEEN1 == TRUE && HALLOWEEN2 == FALSE) PicValue = 1; } void SetBackground(HWND hWnd) { HDC hdc; hdc = GetDC(hWnd); BitBlt(hdc, 0, 0, 1200, 800, hmemdc2, 0, 0, SRCCOPY); ReleaseDC(hWnd, hdc); } void Animation(HWND hWnd, int cls) { int SPEED = 100; if (AnimateW >= 21)
		STEP += 1;
	if (AnimateI >= 15)
		STEP += 1;
	if (AnimateN >= 17)
		STEP += 1;
	if (AnimateD >= 13)
		STEP += 1;
	if (AnimateO >= 12)
		STEP += 1;
	if (AnimateS >= 22)
		STEP += 1;
	if (AnimateC >= 9)
		STEP += 1;
	if (AnimateE >= 15)
		STEP += 1;
	if (AnimateB >= 16)
		STEP += 1;
	if (AnimateT >= 10)
		STEP += 1;

		switch (STEP)
		{
		case 0:
			Draw_W(hWnd,SPEED);
			AnimateW++;
			break;
		case 1:
			Xpos += 2 * Width;
			Ypos += Height;
			STEP += 1;
			AnimateW = 0;
			break;
		case 2:
			Draw_I(hWnd, SPEED);
			AnimateI++;
			break;
		case 3:
			Xpos += 2 * Width;
			STEP += 1;
			AnimateI = 0;
			break;
		case 4:
			Draw_N(hWnd, SPEED);
			AnimateN++;
			break;
		case 5:
			Xpos += 3 * Width;
			Ypos += Height;
			STEP += 1;
			AnimateN = 0;
			break;
		case 6:
			Draw_D(hWnd, SPEED);
			AnimateD++;
			break;
		case 7:
			Xpos += 7 * Width;
			STEP += 1;
			AnimateD = 0;
			break;
		case 8:
			Draw_O(hWnd, SPEED);
			AnimateO++;
			break;
		case 9:
			Xpos += 4 * Width;
			Ypos -= 2 * Height;
			STEP += 1;
			AnimateO = 0;
			break;
		case 10:
			Draw_W(hWnd, SPEED);
			AnimateW++;
			break;
		case 11:
			Xpos += 5 * Width;
			Ypos += Height;
			STEP += 1;
			AnimateW = 0;
			break;
		case 12:
			Draw_S(hWnd, SPEED);
			AnimateS++;
			break;
		case 13:
			Xpos = Xinit;
			Ypos += 9 * Height;
			STEP += 1;
			AnimateS = 0;
			break;
		case 14:
			Draw_C(hWnd, SPEED);
			AnimateC++;
			break;
	        case 15:
			Xpos += 6 * Width;
			STEP += 1;
			AnimateC = 0;
			break;
		case 16:
			Draw_O(hWnd, SPEED);
			AnimateO++;
			break;
		case 17:
			Xpos += 5 * Width;
			Ypos -= 2 * Height;
			STEP += 1;
			AnimateO = 0;
			break;
		case 18:

			Draw_D(hWnd, SPEED);
			AnimateD++;
			break;
		case 19:
			Xpos += 7 * Width;
			Ypos -= 2 * Height;
			STEP += 1;
			AnimateD = 0;
			break;
		case 20:
			Draw_E(hWnd, SPEED);
			AnimateE++;
			break;
		case 21:
			Xpos += 7 * Width;
			STEP += 1;
			AnimateE = 0;
			break;
		case 22:
			Draw_B(hWnd, SPEED);
			AnimateB++;
			break;
		case 23:
			Xpos += 5 * Width;
			Ypos -= 2 * Height;
			STEP += 1;
			AnimateB = 0;
			break;
		case 24:
			Draw_I(hWnd, SPEED);
			AnimateI++;
			break;
		case 25:
			Xpos += 2 * Width;
			Ypos -= 4 * Height;
			STEP += 1;
			AnimateI = 0;
			break;
		case 26:
			Draw_T(hWnd, SPEED);
			AnimateT++;
			break;
		case 27:
			Xpos += 8 * Width;
			Ypos -= 5 * Height;
			STEP += 1;
			AnimateT = 0;
			break;
		case 28:
			Draw_S(hWnd, SPEED);
			AnimateS++;
			break;
		case 29:
			AnimateW = 0;
			AnimateI = 0;
			AnimateN = 0;
			AnimateC = 0;
			AnimateO = 0;
			AnimateD = 0;
			AnimateE = 0;
			AnimateB = 0;
			AnimateS = 0;
			AnimateT = 0;

			Xpos = Xinit;
			Ypos = Yinit;

			if (cls == 1)
				SetBackground(hWnd);
			if (HALLOWEEN1 == FALSE && HALLOWEEN2 == FALSE)
				HALLOWEEN1 = TRUE;
			else if (HALLOWEEN1 == TRUE && HALLOWEEN2 == FALSE)
				HALLOWEEN2 = TRUE;
			else if (HALLOWEEN1 == TRUE && HALLOWEEN2 == TRUE)
			{
				HALLOWEEN1 = FALSE;
				HALLOWEEN2 = FALSE;
			}
			STEP = 0;
			Sleep(300);

			break;
		}
}


 

You can also download the Halloween treats for Programmers :

Download the Project (2.07MB)

Download the .EXE only (0.99 MB)

We hope you liked this program. If you did, SHARE IT and SCARE YOUR FRIENDS. πŸ™‚

Tell us your opinion regarding the Halloween treats for programmers.

(Visited 446 times, 1 visits today)

4 comments

Leave a Reply

Your email address will not be published. Required fields are marked *