I am trying to write a game and having an odd problem. I followed the tutorials up to the events and added my own code. Here it is:
When I run the program, the grids go roughly 3/4 across the screen and the second is only drawn half. Here is a screen shot.
{"name":"611964","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/a\/8ace26d230bf6346e28449d0e01f768c.png","w":1366,"h":768,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/a\/8ace26d230bf6346e28449d0e01f768c"}
I did try it in full screen and it worked perfectly. I also tried a simple line drawing program, one across the top of the screen and one down the left side. The side line appeared to be correct but the top one was short. Did I get ahead of myself or is something wrong with my program?
You have your height and width reversed (if you want 640x480).
You have display = al_create_display(display_height, display_width); The first parameter for al_create_display() is the width, the second is the height, you have them reverse, but then you have the wrong values in those variables.
So the width it is calculated on is 480, when you set it to 640 = 3/4.
That was it. Thanks, but it looks like there is a gap at the bottom of the screen. I guess I'll have to play with my calculations. ... Or is it the frame?
{"name":"611966","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/83857332562bad1aca20e67a993164d7.png","w":1366,"h":768,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/83857332562bad1aca20e67a993164d7"}
Just a quick look at your height values...
grid_height = 640-21 = 619
row_height = grid_height / 24 = 25.7916
And you draw your line 12 times I think for each grid
12 * 25.7916 = 309.4992
So the last line on the top is at 309.4992
Then you start at 309.4992 and move down that many more which leads to around 618.9984
640 - 618 = ~22 lines space at the bottom. Which looks about right from your screenshot.
Instead of starting at zero for the top grid, how about starting at 11 or so, this way your space at the top will match the bottom. Or don't subtract 21 on your grid height at the start.
Or don't subtract 21 on your grid height at the start.
That calculation was to allow for the line thickness when computing the cell sizes. I changed it and it looks better, but there is still a gap. I changed the line allowing for line thickness when calculating the cell width and the last one also comes up short. I guess I'll have to work with it. Thanks anyway.
Anytime.
It's experience anyhow. Good luck with it.