There is a fairly standard pattern for building 2D games. You decide on a virtual resolution, move things by multiplying by elapsed time in the main loop, iterate through entities in an array, handle ...