• Advertisement
Sign in to follow this  

Moving pixels?

This topic is 4875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement