Hello i am making this 2d game with c++ SDL and opengl. I am using glQuads to render 2d quadrilaterals to the screen. There are numeruos squares of different sizes that my character jumps on to get across. The glQuads function requires coordinates.
1 2 3 4 5 6 7
|
glBegin(GL_QUADS);
glVertex2f(x,y);
glVertex2f(x+width, y);
glVertex2f(x+width,y+height);
glVertex2f(x, y+height);
glEnd(); //End drawing
|
Each line is the coordinates for each corner in the square. I have a map class with a draw() function in it that just draws the x, y, width height, and when i call it i can pass values for them, so as i call the map.draw() i re-size and position my square.
I call this function in my main.cpp where a main game loop is happening. How could i simply write the coordinates in a text document, and a ifstream objects loop through each number assigns it to x, y , width height and draws it? So every 4 numbers in the text document would be a new square. eg:
100 200 10 10
could be in my txt. I have tried many different ways for hours.
Thankyou very much, any help would be appreciated.
Thankyou gain in advance :)