Programming 2D Games

The official forum for "Programming 2D Games" the book by: Charles Kelly

It is currently Sun Mar 29, 2020 6:46 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Feb 23, 2020 9:09 pm 
Offline

Joined: Thu Oct 05, 2017 6:53 am
Posts: 15
In `MessageDialog::update()` from messageDialog.cpp, screenRatioX and screenRatioY are only set if the game is in windowed mode.

If you change `FULLSCREEN` in constants.h from `false` to `true`, screenRatioX and screenRatioY remain uninitialized - making it impossible to click the OK or CANCEL button on the dialog.

To fix this, simply default them to 1.0 in `MessageDialog::update()`:
Code:
    screenRatioX = 1.0f; // <- ADDED
    screenRatioY = 1.0f; // <- ADDED
    if (graphics->getFullscreen() == false) // if windowed
    {
        // calculate screen ratios incase window was resized
        RECT clientRect;
        GetClientRect(hwnd, &clientRect);
        screenRatioX = (float)GAME_WIDTH / clientRect.right;
        screenRatioY = (float)GAME_HEIGHT / clientRect.bottom;
    }


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 24, 2020 2:33 pm 
Offline
Site Admin
User avatar

Joined: Sat Jan 28, 2012 4:36 pm
Posts: 554
Thanks for the feedback.

_________________
Professor Kelly


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group