Grid libraries?

Im more or less a beginner to C++, iv been learning it since August last year, and pretty much fully understand procedural programming.

I wasnt to learn object oriented programming, but thats not my question xD

My question is, are there any libraries or headers which contain functions which can divide a window int a grid?

I have recently been looking at the C++ game of life, and wonder how they got individual pixels?

Also, would anyone recommend more efficient alternatives to SDL?
I know how to use SDL, as that is what i have been learning for the last 4 months. but i am wondering if there is anything more efficient and has more features?
I don't have a comparison from SDL, I've never used it, but I've been using Allegro for about a month and from what I have done, it seems fairly easy to use and most of the operators seem self explanatory. I was using a tutorial for a game which was in video from, and my internet sucks so I couldn't watch the videos, but he had the code available for download and from those I understood everything that was going on without being told what statement or operator does what. I'm also pretty new to C++, I've been learning for about 6 - 7 months. Hope this helps.
Dividing a window into a grid is not too complicated. You know the width and height right?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int screenX = 800;
int screenY = 640;

int gridWidth  = 8;
int gridHeight = 8;

int mouseClickX = 79;
int mouseClickY = 440;

int gridClickX = mouseClickX * gridWidth / screenX;  // multiply first
int gridClickY = mouseClickY * gridWidth / screenY;  // multiply first

int myArray[/* which is hopefully 64 here */];

int gridIdx = gridClickY * gridWidth + gridClickX;

if (myArray[gridIdx].isHungry()) myArray[gridIdx].feed();


Topic archived. No new replies allowed.