Understanding screen and internal coordinates
Before we move on to the actual C++ coding, let's talk a little about coordinates. All the images that we see on our monitors are made out of pixels. Pixels are little tiny dots of light that combine to make the images we see.
There are many different monitor resolutions but, as an example, a fairly typical gamer's monitor might have 1920 pixels horizontally and 1080 pixels vertically.
The pixels are numbered starting at the top left of the screen. As you can see from the next diagram, our 1920 x 1080 example is numbered from 0 through to 1919 on the horizontal (x) axis and 0 through 1079 on the vertical (y) axis.
A specific and exact screen location can therefore be identified by x and y coordinate. ...
Get Beginning C++ Game Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.