Sign in to follow this  

Moving pixels?

Recommended Posts

dustydoodoo    100
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
pi_equals_3    517
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this