RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic Goto page 1, 2  Next 
View previous topic - View next topic  
Author Message
DeveloperX
202192397


Joined: 04 May 2003
Posts: 1626
Location: Decatur, IL, USA

PostPosted: Thu Oct 28, 2004 1:20 am    Post subject: Dream Destroyer [quote]

If any of you downloaded my 'compo' build, then by all means, check this one out. :)

http://ccps.rpgdx.net/projects/7/DreamDestroyer_incomplete_post_compo_build.zip

Still more to be done, but we're getting there.. slowly, but surely. :)
_________________
Principal Software Architect
Rambling Indie Games, LLC

See my professional portfolio
Back to top  
js71
Wandering DJ


Joined: 22 Nov 2002
Posts: 815

PostPosted: Thu Oct 28, 2004 3:32 am    Post subject: [quote]

Unplayably fast... Just like the first build. :\
(I've always found walking in place to be a bit annoying too)
Nice graphics though... The minimap is nice.
Back to top  
DeveloperX
202192397


Joined: 04 May 2003
Posts: 1626
Location: Decatur, IL, USA

PostPosted: Thu Oct 28, 2004 3:51 am    Post subject: [quote]

Josiah Tobin wrote:
Unplayably fast... Just like the first build. :\
(I've always found walking in place to be a bit annoying too)
Nice graphics though... The minimap is nice.


I've been trying to figure out how to get the timing fixed.
And the animation isn't fixed yet.

Once I get those 2 things solved, I can start working on fully integrating the virtual machine..
_________________
Principal Software Architect
Rambling Indie Games, LLC

See my professional portfolio
Back to top  
Adam
Mage


Joined: 30 Dec 2002
Posts: 416
Location: Australia

PostPosted: Thu Oct 28, 2004 4:15 am    Post subject: [quote]

Shoudn't this thread be in projects/screenshots?

DeveloperX wrote:
I've been trying to figure out how to get the timing fixed.


http://www.glost.eclipse.co.uk/gfoot/vivace/vivace.html#Examples%20of%20timers

Scroll down to "9.4.3 Regulating game speed"
_________________
https://numbatlogic.com
Back to top  
DeveloperX
202192397


Joined: 04 May 2003
Posts: 1626
Location: Decatur, IL, USA

PostPosted: Thu Oct 28, 2004 5:45 am    Post subject: [quote]

adam wrote:
Shoudn't this thread be in projects/screenshots?

Does it really matter?

Quote:

http://www.glost.eclipse.co.uk/gfoot/vivace/vivace.html#Examples%20of%20timers

Scroll down to "9.4.3 Regulating game speed"


Went there...read it all....still don't get it.

problems I'm having:

- player either changes frames really fast like he's having a seizure, or doesn't change at all.
- game isn't going to run the same speed on other PCs.

I asked Ninkazu for help, and he told me about the install_int() stuff...and it doesn't work. I don't know what I'm doing, and if anyone wouldn't mind taking some time to show me step by step, I would really appreciate it.
I've been reading different sources for 4 days, I simply cannot figure this out.
_________________
Principal Software Architect
Rambling Indie Games, LLC

See my professional portfolio
Back to top  
Adam
Mage


Joined: 30 Dec 2002
Posts: 416
Location: Australia

PostPosted: Thu Oct 28, 2004 6:25 am    Post subject: [quote]

DeveloperX wrote:
Does it really matter?

Yes.

DeveloperX wrote:

- player either changes frames really fast like he's having a seizure, or doesn't change at all.
- game isn't going to run the same speed on other PCs.

Hmmm, very strange. Let me think... You know, the link i gave you solves both these problems.

Let's go a little crazy and try this. Look at the example given examples/chap_09/ex_4_3. http://www.glost.eclipse.co.uk/gfoot/vivace/vivexam.zip.

You need to use the magic of copy and paste to throw this in right up the top of your program.
Code:
int actual_cycle;
volatile int target_cycle;
volatile int last_fps;
volatile int frame_counter;
void target_incrementor()
{
    target_cycle++;
}
END_OF_FUNCTION(target_incrementor);

void count_frames()
{
    last_fps = frame_counter;
    frame_counter = 0;
}
END_OF_FUNCTION(count_frames);


Now, we need tis in our intalization:
Code:
install_timer();
    LOCK_VARIABLE(target_cycle);
    LOCK_FUNCTION(target_incrementor);
    install_int_ex(target_incrementor, BPS_TO_TIMER(30));
    LOCK_VARIABLE(last_fps);
    LOCK_VARIABLE(frame_counter);
    LOCK_FUNCTION(count_frames);
    install_int_ex(count_frames, BPS_TO_TIMER(1));
    actual_cycle = target_cycle = 0;


the BPS_TO_TIMER(30) bitty gives you 30 cycles a second.

now your main loop of your game needs to be alterd to look something like this:
Code:

   // however you chose to loop would be above this line
   // do input crap here
   draw_one_frame();                       /* First do some graphics,  */
   while (target_cycle > actual_cycle)     /* then until up-to-date... */
       do_one_game_cycle();                /* ... do game cycles.      */
   // close main loop below this line


now, in your draw_one_frame() or whatever you called it, you only do the drawing onto screen. Don't do logic. Right at the end of this function put in frame_counter++;

in do_one_game_cycle() or whatnot, you don't do any screen drawing. Put actual_cycle++; at the end of this function.

You'll probably need to make those integer declerations at the top globals if your code is in more than one file.

I think my name should be listed in the credits for your game.
_________________
https://numbatlogic.com
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Thu Oct 28, 2004 4:46 pm    Post subject: [quote]

adam wrote:
DeveloperX wrote:
Does it really matter?

Yes.

Indeed it does, I moved it now. :-)
Back to top  
Joakim
Tenshi's Bitch (Peach says "Suck it!")


Joined: 05 Apr 2004
Posts: 64

PostPosted: Thu Oct 28, 2004 6:27 pm    Post subject: [quote]

The speed of a game should not depend on the framerate. Here is the solution to a timing system that will update your game logic a constant number of times per second, but draw to the screen as often as possible.

Code:
  // Update objects a specified number of times (50 times per second)
  updates = (get_microseconds() - lasttime) / 20;
  if( updates > 0 )
  {
    for (i=0; i<updates; i++)
    {
      // Update your game logic here (move stuff etc.)
    }
    lasttime += updates * 20;
  }
  // Draw stuff to the screen here

get_microseconds() is a psudo function, which should of course be a timer that returns the number of elapsed microseconds (since the computer or the engine started, or some other point in time).

It updates 50 times per second because the constant used is 20. That is, 1 sec / 20 = 1000 microseconds / 20 = 50 times per second. If you change this, be sure to change the constant 20 in both places.
lasttime, i and updates should be integers of course.

Be sure to reset lasttime before entering your game loop like this:
lasttime = get_microseconds();
Back to top  
white_door
Icemonkey


Joined: 30 May 2002
Posts: 243
Location: New Zealand

PostPosted: Thu Oct 28, 2004 7:34 pm    Post subject: [quote]

Quote:
but draw to the screen as often as possible.


what is the point of redrawing the screen at times when nothing has changed?
Back to top  
Joakim
Tenshi's Bitch (Peach says "Suck it!")


Joined: 05 Apr 2004
Posts: 64

PostPosted: Thu Oct 28, 2004 7:50 pm    Post subject: [quote]

It's a lot of fun!
No actually, you're quite right about that lol.
Here's the modified version:
Code:
  // Update objects a specified number of times (50 times per second)
  updates = (get_microseconds() - lasttime) / 20;
  if( updates > 0 )
  {
    for (i=0; i<updates; i++)
    {
      // Update your game logic here (move stuff etc.)
    }
    lasttime += updates * 20;
    // Draw stuff to the screen here instead
  }
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Thu Oct 28, 2004 7:51 pm    Post subject: [quote]

I explained Allegro's timer functions to DeveloperX tonight, at least how to limit the maximum speed of the game. If the PC can't keep up, it would still need to skip frames and I'll explain that later. I'm trying not to give too much sample code, he should be able to write it himself.
Back to top  
Joakim
Tenshi's Bitch (Peach says "Suck it!")


Joined: 05 Apr 2004
Posts: 64

PostPosted: Thu Oct 28, 2004 7:55 pm    Post subject: [quote]

Well this is really simple and easy to understand, and it's library independant, so it might prove more useful in the long run. Either way, I'm glad white_door pointed out my waste of CPU time redrawing the same scene. Thanks buddy! :)
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Thu Oct 28, 2004 8:34 pm    Post subject: [quote]

Joakim wrote:
Well this is really simple and easy to understand, and it's library independant, so it might prove more useful in the long run. Either way, I'm glad white_door pointed out my waste of CPU time redrawing the same scene. Thanks buddy! :)

I agree your way is really simple too, both methods are rather simple, but if you've never done either before, either can be daunting to understand. :)

Btw, there's no reduction in CPU time waste if you just keep looping in the while instead of redrawing the screen. The only advantage not redrawing the screen has, is that you'll jump in the next logic update as soon as possible, instead of lagging behind a bit because you were busy redrawing the previous screen. Not sure if this would be noticable though.
Back to top  
white_door
Icemonkey


Joined: 30 May 2002
Posts: 243
Location: New Zealand

PostPosted: Thu Oct 28, 2004 9:26 pm    Post subject: [quote]

If you actually care enough to reduce cpu usage, when not redrawing you'll have to yield your timeslice to the OS. I don't see it as a major issue though, since people expect games to eat up all the cpu time.
Back to top  
Joakim
Tenshi's Bitch (Peach says "Suck it!")


Joined: 05 Apr 2004
Posts: 64

PostPosted: Fri Oct 29, 2004 4:23 pm    Post subject: [quote]

The truth is, I don't care if I take up the entire processing time hehe. But the problem you pointed out is the issue here, as a 3D game might use quite a lot of ms to render to the screen, which might be noticable if programmed like my first example.

I guess...
Back to top  
Post new topic Reply to topic Page 1 of 2 All times are GMT
Goto page 1, 2  Next 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum