title: scala game programming: advancing object position in a functional style
body: <p>Long time java programmer slowly learning scala (loving it by the way), and I think my mind is still wrapping itself around the concept of writing things functionally.  Right now I'm attempting to write a simple visualizer for some moving 2d textures.  The imperative approach is simple enough, and I'm sure most of you will recognize this relatively ubiquitous block of code (stuff was changed to protect the innocent):</p>
  
  <pre><code>class MovingTexture(var position, var velocity) extends Renders with Advances {
      def render : Unit = {...}
      def advance(milliseconds : Float) : Unit = {
          position = position + velocity * milliseconds
      }
  }
  </code></pre>
  
  <p>This code will work just fine, however it has tons of mutable state and its functions are replete with side effects.  I can't let myself get away with this, there <em>must</em> be a better way!  </p>
  
  <p>Does anyone have an amazing, elegant, functional solution to this simple problem?  Does anyone know of a source where I could learn more about solving these sorts of problems?</p>