Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 1059 times)
0 Members and 1 Guest are viewing this topic.
Offline stef569

Junior Member





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

Hi,

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

1  
2  
3  
        for(int i=0;i<MOVE_DELAY;i++) {
        piece.move(piece.down);
}


I've seen on this site
this game loop

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
    float t = 0.0f;

    float currentTime = time();

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

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

         render(state);
    }

from http://www.gaffer.org/game-physics/fix-your-timestep/
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:
http://fivedots.coe.psu.ac.th/~ad/jg/

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 gaffer.com.  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 javag.org site. http://javag.org/?q=node/1

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

Junior Member





« 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 swinglabs.org. Thanks to Romain Guy who also helped me a lot !
http://java.developpez.tv/javadesktop-dec2005/#Part20
I've really enjoyed this conference, though I've been participating through the web only. What an amazing guy !
Cheesy

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (4 views)
2014-09-21 00:34:41

moogie (4 views)
2014-09-21 00:26:15

UprightPath (22 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (96 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29

BurntPizza (52 views)
2014-09-07 01:13:42
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!