• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

gameLoop()... why do we need to know last loop time?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so im checking out the SpaceInvaders tutorial found here:

http://www.cokeandcode.com/node/6

im trying to wrap my head around why you need to know the last loop time to calculate movement? i would think that you would just need to look at the current position and increment that x-axis and/or y-axis by .01, 1, 30 or whatever needed for each loop.

below are a few snippets of the code listed in the above link:





 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the loops may not be constant in time, depending on what else the machine is doing, but you still want your sprites to look like they are moving at a constant rate.

so if i update the screen more often (i.e. shorter loop times), i want them to move less. 5 frames per second need to move further between each re-paint than 20 frames per second.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic