Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

zilch_

Real Game Programmers

This topic is 5789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been programming games for halft a year or so now, and programming for all of my life. But thats not important here. The important thing is that when I start code a game, I always think "this game has to behave EXACTLY the same even if I run it on the slowest possible computer". This gives me enourmous problems that I don''t like, like Collision Response. If the computer is slow as hell, will the outcome be EXACTLY the same if something collides? Then I have to trace the collision to it''s EXACT (pixelwise) point in time. This is a lot of work. Extremely more than just getting the pixelperfecet collision detection to work, which is quite easy. Another problem is the Acceleration/friction one. But this is certainly a skill issue. Ofcourse we are talking about a gameengine that measures milliseconds since last frame, and updates all objects using this value. Now the question is, If I run a state of the art game on an extremely slow computer - will the outcome be EXACTLY the same? How the *insert french word* do they do that with the collision detection, fysics, and everything else for that matter. I actually whish I coded for a gaming console when I get stuck in questions like this. That would actually solve the issue all by itself. Thanks for the help to a gameprogramming newbie. zilch_

Share this post


Link to post
Share on other sites
Advertisement
They don''t run state of the art games on slow PCs... hence system requirements.

But you''ll have to use timers in order to get the same response times from PCs of different speeds.

Share this post


Link to post
Share on other sites
I''m by no means a professional, but i believe you need to pick a target system and code for that, or for something slightly slower, but don''t get crazy thinking your game needs to run on an ibm p/s2. Code for your target audience.

- Free Your Mind -

Share this post


Link to post
Share on other sites
Zyroth,
I''m totally aware of that.

The question was not about how to do that. I wrote...

"Ofcourse we are talking about a gameengine that measures milliseconds since last frame, and updates all objects using this value."

... which meant that I did this. And I assume all other state of the art engines do that too.

The question was whether they actually behave EXACTLY the same if they are running on a 800 mhz computer, or a 1800 mhz computer. If a spaceshit collides with an AI spaceship in decent2 (or something), would the outcome be EXACTLY the same on an 800 mhz computer (assuming it''s hosting the AI too ) that it would on an 1800 mhz computer? I mean that the resulting x,y coordinate after the ship has stopped whould be EXACTLY the same. That means it actually trances back to the exact point of location.

When I think about it, this whould actually be a lot simplier in 3d than in 2d, as you have the triangles colliding, and their corresponding coordinates. But in a 2d game, all you have is pixels representing the ship.

thanks!

zilch_

Share this post


Link to post
Share on other sites
No, I don''t beleive the results would be EXACTLY the same, due to the simple fact that your timer isn''t infinitely accurate (you can only time to within milliseconds, or whatevers, right?). Also, calculations on variables used in deciding things such as collision response etc. aren''t infinitely accurate, you only have a certain number of decimal places. These tiny differences can add up. From a players point of view, someone playing at 10 FPS can never hope to reproduce the same gameplay as someone playing at 100 FPS, because the frequency at with their inputs are read are different (the fast computer has more accurate inputs, producing different outputs). However, with good design and good physics, you can make sure they are VERY NEARLY the same results on most systems. The physics involved can be very complicated, a bit beyond me at the moment, as I discoved the handling in my car physics demo was wildly different on different computers I got the acceleration and braking speeds correct on slow and fast computers, but I still haven''t sorted the steering.

Share this post


Link to post
Share on other sites
Interesting,
I know what you are going through mate

Not in my wildest dreams I would think that the steering whould be harder to fix than the physics though.

And ofcourse,
the input sampling would differ,
but assuming the game is input-less, and the object start with an initial velocity and direction.

Assuming a difference in 10 fps and 100 fps, it would still be possible to make it 100% accurate. It would be in a gameloop (this is just to show you what i mean) that does all movement, physics and other things in a loop incrementing by 1 millisecond each iteration. Ofcourse no game does this. But this would still make it EXACTLY the same even on ALL computers.

This would catch all collisions at the same spot too.

zilch_

Share this post


Link to post
Share on other sites
zilch_ , I''m not sure I quite understand how to get 100% accuracy.

Take this example, a car crashes into a wall. However, because the game runs in frames, on a fast computer the collision is detected when the car is 0.01 metres through the wall, but on the slow computer, because the time steps between frames are larger, the collision is detected when the car is 0.1 metres through the wall. Now, we could use some funky maths in order to work back and solve the exact moment the car just touched the wall, but because our equation will have different inputs on different computers, inputs which have been ROUNDED, the outcomes surely would be slightly different.

In the example of acceleration verses steering, maybe it isn''t any harder, it''s just harder for me because I understand certain areas of physics better than others. What I do know is that every variable must be in terms of time, such as metres per second for the cars speed. I still haven''t got all the variables for calculating skids in a "per second" format, that''s my problem.

Share this post


Link to post
Share on other sites
Aha, it just clicked into my head what you were meaning. Yes, that would produce exactly the same results on each computer, but the action would unfold at different speeds! Like what sometimes happens when you play old DOS or QBASIC games on your fast computer nowadays. This might look bad, and even if you ignored that, you couldn''t use this for multiplayer games, or games where your score was based on time, or games which required a fast reaction in order to win. However, it may be very good for physics simulations in real world applications, where accuracy is more important.

Share this post


Link to post
Share on other sites
OK!
I have to explain what I mean, as what you describe is the (my, and probably many others) initial problem.

What you say, about the car crashing, assumes, basically, that the collision detection is run once for each frame, therefore not actually exactly at the same point in time (Realtive to the start of the application).

However, what I say, is that if your gameloop does everything that is inside a basic gameengine (movement, psysics AND collision detection) once for each millisecond; the outcome would be the same.

Ofcourse, there will still be different amount of milliseconds passed since last fram on different computers, but if the gameloop is changed in this way, the outcome is always the same.

This is however not practical in reality. But it is possible.

What I mean in more detail, is instead of having:

gameloop {
ms = millisecondsSinceLastFrame();
updateAllObjects(ms);
CheckAndHandleCollision();
// Whatever you want
render();
}

you have:

gameloop {
ms = millisecondsSinceLastFrame();
for ( each millisecond ) {
updateAllObjects(1); // one millisecond
CheckAndHandleCollision();
// Whatever you want
}
render();
}

That WOULD solve the problem. In an INappropriate manner however.

zilch_



[edited by - zilch_ on September 9, 2002 9:37:28 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!