• Advertisement
Sign in to follow this  

Allegro Question

This topic is 3440 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am reading game programming all in one and it has that I should use SCREEN_W-1 and SCREEN_H-1.I was wondering why is there a minus 1 and why can't I use just SCREEN_H?

Share this post


Link to post
Share on other sites
Advertisement
It likely means that the screen coordinates start at zero. Therefore, for the width of the drawing area to be SCREEN_W wide then the coordinates are from 0 to SCREEN_W - 1.

Share this post


Link to post
Share on other sites
Also, when I read that book I remember the author mentioning that it was easy to crash Allegro if you went outside of your drawing area when using certain functions so he does that in all his code to safeguard against the infamous "off by one bugs".
Personally, I just stuck with SCREEN_W and SCREEN_H myself since that's what all the official Allegro tutorials and documentation uses, it's less typing and looks more readable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement