Step 2: Update Enemy X position

By nature, zombies walk very slowly. Based on the size of our objects, a speed somewhere between 0.75 and 1.25 pixels per frame seems appropriate. The problem is, all object co-ordinates are stored in integer form and all integers are whole numbers only.

For an object to move in decimal increments and be positioned at decimal co-ordinates, we must store it's postion indirectly in an alterable value. This is because alterable values can store floating point values (non-whole numbers).

All we need to do is constantly update the actual X position with the floating point X position.
Run the application and you will see that each Enemy is now re-positioned at the mouse co-ordinates. For a more detailed explaination, please read the Floating Point Movement article.

5