It’s the same for 2d just translate and draw
it won’t work as you want.Correct way should be
loop
{
glPushMatrix()
translate
draw
glPopMatrix()
}
if you don’t use push- and popmatrix you will be translating more and more to the right(if using glTranslatef(-1.0f,0.0f,0.0f) your 500object will be draw at coordinates -500,0,0
Movement works the same in 2D as 3D.
This is a wrong aproach, since you can only move one object at a time. Also you need to redraw the screen each time there is a movement.
Better way is to create a loop routine to control the movement:
Originally posted by Sklar:
[b]To move an object across the screen, can I simply do some kind of for loop, like so:
for(int number = 1; number < 500; number++)
{
translate the object to the right
draw the object
}
I assume this won’t work, as I haven’t made it work yet. Could someone please clue me in to how to move an object in 2D.