Here's an example of how I structure my programs: Set initial conditions -- draw the screen, set variables, etc. Do this forever: Check inputs -- buttons, touchscreen, whatever I'm using Change data based on inputs Calculate new positions for onscreen objects based on data -- how far does everything move in 1/60th of a second? Move onscreen objects to their new positions Repeat.