@@ -12,6 +12,10 @@ HWND wnd; // current window
12
12
WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
13
13
WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
14
14
15
+ HBITMAP MMenu;
16
+ HBITMAP Paused;
17
+ HBITMAP Options;
18
+
15
19
HBITMAP TSimg;
16
20
HBITMAP TSmask;
17
21
HBITMAP playerSprite;
@@ -177,9 +181,10 @@ Text* modtxt1 = new Text(createRECT(0, 75, 250, 18), RGB(255, 255, 255), "Shifti
177
181
Text* modtxt2 = new Text(createRECT(0 , 92 , 250 , 18 ), RGB(255 , 255 , 255 ), " Control: " + std::to_string(globals::g_modKeys.at(VK_CONTROL)), DT_LEFT, true );
178
182
Text* modtxt3 = new Text(createRECT(0 , 109 , 250 , 18 ), RGB(255 , 255 , 255 ), " Tab: " + std::to_string(globals::g_modKeys.at(VK_TAB)), DT_LEFT, true );
179
183
180
- Text* debugtxt = new Text(createRECT(0 , 140 , 250 , 18 ), RGB(255 , 255 , 255 ), " Debug: " + std::to_string(globals::g_debug), DT_LEFT, true );
184
+ Text* debugtxt = new Text(createRECT(0 , 130 , 250 , 18 ), RGB(255 , 255 , 255 ), " Debug: " + std::to_string(globals::g_debug), DT_LEFT, true );
181
185
182
- Text* fpstxt = new Text(createRECT(0 , 165 , 250 , 18 ), RGB(255 , 255 , 255 ), " FPS: " + std::to_string(globals::g_fps), DT_LEFT, true );
186
+ Text* fpstxt = new Text(createRECT(0 , 150 , 250 , 18 ), RGB(255 , 255 , 255 ), " FPS: " + std::to_string(globals::g_fps), DT_LEFT, true );
187
+ Text* Afpstxt = new Text(createRECT(0 , 168 , 250 , 18 ), RGB(255 , 255 , 255 ), " AFPS: " + std::to_string(globals::g_fps), DT_LEFT, true );
183
188
184
189
Image* mousebox = new Image(createRECT(0 , 0 , 64 , 64 ), mouseSpriteU);
185
190
@@ -217,6 +222,8 @@ void end(int n)
217
222
delete globals::Options;
218
223
delete globals::Exit;
219
224
225
+ delete globals::ExitOps;
226
+
220
227
delete globals::g_player;
221
228
if (!globals::g_level->uninit )delete globals::g_level;
222
229
@@ -235,17 +242,24 @@ void end(int n)
235
242
exit (0 );
236
243
}
237
244
245
+ void exitOptions (int i)
246
+ {
247
+ globals::curScreen = globals::prevScreen;
248
+ }
249
+
238
250
void buildScreenObjects ()
239
251
{
240
- globals::NewGame = new Button (createRECT (225 , 0 , 300 , 100 ), RGB (70 , 125 , 150 ), &startN, " New Game" );
241
- globals::Continue = new Button (createRECT (225 , 90 , 300 , 100 ), RGB (70 , 125 , 150 ), &cont, " Continue" );
242
- globals::Options0 = new Button (createRECT (225 , 240 , 300 , 100 ), RGB (70 , 125 , 150 ), &options, " Options" );
243
- globals::End = new Button (createRECT (225 , 390 , 300 , 100 ), RGB (70 , 125 , 150 ), &end, " Exit" );
252
+ globals::NewGame = new Button (createRECT (225 , 35 , 300 , 100 ), RGB (70 , 125 , 150 ), &startN, " New Game" );
253
+ globals::Continue = new Button (createRECT (225 , 165 , 300 , 100 ), RGB (70 , 125 , 150 ), &cont, " Continue" );
254
+ globals::Options0 = new Button (createRECT (225 , 295 , 300 , 100 ), RGB (70 , 125 , 150 ), &options, " Options" );
255
+ globals::End = new Button (createRECT (225 , 425 , 300 , 100 ), RGB (70 , 125 , 150 ), &end, " Exit" );
244
256
245
257
globals::Resume = new Button (createRECT (225 , 90 , 300 , 100 ), RGB (70 , 125 , 150 ), &resume, " Resume" );
246
258
globals::Options = new Button (createRECT (225 , 240 , 300 , 100 ), RGB (70 , 125 , 150 ), &options, " Options" );
247
259
globals::Exit = new Button (createRECT (225 , 390 , 300 , 100 ), RGB (70 , 125 , 150 ), &quit, " Exit" );
248
260
261
+ globals::ExitOps = new Button (createRECT (225 , 390 , 300 , 100 ), RGB (70 , 125 , 150 ), &exitOptions, " Exit" );
262
+
249
263
tilesets.reserve (1 );
250
264
tileset->source = TSimg;
251
265
tileset->sourceMask = TSmask;
@@ -269,7 +283,7 @@ void buildScreenObjects()
269
283
270
284
globals::g_mousebox = mousebox;
271
285
272
- globals::g_ScreenObjects.reserve (12 );
286
+ globals::g_ScreenObjects.reserve (13 );
273
287
274
288
globals::g_ScreenObjects.push_back (mouseXtxt);
275
289
globals::g_ScreenObjects.push_back (mouseYtxt);
@@ -287,6 +301,7 @@ void buildScreenObjects()
287
301
globals::g_ScreenObjects.push_back (debugtxt);
288
302
289
303
globals::g_ScreenObjects.push_back (fpstxt);
304
+ globals::g_ScreenObjects.push_back (Afpstxt);
290
305
291
306
globals::g_ScreenObjects.push_back (globals::g_mousebox);
292
307
}
@@ -303,6 +318,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
303
318
return FALSE ;
304
319
}
305
320
321
+ // MMenu = LoadBitmap(hInst, MAKEINTRESOURCE(@TODO));
322
+ // Paused = LoadBitmap(hInst, MAKEINTRESOURCE(@TODO));
323
+ // Options = LoadBitmap(hInst, MAKEINTRESOURCE(@TODO));
324
+
306
325
TSimg = LoadBitmap (hInst, MAKEINTRESOURCE (IDB_TILESET1));
307
326
TSmask = CreateBitmapMask (TSimg, RGB (0 ,0 ,1 ));
308
327
playerSprite = LoadBitmap (hInst, MAKEINTRESOURCE (IDB_PLAYER1));
@@ -328,7 +347,7 @@ void pressed(WPARAM key)
328
347
{
329
348
if (globals::curScreen == 1 )
330
349
{
331
- globals::curScreen = globals::prevScreen ;
350
+ exitOptions ( 0 ) ;
332
351
}
333
352
else
334
353
{
@@ -387,6 +406,7 @@ void depressed(WPARAM key)
387
406
388
407
unsigned long long fpsTimer = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
389
408
unsigned int times = 0 ;
409
+ unsigned int Atimes = 0 ;
390
410
391
411
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
392
412
{
@@ -411,15 +431,20 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
411
431
RECT temp;
412
432
GetUpdateRect (hWnd, &temp, true );
413
433
pnt (hWnd, &temp);
434
+ Atimes++;
414
435
}
415
436
break ;
416
437
case WM_ERASEBKGND:
417
438
return TRUE ;
418
439
case WM_MOUSEMOVE:
419
440
globals::g_mouseX = GET_X_LPARAM (lParam);
420
441
globals::g_mouseY = GET_Y_LPARAM (lParam);
421
- mouseXtxt->text = " Mouse X: " + std::to_string (globals::g_mouseX);
422
- mouseYtxt->text = " Mouse Y: " + std::to_string (globals::g_mouseY);
442
+ if (globals::g_debug)
443
+ {
444
+ mouseXtxt->text = " Mouse X: " + std::to_string (globals::g_mouseX);
445
+ mouseYtxt->text = " Mouse Y: " + std::to_string (globals::g_mouseY);
446
+ }
447
+
423
448
if (globals::curScreen == 3 )
424
449
if (globals::g_mousebox->rect .left + 32 > 34 && globals::g_mousebox->rect .left + 32 < 734 && globals::g_mousebox->rect .top +32 > 35 && !globals::g_player->collideMouseX (float (mousebox->rect .left ), float (mousebox->rect .top ), false ) && !globals::g_player->collideMouseY (float (mousebox->rect .left ), float (mousebox->rect .top ), false ))
425
450
if (globals::g_modKeys.at (VK_SHIFT) || globals::g_mouseDown) globals::g_player->mousebox = true ;
@@ -451,6 +476,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
451
476
InvalidateRect (hWnd, &createRECT (0 , 0 , SWIDTH, SHEIGHT), true );
452
477
}
453
478
break ;
479
+ case 1 :
480
+ if (globals::ExitOps->active && globals::ExitOps->Touching (globals::g_mouseX, globals::g_mouseY))
481
+ {
482
+ globals::ExitOps->press (0 );
483
+ InvalidateRect (hWnd, &createRECT (0 , 0 , SWIDTH, SHEIGHT), true );
484
+ }
485
+ break ;
454
486
case 2 :
455
487
if (globals::Resume->active && globals::Resume->Touching (globals::g_mouseX, globals::g_mouseY))
456
488
{
@@ -508,9 +540,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
508
540
default :
509
541
pressed (wParam);
510
542
}
511
- modtxt1->text = " Shifting: " + std::to_string (globals::g_modKeys.at (VK_SHIFT));
512
- modtxt2->text = " Control: " + std::to_string (globals::g_modKeys.at (VK_CONTROL));
513
- modtxt3->text = " Tab: " + std::to_string (globals::g_modKeys.at (VK_TAB));
543
+ if (globals::g_debug)
544
+ {
545
+ modtxt1->text = " Shifting: " + std::to_string (globals::g_modKeys.at (VK_SHIFT));
546
+ modtxt2->text = " Control: " + std::to_string (globals::g_modKeys.at (VK_CONTROL));
547
+ modtxt3->text = " Tab: " + std::to_string (globals::g_modKeys.at (VK_TAB));
548
+ }
514
549
break ;
515
550
case WM_KEYUP:
516
551
switch (wParam)
@@ -529,22 +564,30 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
529
564
default :
530
565
depressed (wParam);
531
566
}
532
- modtxt1->text = " Shifting: " + std::to_string (globals::g_modKeys.at (VK_SHIFT));
533
- modtxt2->text = " Control: " + std::to_string (globals::g_modKeys.at (VK_CONTROL));
534
- modtxt3->text = " Tab: " + std::to_string (globals::g_modKeys.at (VK_TAB));
567
+ if (globals::g_debug)
568
+ {
569
+ modtxt1->text = " Shifting: " + std::to_string (globals::g_modKeys.at (VK_SHIFT));
570
+ modtxt2->text = " Control: " + std::to_string (globals::g_modKeys.at (VK_CONTROL));
571
+ modtxt3->text = " Tab: " + std::to_string (globals::g_modKeys.at (VK_TAB));
572
+ }
535
573
break ;
536
574
case WM_TIMER:
537
575
switch (wParam)
538
576
{
539
577
case 1 :
540
578
globals::timeNow = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ();
541
- timetxt->text = " Time Now: " + std::to_string (globals::timeNow);
579
+ if (globals::g_debug) timetxt->text = " Time Now: " + std::to_string (globals::timeNow);
542
580
if (globals::timeNow - fpsTimer >= 1000 )
543
581
{
544
582
fpsTimer += 1000 ;
545
583
globals::g_fps = times;
546
- fpstxt->text = " FPS: " + std::to_string (globals::g_fps);
584
+ if (globals::g_debug)
585
+ {
586
+ fpstxt->text = " FPS: " + std::to_string (globals::g_fps);
587
+ Afpstxt->text = " AFPS: " + std::to_string (Atimes);
588
+ }
547
589
times = 1 ;
590
+ Atimes = 0 ;
548
591
}
549
592
else {
550
593
times++;
0 commit comments