-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
1477 lines (1369 loc) · 53.4 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#include <iostream>
#include <vector>
#include <tchar.h>
#include <windows.h>
#include <mmsystem.h>
#include <cstdlib>
#include<time.h>
#define PRITISNUTO(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
const int TIMER_ID = 1;
const int BACKGROUND_TIMER_ID = 2;
const int START_TIMER_ID = 3;
const int END_TIMER_ID = 4;
const int GAME_TIMER_ID = 5;
const int LOLLIPOP_TIMER_ID = 6;
const int BALLOON_TIMER_ID = 7;
const int BIRD_TIMER_ID = 8;
const int TIME_BONUS_TIMER_ID = 9;
const int SECONDS10_BONUS_TIMER_ID = 10;
const int POINTS10_TIMER_ID = 11;
const int POINTS15_TIMER_ID = 12;
const int POINTSmin10_TIMER_ID = 13;
class Object
{
public:
int x, y, height, width, n;
int dx = 0;
int dy = 0;
};
Object Elf;
static int ElfCounterX = 0, ElfCounterY = 0, BalloonCounterX = 0, BalloonCounterY = 0, BirdCounterX = 0, BirdCounterY = 0;
Object background, backgroundBeginWindow, backgroundEndWindow;
static int startPoints, gameTime;
Object ScoreTable, Points10, PointsMin10, Points15, Seconds;
Object PlayButton, TryAgainButton, ExitButton;
std::vector<Object> presents, lollipops, balloons, houses, birds, clocks;
class Chimney
{
public:
int chimneyLeft, chimneyRight, height;
};
Chimney chimney;
BITMAP bitmap;
HBITMAP hbmBackground, hbmBackgroundBeginWindow, hbmBackgroundEndWindow;
HBITMAP hbmElf, hbmElfMask;
HBITMAP hbmHouse1, hbmHouse1Mask, hbmHouse2, hbmHouse2Mask, hbmHouse3, hbmHouse3Mask, hbmHouse4, hbmHouse4Mask, hbmHouse5, hbmHouse5Mask;
HBITMAP hbmPresent, hbmPresentMask;
HBITMAP hbmLollipop, hbmLollipopMask;
HBITMAP hbmBalloon, hbmBalloonMask;
HBITMAP hbmBird, hbmBirdMask;
HBITMAP hbmSnowman, hbmSnowmanMask;
HBITMAP hbmPurpleTree, hbmPurpleTreeMask, hbmGreenTree, hbmGreenTreeMask, hbmPinkTree, hbmPinkTreeMask;
HBITMAP hbmClock, hbmClockMask;
HBITMAP hbmScoreTable, hbmScoreTableMask;
HBITMAP hbmPoints10, hbmPoints10Mask;
HBITMAP hbmPointsMin10, hbmPointsMin10Mask;
HBITMAP hbmPoints15, hbmPoints15Mask;
HBITMAP hbmSeconds, hbmSecondsMask;
HBITMAP hbmPlay, hbmPlayMask;
HBITMAP hbmTryAgain, hbmTryAgainMask;
HBITMAP hbmExit, hbmExitMask;
void GameInitialize();
void CheckInput(HWND);
void Update();
void DrawGame(HDC, RECT*, HWND);
void makeHouse(int);
Chimney chimneyCoordinates(Object);
void finishTheGame(HWND);
void DrawWindow(HDC, RECT*);
void DrawBackground(HDC, RECT*);
static int TenPointsPic = 0, FifteenPointsPic = 0, TenSecondsPic = 0, MinusTenPointsPic = 0;
void TenPointsPicFunction(HDC, HDC, int, int);
void FifteenPointsPicFunction(HDC, HDC);
void MinusTenPointsPicFunction(HDC, HDC, int, int);
void TenSecondsPicFunction(HDC, HDC, int, int);
void UpdateHouse();
void UpdateClock();
void UpdateScore(int);
void UpdateBalloon();
void UpdateLollipop();
void UpdatePresent();
void UpdateBird();
void UpdateElf();
void presentSound();
void pointsSound();
void hitSound();
void timeLeakSound();
HWND hwndWindow;
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK GameWindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
TCHAR szClassName[ ] = _T("Elf Express");
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = "Parent";
wincl.lpfnWndProc = GameWindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = (HCURSOR)LoadImage(NULL, "cursor.cur", IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
"Parent", /* Classname */
_T("Elf Express"), /* Title Text */
WS_SYSMENU | WS_CAPTION, /* default window */
60, /* Windows decides the position */
60, /* where the window ends up on the screen */
1030, /* The programs width */
600, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* The Window structure */
wincl.lpszClassName = "ChoiceWindow";
wincl.lpfnWndProc = WindowProcedure;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwndWindow = CreateWindowEx (
0, /* Extended possibilites for variation */
"ChoiceWindow", /* Classname */
_T("Elf Express"), /* Title Text */
WS_CAPTION, /* default window */
60, /* Windows decides the position */
60, /* where the window ends up on the screen */
1030, /* The programs width */
600, /* and height in pixels */
hwnd, /* The window is a child-window to desktop */
NULL, /* No menu */
(HINSTANCE)GetWindowLong(hwnd, GWLP_HINSTANCE),/* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwndWindow, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
int START = 0;
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
BITMAP bitmap;
int playButtonEndX, playButtonEndY, TryAgainButtonW, TryAgainButtonH, ExitButtonW, ExitButtonH;
int x = LOWORD(lParam);
int y = HIWORD(lParam);
if(START == 0)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
{
SetTimer(hwnd, START_TIMER_ID, 1, NULL);
mciSendString("close gameSound", NULL, 0, NULL);
mciSendString("open sounds/gameSound.wav type waveaudio alias gameSound", NULL, 0, NULL);
mciSendString("play gameSound notify", NULL, 0, hwnd);
hbmBackgroundBeginWindow = (HBITMAP)LoadImage(NULL, "backgrounds/firstWindow.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmBackgroundBeginWindow, sizeof(bitmap), &bitmap);
backgroundBeginWindow.width = bitmap.bmWidth;
backgroundBeginWindow.height = bitmap.bmHeight;
hbmPlay = (HBITMAP)LoadImage(NULL, "buttons/playWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPlayMask = (HBITMAP)LoadImage(NULL, "buttons/playBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmPlay, sizeof(bitmap), &bitmap);
PlayButton.width = bitmap.bmWidth;
PlayButton.height = bitmap.bmHeight;
break;
}
case WM_TIMER:
{
switch(wParam)
{
case START_TIMER_ID:
{
HDC hdc = GetDC(hwnd);
RECT clientRect;
GetClientRect(hwnd, &clientRect);
DrawWindow(hdc, &clientRect);
ReleaseDC(hwnd, hdc);
break;
}
}
break;
}
case WM_KEYDOWN:
{
if(PRITISNUTO(0x50))//P as PLAY
{
HWND parent = GetWindow(hwnd, GW_OWNER);
DestroyWindow(hwndWindow);
SendMessage(parent, WM_SETREDRAW, 0, 0);
}
break;
}
case WM_LBUTTONDOWN:
{
HWND parent = GetWindow(hwnd, GW_OWNER);
playButtonEndX = (PlayButton.x + PlayButton.width);
playButtonEndY = (PlayButton.y + PlayButton.height);
if(x > PlayButton.x && x < playButtonEndX && y > PlayButton.y && y < playButtonEndY)
{
DestroyWindow(hwndWindow);
SendMessage(parent, WM_SETREDRAW, 0, 0);
}
break;
}
case WM_DESTROY:
KillTimer(hwnd, START_TIMER_ID);
mciSendString("close gameSound", NULL, 0, NULL);
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
}
if(START >= 1)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
{
SetTimer(hwnd, END_TIMER_ID, 40, NULL);
mciSendString("close gameSound", NULL, 0, NULL);
mciSendString("open sounds/gameSound.wav type waveaudio alias gameSound", NULL, 0, NULL);
mciSendString("play gameSound notify", NULL, 0, hwnd);
hbmBackgroundEndWindow = (HBITMAP)LoadImage(NULL, "backgrounds/endWindow.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmBackgroundEndWindow, sizeof(bitmap), &bitmap);
backgroundEndWindow.height = bitmap.bmHeight;
backgroundEndWindow.width = bitmap.bmWidth;
hbmExit = (HBITMAP)LoadImage(NULL, "buttons/exitWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmExitMask = (HBITMAP)LoadImage(NULL, "buttons/exitBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmExit, sizeof(bitmap), &bitmap);
ExitButton.height = bitmap.bmHeight;
ExitButton.width = bitmap.bmWidth;
hbmTryAgain = (HBITMAP)LoadImage(NULL, "buttons/tryAgainWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmTryAgainMask = (HBITMAP)LoadImage(NULL, "buttons/tryAgainBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmTryAgain, sizeof(bitmap), &bitmap);
TryAgainButton.height = bitmap.bmHeight;
TryAgainButton.width = bitmap.bmWidth;
break;
}
case WM_TIMER:
{
switch(wParam)
{
case END_TIMER_ID:
{
HDC hdc = GetDC(hwnd);
RECT clientRect;
GetClientRect(hwnd, &clientRect);
DrawWindow(hdc, &clientRect);
ReleaseDC(hwnd, hdc);
break;
}
}
break;
}
case WM_KEYDOWN:
{
HWND parent = GetWindow(hwnd, GW_OWNER);
if(PRITISNUTO(0x45))//E as EXIT
{
SendMessage(parent, WM_DESTROY, 0, 0);
}
if(PRITISNUTO(0x41))//A as AGAIN
{
DestroyWindow(hwndWindow);
SendMessage(parent, WM_SETREDRAW, 0, 0);
}
break;
}
case WM_LBUTTONDOWN:
{
HWND parent = GetWindow(hwnd, GW_OWNER);
TryAgainButtonW = TryAgainButton.x + TryAgainButton.width;
TryAgainButtonH = TryAgainButton.y + TryAgainButton.height;
ExitButtonW = ExitButton.x + ExitButton.width;
ExitButtonH = ExitButton.y + ExitButton.height;
if(x > TryAgainButton.x && x < TryAgainButtonW && y > TryAgainButton.y && y < TryAgainButtonH)
{
DestroyWindow(hwndWindow);
SendMessage(parent, WM_SETREDRAW, 0, 0);
}
if(x > ExitButton.x && x < ExitButtonW && y > ExitButton.y && y < ExitButtonH)
{
SendMessage(parent, WM_DESTROY, 0, 0);
}
break;
}
case WM_DESTROY:
KillTimer(hwnd, END_TIMER_ID);
mciSendString("close gameSound", NULL, 0, NULL);
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
}
return 0;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK GameWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
{
SetTimer(hwnd, BACKGROUND_TIMER_ID, 100, NULL);
break;
}
case WM_SETREDRAW:
{
startPoints = 0;
gameTime = 59;
Elf.x = 0;
Elf.y = 150;
KillTimer(hwnd, BACKGROUND_TIMER_ID);
SetTimer(hwnd, TIMER_ID, 100, NULL);
SetTimer(hwnd, GAME_TIMER_ID, 1000, NULL);
SetTimer(hwnd, TIME_BONUS_TIMER_ID, 9000, NULL);
SetTimer(hwnd, BALLOON_TIMER_ID, 13000, NULL);
SetTimer(hwnd, LOLLIPOP_TIMER_ID, 7000, NULL);
SetTimer(hwnd, BIRD_TIMER_ID, 11000, NULL);
GameInitialize();
break;
}
case WM_KEYDOWN:
{
CheckInput(hwnd);
break;
}
case WM_TIMER:
{
BITMAP bitmap;
HDC hdc = GetDC(hwnd);
RECT clientRect;
GetClientRect(hwnd, &clientRect);
switch(wParam)
{
case TIMER_ID:
{
Update();
DrawGame(hdc, &clientRect, hwnd);
ReleaseDC(hwnd, hdc);
break;
}
case GAME_TIMER_ID:
{
gameTime-=1;;
break;
}
case TIME_BONUS_TIMER_ID:
{
Object clock;
GetObject(hbmClock, sizeof(bitmap), &bitmap);
clock.height = bitmap.bmHeight;
clock.width = bitmap.bmWidth;
clock.dx = 10;
clock.x = 1024;
srand(time(0));
clock.y = rand() % (285 - clock.height) + 1;
clocks.push_back(clock);
break;
}
case LOLLIPOP_TIMER_ID:
{
Object lollipop;
GetObject(hbmLollipop, sizeof(bitmap), &bitmap);
lollipop.height = bitmap.bmHeight;
lollipop.width = bitmap.bmWidth;
lollipop.dx = 10;
lollipop.x = 1024;
srand(time(0));
lollipop.y = rand()%285;
lollipops.push_back(lollipop);
break;
}
case BALLOON_TIMER_ID:
{
Object balloon;
GetObject(hbmBalloon, sizeof(bitmap), &bitmap);
balloon.height = bitmap.bmHeight / 2;
balloon.width = bitmap.bmWidth / 5;
balloon.dx = 20;
balloon.x = 1024;
srand(time(0));
balloon.y = rand()%(285 - balloon.height);
balloons.push_back(balloon);
break;
}
case BIRD_TIMER_ID:
{
Object bird;
GetObject(hbmBird, sizeof(bitmap), &bitmap);
bird.height = bitmap.bmHeight / 2;
bird.width = bitmap.bmWidth / 8;
bird.dx = 20;
bird.x = 1024;
srand(time(0));
bird.y = rand()%285;
birds.push_back(bird);
break;
}
case POINTS15_TIMER_ID:
{
FifteenPointsPic = 0;
break;
}
case POINTS10_TIMER_ID:
{
TenPointsPic = 0;
break;
}
case SECONDS10_BONUS_TIMER_ID:
{
TenSecondsPic = 0;
break;
}
case POINTSmin10_TIMER_ID:
{
MinusTenPointsPic = 0;
break;
}
case BACKGROUND_TIMER_ID:
{
DrawBackground(hdc, &clientRect);
ReleaseDC(hwnd, hdc);
break;
}
}
break;
}
case WM_DESTROY:
KillTimer(hwnd, TIMER_ID);
KillTimer(hwnd, GAME_TIMER_ID);
KillTimer(hwnd, TIME_BONUS_TIMER_ID);
KillTimer(hwnd, BALLOON_TIMER_ID);
KillTimer(hwnd, LOLLIPOP_TIMER_ID);
KillTimer(hwnd, BIRD_TIMER_ID);
KillTimer(hwnd, POINTS15_TIMER_ID);
KillTimer(hwnd, POINTS10_TIMER_ID);
KillTimer(hwnd, POINTSmin10_TIMER_ID);
KillTimer(hwnd, SECONDS10_BONUS_TIMER_ID);
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
void DrawWindow(HDC hdc, RECT *rect)
{
HDC hdcBuffer = CreateCompatibleDC(hdc);
HBITMAP hbmBuffer = CreateCompatibleBitmap(hdc, rect->right, rect->bottom);
HBITMAP hbmBufferOld = (HBITMAP)SelectObject(hdcBuffer, hbmBuffer);
HDC hdcMem = CreateCompatibleDC(hdc);
if(START == 0)
{
HBITMAP hbmMemOld = (HBITMAP)SelectObject(hdcMem, hbmBackgroundBeginWindow);
BitBlt(hdcBuffer, backgroundBeginWindow.x, backgroundBeginWindow.y, backgroundBeginWindow.width, backgroundBeginWindow.height, hdcMem, 0, 0, SRCCOPY);
PlayButton.x = rect->right/2 - PlayButton.width/2;
PlayButton.y = 273;
SelectObject(hdcMem, hbmPlay);
BitBlt(hdcBuffer, PlayButton.x, PlayButton.y, PlayButton.width, PlayButton.height, hdcMem, 0, 0,SRCAND);
SelectObject(hdcMem, hbmPlayMask);
BitBlt(hdcBuffer, PlayButton.x, PlayButton.y,PlayButton.width, PlayButton.height, hdcMem, 0, 0,SRCPAINT);
SelectObject(hdcMem, hbmMemOld);
DeleteDC(hdcMem);
BitBlt(hdc, 0, 0, rect->right, rect->bottom, hdcBuffer, 0, 0, SRCCOPY);
SelectObject(hdcBuffer, hbmBufferOld);
DeleteDC(hdcBuffer);
DeleteObject(hbmBuffer);
}
else if(START >= 1)
{
HBITMAP hBmMemOld = (HBITMAP)SelectObject(hdcMem, hbmBackgroundEndWindow);
BitBlt(hdcBuffer, backgroundEndWindow.x, backgroundEndWindow.y, backgroundEndWindow.width, backgroundEndWindow.height, hdcMem, 0, 0, SRCCOPY);
TryAgainButton.x = 110;
TryAgainButton.y = 360;
SelectObject(hdcMem, hbmTryAgain);
BitBlt(hdcBuffer, TryAgainButton.x, TryAgainButton.y, TryAgainButton.width, TryAgainButton.height, hdcMem, 0, 0,SRCAND);
SelectObject(hdcMem, hbmTryAgainMask);
BitBlt(hdcBuffer, TryAgainButton.x, TryAgainButton.y, TryAgainButton.width, TryAgainButton.height, hdcMem, 0, 0,SRCPAINT);
ExitButton.x = 600;
ExitButton.y = 360;
SelectObject(hdcMem, hbmExit);
BitBlt(hdcBuffer, ExitButton.x, ExitButton.y, ExitButton.width, ExitButton.height, hdcMem, 0, 0,SRCAND);
SelectObject(hdcMem, hbmExitMask);
BitBlt(hdcBuffer, ExitButton.x, ExitButton.y, ExitButton.width, ExitButton.height, hdcMem, 0, 0,SRCPAINT);
SelectObject(hdcMem, hBmMemOld);
DeleteDC(hdcMem);
BitBlt(hdc, 0, 0, rect->right, rect->bottom, hdcBuffer, 0, 0, SRCCOPY);
SelectObject(hdcBuffer, hbmBufferOld);
DeleteDC(hdcBuffer);
DeleteObject(hbmBuffer);
SetTextColor(hdc, RGB(102,0,102));
SetBkMode(hdc, TRANSPARENT);
HFONT hFont = CreateFont (50, 0, 0, 0, 700, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma"));
SelectObject(hdc,(HFONT)(hFont));
if(startPoints < 10)
{
TextOut(hdc, rect->right/2 - 10, rect->bottom/2 + 15, std::to_string(startPoints).c_str(), std::to_string(startPoints).length());
}
if(startPoints > 9 && startPoints < 100)
{
TextOut(hdc, rect->right/2 - 25, rect->bottom/2 + 15, std::to_string(startPoints).c_str(), std::to_string(startPoints).length());
}
if(startPoints > 99 && startPoints < 1000)
{
TextOut(hdc, rect->right/2 - 35, rect->bottom/2 + 15, std::to_string(startPoints).c_str(), std::to_string(startPoints).length());
}
}
}
void GameInitialize()
{
BITMAP bitmap;
hbmBackground = (HBITMAP)LoadImage(NULL, "backgrounds/background.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmBackground, sizeof(bitmap), &bitmap);
background.height = bitmap.bmHeight;
background.width = bitmap.bmWidth;
hbmHouse1 = (HBITMAP)LoadImage(NULL, "houses/house1White.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmHouse1Mask = (HBITMAP)LoadImage(NULL, "houses/house1Black.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmHouse2 = (HBITMAP)LoadImage(NULL, "houses/house2White.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmHouse2Mask = (HBITMAP)LoadImage(NULL, "houses/house2Black.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmHouse3 = (HBITMAP)LoadImage(NULL, "houses/house3White.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmHouse3Mask = (HBITMAP)LoadImage(NULL, "houses/house3Black.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmHouse4 = (HBITMAP)LoadImage(NULL, "houses/house4White.bmp", IMAGE_BITMAP, 0,0, LR_LOADFROMFILE);
hbmHouse4Mask = (HBITMAP)LoadImage(NULL, "houses/house4Black.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmHouse5 = (HBITMAP)LoadImage(NULL, "houses/house5White.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmHouse5Mask = (HBITMAP)LoadImage(NULL, "houses/house5Black.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPurpleTree = (HBITMAP)LoadImage(NULL, "trees/purpleTreeWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPurpleTreeMask = (HBITMAP)LoadImage(NULL, "trees/purpleTreeBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmGreenTree = (HBITMAP)LoadImage(NULL, "trees/greenTreeWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmGreenTreeMask = (HBITMAP)LoadImage(NULL, "trees/greenTreeBlack.bmp", IMAGE_BITMAP, 0,0, LR_LOADFROMFILE);
hbmPinkTree = (HBITMAP)LoadImage(NULL, "trees/pinkTreeWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPinkTreeMask = (HBITMAP)LoadImage(NULL, "trees/pinkTreeBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmSnowman = (HBITMAP)LoadImage(NULL, "trees/snowmanWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmSnowmanMask = (HBITMAP)LoadImage(NULL, "trees/snowmanBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPresent = (HBITMAP)LoadImage(NULL, "other/presentWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPresentMask = (HBITMAP)LoadImage(NULL, "other/presentBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmLollipop = (HBITMAP)LoadImage(NULL, "other/lollipopWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmLollipopMask = (HBITMAP)LoadImage(NULL, "other/lollipopBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmBird = (HBITMAP)LoadImage(NULL, "other/birdWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmBirdMask = (HBITMAP)LoadImage(NULL, "other/birdBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmBalloon = (HBITMAP)LoadImage(NULL, "other/balloonWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmBalloonMask = (HBITMAP)LoadImage(NULL, "other/balloonBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmClock = (HBITMAP)LoadImage(NULL, "other/clock.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmClockMask = (HBITMAP)LoadImage(NULL, "other/clockBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmElf = (HBITMAP)LoadImage(NULL, "other/elfWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmElfMask = (HBITMAP)LoadImage(NULL, "other/elfBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmElf, sizeof(bitmap), &bitmap);
Elf.height = bitmap.bmHeight/2;
Elf.width = bitmap.bmWidth/5;
Elf.x = 0;
Elf.y = 150;
Elf.dx = 15;
Elf.dy = 15;
hbmScoreTable = (HBITMAP)LoadImage(NULL, "points/scoreTableWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmScoreTableMask = (HBITMAP)LoadImage(NULL, "points/scoreTableBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmScoreTable, sizeof(bitmap), &bitmap);
ScoreTable.height = bitmap.bmHeight;
ScoreTable.width = bitmap.bmWidth;
ScoreTable.x = 512 - (ScoreTable.width/2);
ScoreTable.y = 5;
hbmPoints10 = (HBITMAP)LoadImage(NULL, "points/plus10.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPoints10Mask = (HBITMAP)LoadImage(NULL, "points/plus10Black.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmPoints10Mask, sizeof(bitmap), &bitmap);
Points10.height = bitmap.bmHeight;
Points10.width = bitmap.bmWidth;
hbmPointsMin10 = (HBITMAP)LoadImage(NULL, "points/min10White.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPointsMin10Mask = (HBITMAP)LoadImage(NULL, "points/min10Black.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmPointsMin10Mask, sizeof(bitmap), &bitmap);
PointsMin10.height = bitmap.bmHeight;
PointsMin10.width = bitmap.bmWidth;
hbmPoints15 = (HBITMAP)LoadImage(NULL, "points/plus15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmPoints15Mask = (HBITMAP)LoadImage(NULL, "points/plus15Black.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmPoints15Mask, sizeof(bitmap), &bitmap);
Points15.height = bitmap.bmHeight;
Points15.width = bitmap.bmWidth;
hbmSeconds = (HBITMAP)LoadImage(NULL, "points/plusTimeWhite.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmSecondsMask = (HBITMAP)LoadImage(NULL, "points/plusTimeBlack.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hbmSeconds, sizeof(bitmap), &bitmap);
Seconds.height = bitmap.bmHeight;
Seconds.width = bitmap.bmWidth;
srand(time(0));
makeHouse(rand() % 9 + 1);
}
void DrawBackground(HDC hdc, RECT* rect)
{
HDC hdcBuffer = CreateCompatibleDC(hdc);
HBITMAP hBmBuffer = CreateCompatibleBitmap(hdc, rect->right, rect->bottom);
HBITMAP hBmBufferOld = (HBITMAP)SelectObject(hdcBuffer, hBmBuffer);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hBmMemOld = (HBITMAP)SelectObject(hdcMem, hbmBackground);
BitBlt(hdcBuffer, background.x, background.y, background.width, background.height, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hBmMemOld);
DeleteDC(hdcMem);
BitBlt(hdc, 0, 0, rect->right, rect->bottom, hdcBuffer, 0, 0, SRCCOPY);
SelectObject(hdcBuffer, hBmBufferOld);
DeleteDC(hdcBuffer);
DeleteObject(hBmBuffer);
}
void DrawGame(HDC hdc, RECT *rect, HWND hwnd)
{
HDC hdcBuffer = CreateCompatibleDC(hdc);
HBITMAP hbmBuffer = CreateCompatibleBitmap(hdc, rect->right, rect->bottom);
HBITMAP hbmBufferOld = (HBITMAP)SelectObject(hdcBuffer, hbmBuffer);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmMemOld = (HBITMAP)SelectObject(hdcMem, hbmBackground);
BitBlt(hdcBuffer, background.x, background.y, background.width, background.height, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hbmElf);
BitBlt(hdcBuffer, Elf.x, Elf.y, Elf.width, Elf.height, hdcMem, ElfCounterX*Elf.width, ElfCounterY*Elf.height, SRCAND);
SelectObject(hdcMem, hbmElfMask);
BitBlt(hdcBuffer, Elf.x, Elf.y, Elf.width, Elf.height, hdcMem, ElfCounterX*Elf.width, ElfCounterY*Elf.height, SRCPAINT);
for(int i = 0; i<(int)(houses.size()); i++)
{
if(houses[i].n == 1)
{
SelectObject(hdcMem, hbmHouse1);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmHouse1Mask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
else if(houses[i].n == 2)
{
SelectObject(hdcMem, hbmHouse2);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmHouse2Mask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
else if(houses[i].n == 3)
{
SelectObject(hdcMem, hbmGreenTree);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmGreenTreeMask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
else if(houses[i].n == 4)
{
SelectObject(hdcMem, hbmHouse4);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmHouse4Mask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
else if(houses[i].n == 5)
{
SelectObject(hdcMem, hbmSnowman);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmSnowmanMask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
else if(houses[i].n == 6)
{
SelectObject(hdcMem, hbmHouse3);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmHouse3Mask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
else if(houses[i].n == 7)
{
SelectObject(hdcMem, hbmPinkTree);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmPinkTreeMask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
else if(houses[i].n == 8)
{
SelectObject(hdcMem, hbmHouse5);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmHouse5Mask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
else if(houses[i].n == 9)
{
SelectObject(hdcMem, hbmPurpleTree);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmPurpleTreeMask);
BitBlt(hdcBuffer, houses[i].x, houses[i].y, houses[i].width, houses[i].height, hdcMem, 0, 0, SRCPAINT);
}
for(int j = 0; j<(int)(presents.size()); j++)
{
Object pr = presents[j];
int prX = presents[j].x;
int prY = presents[j].y;
SelectObject(hdcMem, hbmPresent);
BitBlt(hdcBuffer, prX, prY, pr.width, pr.height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmPresentMask);
BitBlt(hdcBuffer, prX, prY, pr.width, pr.height, hdcMem, 0, 0, SRCPAINT);
if(houses[i].n > 0 && houses[i].n < 9)
{
chimney = chimneyCoordinates(houses[i]);
if((chimney.height - 10 <= prY) && (chimney.height + 10 >= prY) && (chimney.chimneyLeft <= prX) && (chimney.chimneyRight >= prX))
{
UpdateScore(15);
Points15.x = prX;
Points15.y = prY;
FifteenPointsPic = 1;
presents.erase(presents.begin() + j);
SetTimer(hwnd, POINTS15_TIMER_ID, 1000, NULL);
presentSound();
}
}
else if(prY > rect->bottom)
{
FifteenPointsPic = 0;
presents.erase(presents.begin() + j);
}
}
}
if((houses[0].x + houses[0].width) < rect->left)
{
houses.erase(houses.begin());
}
if((houses[houses.size()-1].x + houses[houses.size()-1].width) < rect->right)
{
srand(time(0));
makeHouse(rand() % 9 + 1);
}
if(FifteenPointsPic != 0)
{
FifteenPointsPicFunction(hdcMem, hdcBuffer);
}
for(int k = 0; k <(int)(lollipops.size()); k++)
{
Object lp = lollipops[k];
int lpX = lollipops[k].x;
int lpY = lollipops[k].y;
SelectObject(hdcMem, hbmLollipop);
BitBlt(hdcBuffer, lpX, lpY, lp.width, lp.height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmLollipopMask);
BitBlt(hdcBuffer, lpX, lpY, lp.width, lp.height, hdcMem, 0, 0, SRCPAINT);
if(lpX < Elf.x)
{
TenPointsPic = 0;
}
else if((lpX <= Elf.x + Elf.width) && (lpY <= Elf.y + Elf.height) && (lpY + lp.height >= Elf.y))
{
Points10.x = lpX;
Points10.y = lpY;
UpdateScore(10);
TenPointsPic = 1;
lollipops.erase(lollipops.begin() + k);
SetTimer(hwnd, POINTS10_TIMER_ID, 1000, NULL);
pointsSound();
}
}
if(TenPointsPic!=0)
{
TenPointsPicFunction(hdcMem, hdcBuffer, Points10.x, Points10.y);
}
if(!lollipops.empty() && (lollipops[0].x + lollipops[0].width < rect->left))
{
lollipops.erase(lollipops.begin());
}
for(int l = 0; l<(int)(birds.size()); l++)
{
Object b = birds[l];
int bX = birds[l].x;
int bY = birds[l].y;
SelectObject(hdcMem, hbmBird);
BitBlt(hdcBuffer, bX, bY, b.width, b.height, hdcMem, BirdCounterX*b.width, BirdCounterY*b.height, SRCAND);
SelectObject(hdcMem, hbmBirdMask);
BitBlt(hdcBuffer, bX, bY, b.width, b.height, hdcMem, BirdCounterX*b.width, BirdCounterY*b.height, SRCPAINT);
if(bX + b.width < rect->left || bY + b.height > rect->bottom)
{
birds.erase(birds.begin()+l);
}
if(bX < Elf.x)
{
MinusTenPointsPic = 0;
}
else if((bX <= Elf.x + Elf.width) && (bY <= Elf.y + Elf.height) && (bY + b.height >= Elf.y))
{
PointsMin10.x = bX;
PointsMin10.y = bY;
UpdateScore(-10);
MinusTenPointsPic = 1;
birds.erase(birds.begin() + l);
SetTimer(hwnd, POINTSmin10_TIMER_ID, 1000, NULL);
hitSound();
}
}
if(MinusTenPointsPic!=0)
{
MinusTenPointsPicFunction(hdcMem, hdcBuffer, PointsMin10.x, PointsMin10.y);
}
if(!birds.empty() && (birds[0].x + birds[0].width < rect->left))
{
birds.erase(birds.begin());
}
for(int m = 0; m<(int)(balloons.size()); m++)
{
Object bl = balloons[m];
int blX = balloons[m].x;
int blY = balloons[m].y;
SelectObject(hdcMem, hbmBalloon);
BitBlt(hdcBuffer, blX, blY, bl.width, bl.height, hdcMem, BalloonCounterX*bl.width, BalloonCounterY*bl.height,SRCAND);
SelectObject(hdcMem, hbmBalloonMask);
BitBlt(hdcBuffer, blX, blY, bl.width, bl.height, hdcMem, BalloonCounterX*bl.width, BalloonCounterY*bl.height,SRCPAINT);
if(blX + bl.width < rect->left || blY + bl.height > rect->bottom)
{
balloons.erase(balloons.begin() + m);
}
if(blX < Elf.x)
{
TenPointsPic = 0;
}
else if((blX <= Elf.x + Elf.width) && (blY <= Elf.y + Elf.height) && (blY + bl.height >= Elf.y))
{
Points10.x = blX;
Points10.y = blY;
UpdateScore(10);
TenPointsPic = 1;
SetTimer(hwnd, POINTS10_TIMER_ID, 1000, NULL);
pointsSound();
balloons.erase(balloons.begin() + m);
}
}
if(TenPointsPic!=0)
{
TenPointsPicFunction(hdcMem, hdcBuffer, Points10.x, Points10.y);
}
if(!balloons.empty() && (balloons[0].x + balloons[0].width < rect->left))
{
balloons.erase(balloons.begin());
}
for(int n = 0; n<(int)(clocks.size()); n++)
{
Object cl = clocks[n];
int clX = clocks[n].x;
int clY = clocks[n].y;
SelectObject(hdcMem, hbmClock);
BitBlt(hdcBuffer, clX, clY, cl.width, cl.height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmClockMask);
BitBlt(hdcBuffer, clX, clY, cl.width, cl.height, hdcMem, 0, 0, SRCPAINT);
if(clX < Elf.x)
{
TenSecondsPic = 0;
}
else if((clX <= Elf.x + Elf.width) && (clY <= Elf.y + Elf.height) && (clY + cl.height >= Elf.y))
{
gameTime += 5;
Seconds.x = clX;
Seconds.y = clY;
TenSecondsPic = 1;
clocks.erase(clocks.begin() + n);
SetTimer(hwnd, SECONDS10_BONUS_TIMER_ID, 1000, NULL);
pointsSound();
}
}
if(TenSecondsPic!=0)
{
TenSecondsPicFunction(hdcMem, hdcBuffer, Seconds.x, Seconds.y);
}
if(!clocks.empty() && (clocks[0].x + clocks[0].width < rect->left))
{
clocks.erase(clocks.begin());
}
SelectObject(hdcMem, hbmScoreTable);
BitBlt(hdcBuffer, ScoreTable.x, ScoreTable.y,ScoreTable.width, ScoreTable.height, hdcMem, 0, 0, SRCAND);
SelectObject(hdcMem, hbmScoreTableMask);
BitBlt(hdcBuffer, ScoreTable.x, ScoreTable.y, ScoreTable.width, ScoreTable.height, hdcMem, 0, 0, SRCPAINT);
SelectObject(hdcMem, hbmMemOld);
DeleteDC(hdcMem);
BitBlt(hdc, 0, 0, rect->right, rect->bottom, hdcBuffer, 0, 0, SRCCOPY);
SelectObject(hdcBuffer, hbmBufferOld);
DeleteDC(hdcBuffer);
DeleteObject(hbmBuffer);
if(startPoints == 0)
{
std::string level = "LEVEL 1";
SetTextColor(hdc, RGB(102,0,102));
SetBkMode(hdc, TRANSPARENT);
HFONT hFont = CreateFont (50, 0, 0, 0, 700, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Black Cooper"));
SelectObject(hdc,(HFONT)(hFont));