Sign in to follow this  
maniac20

Allegro Question

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this