Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Moving with time instead of cpu bound movement.  (Read 1719 times)
0 Members and 1 Guest are viewing this topic.
Offline stef569

Junior Devvie

« Posted 2007-10-06 17:50:34 »


I'm wondering how do you use time when you want to move for example a tetris one place down?
I currently use this:

        for(int i=0;i<MOVE_DELAY;i++) {

I've seen on this site
this game loop

    float t = 0.0f;

    float currentTime = time();

    while (!quit)
         float newTime = time();
         float dt = newTime - currentTime;
         currentTime = newTime;

         integrate(state, t, dt);
         t += dt;


and I don't understand this line: render(state);
how would you use that state?
Offline rbscholtus

Junior Newbie

« Reply #1 - Posted 2007-11-04 10:58:28 »

If you are new to animation and you want to develop a good main game loop, I highly recommend reading (online) chapter 2 of:

Or just buy the book, as I did. At the end of the chapter you will have a clear idea of how a good ani loop should work. Then it should also be much easier to understand the code you copied from  Cheesy

Key to your Tetris animation will be to choose a fixed timeslot and do an update() once each timeslot, and then render. If rendering falls behind, you compensate by doing more update(), until the updates are in synch with the time.
Offline tbulford

Senior Newbie

Medals: 1

« Reply #2 - Posted 2007-11-15 05:47:18 »

For frame timing management there are a few approaches. You could look at a short tutorial on the site.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline broumbroum

Junior Devvie

« Reply #3 - Posted 2007-11-15 17:24:55 »

hi! I've been working with Timing Frameworking for past 2 years now and here's one of the conferences I watched for a while. It's french spoken but an english powerpoint presentation. You can find more at Thanks to Romain Guy who also helped me a lot !
I've really enjoyed this conference, though I've been participating through the web only. What an amazing guy !

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @
on /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Pages: [1]
  ignore  |  Print  

EgonOlsen (79 views)
2018-06-10 19:43:48

EgonOlsen (59 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (261 views)
2018-05-13 18:23:11

nelsongames (159 views)
2018-04-24 18:15:36

nelsongames (158 views)
2018-04-24 18:14:32

ivj94 (901 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (813 views)
2018-03-24 14:43:53

Solater (177 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!