In an event driven API, such as Java or C/C++/Win32, call an Update() function that repeats steps 1, 2, and 5, if neccessary. Input, drawing and animation can take place in the corresponding event methods.