Moving pixels?

Started by
2 comments, last by dustydoodoo 19 years, 6 months ago
Well first i started with flash and all u had to do to move and object is "char._x +=1", and it would move the object right. But in c++ win32, u have to redraw the object and erase the pixels behind him that used to be the old him, right?
Sure i will write my signature, just gimme a piece of paper
Advertisement
Yes, that's pretty much the idea. One way to handle object movement is to draw or redraw sections of the screen that change only.

In this case, sometimes just erasing the pixels where the object used to be is not enough. There may be a background image, or other objects, which should be visible once the object in front moves. Erasing these pixels would not give the proper effect in this case.

Another approach (also the most widely used for games) is to create a game loop, in which the entire scene is processed (handling events, moving objects, taking input, game logic) and everything is redrawn. In this case, you could increase an object's x or y position and the entire scene would be redrawn based on the new coordinates. In this approach, you won't have to worry about erasing pixels where something else should be in the background.

If you're interested in reading about game loops, I'm sure there's some interesting stuff in the articles section here.

Hope that helped a little.
Great! thanks
Sure i will write my signature, just gimme a piece of paper
I made a really simple game, all u do is move a pixel around the screen but its a start!
Sure i will write my signature, just gimme a piece of paper

This topic is closed to new replies.

Advertisement