Download: [link]
Size: 11KB

Project Start: 2007

Language(s):

Homer Simpson

In Windows Programming, we were to create a Three Man's Morris game over the course of the class with goals to complete each day. Being chronicly ahead of schedule, I was given a few extra assignments to keep me busy. After swiftly finishing the Union Jack, I was told to do Homer Simpson using only the pen, line and circle tools. I did not finish, however what I did make was relatively impressive in the time I had.

Provided Code:

void OnPaint(HWND hWnd)
{

PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hWnd, &ps);

// background yaaaaaaay
RECT rClient;
GetClientRect(hWnd, &rClient);
HBRUSH fill = CreateSolidBrush(RGB(50, 50, 200));
FillRect(hdc, &rClient, fill );
DeleteObject(fill);

HPEN blacklines = CreatePen(1, 5, RGB(0, 0, 0));
HPEN yellowlines = CreatePen(1, 15, RGB(255, 255, 0));
HPEN tanlines = CreatePen(1, 15, RGB(185, 185, 15));
HPEN oldpen = (HPEN)SelectObject(hdc, blacklines);
HBRUSH yellowint = CreateSolidBrush(RGB(255, 255, 0));
HBRUSH blackint = CreateSolidBrush(RGB(0, 0, 0));
HBRUSH tanint = CreateSolidBrush(RGB(185, 185, 15));
HBRUSH oldbrush = (HBRUSH)SelectObject(hdc, yellowint);

// head base
Ellipse(hdc, 100, 100, 350, 350);

// eyes
SelectObject(hdc, oldbrush);
Ellipse(hdc, 275, 200, 340, 275);
Ellipse(hdc, 200, 200, 275, 275);
SelectObject(hdc, blackint);
Ellipse(hdc, 220, 220, 230, 230);
Ellipse(hdc, 290, 220, 300, 230);


// mouth
SelectObject(hdc, tanint);
SelectObject(hdc, blacklines);
Ellipse(hdc, 190, 300, 320, 400);
Ellipse(hdc, 195, 330, 325, 380);
Ellipse(hdc, 205, 300, 340, 350);
SelectObject(hdc, tanlines);
MoveToEx(hdc, 207, 330, NULL);
LineTo(hdc, 212, 330);
MoveToEx(hdc, 207, 340, NULL);
LineTo(hdc, 212, 340);
MoveToEx(hdc, 200, 350, NULL);
LineTo(hdc, 205, 350);
MoveToEx(hdc, 202, 360, NULL);
LineTo(hdc, 235, 360);
MoveToEx(hdc, 210, 369, NULL);
LineTo(hdc, 300, 370);
MoveToEx(hdc, 220, 379, NULL);
LineTo(hdc, 280, 382);


// nose
SelectObject(hdc, blacklines);
SelectObject(hdc, yellowint);
Ellipse(hdc, 275, 265, 350, 310);
MoveToEx(hdc, 275, 265, NULL);
LineTo(hdc, 300, 265);
SelectObject(hdc, yellowlines);
MoveToEx(hdc, 275, 275, NULL);
LineTo(hdc, 300, 275);
MoveToEx(hdc, 275, 290, NULL);
LineTo(hdc, 300, 290);
MoveToEx(hdc, 275, 290, NULL);
LineTo(hdc, 300, 290);


// ear
SelectObject(hdc, blacklines);
SelectObject(hdc, yellowint);
Ellipse(hdc, 75, 225, 130, 280);
SelectObject(hdc, yellowlines);
MoveToEx(hdc, 125, 225, NULL);
LineTo(hdc, 125, 275);


// hair
SelectObject(hdc, blacklines);
MoveToEx(hdc, 75, 225, NULL);
LineTo(hdc, 90, 200);
MoveToEx(hdc, 90, 200, NULL);
LineTo(hdc, 110, 225);
MoveToEx(hdc, 110, 225, NULL);
LineTo(hdc, 130, 200);
MoveToEx(hdc, 130, 200, NULL);
LineTo(hdc, 140, 225);


// face
MoveToEx(hdc, 110, 280, NULL);
LineTo(hdc, 110, 350);
SelectObject(hdc, yellowlines);
MoveToEx(hdc, 120, 280, NULL);
LineTo(hdc, 120, 350);
MoveToEx(hdc, 135, 280, NULL);
LineTo(hdc, 135, 350);
MoveToEx(hdc, 145, 280, NULL);
LineTo(hdc, 145, 350);
MoveToEx(hdc, 155, 280, NULL);
LineTo(hdc, 155, 350);
MoveToEx(hdc, 165, 280, NULL);
LineTo(hdc, 165, 350);
MoveToEx(hdc, 175, 280, NULL);
LineTo(hdc, 175, 350);
MoveToEx(hdc, 180, 280, NULL);
LineTo(hdc, 180, 350);


SelectObject(hdc, oldpen);
SelectObject(hdc, oldbrush);
DeleteObject(tanint);
DeleteObject(yellowlines);
DeleteObject(blacklines);
DeleteObject(yellowint);
DeleteObject(blackint);


EndPaint(hWnd, &ps);
}