by date
Can't be the only one with this problem...?
Can't be the only one with this problem...?
| Name: | Mads Laumann | ![]() |
|---|---|---|
| Date Posted: | Jan 24, 2007 | |
| Rating: | Not Rated | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Mads Laumann |
Blog post
It's been a while since my last post, but it has been christmas and I have been on vecation to the Domanican Republic for 14 days :)
I have had this problem for some time now, but haven't been able to fix it my self. I have created and posted in different threads, but I still haven't been able to fix the problem... :(
Threads:
- www.garagegames.com/mg/forums/result.thread.php?qt=54975
- garagegames.com/mg/forums/result.thread.php?qt=52682
(I have posted in this thread)
To make a long story short, the problem is that my game runs at different speed, depending on the CPU of the users PC. I have been looking at the TankBuster source code, to get inspired to how to design the game, codewise. Can't find the link to the source code anymore, so i can't give it to you :(
But my current code/scripts is in the first forum link. It's the private forum.
To sum it all up
What I have found out so far is that the my problem started because I was updating all my entities in the 'onUpdateScene' function. Like they do on the TankBuster game.
I was then told that I shouldn't update my game here, because this function is called as many times at the users computer can handle. Ok, that was my guess too. Next problem, where do I update my game then? Because I really wanna do it this way by have some kind of "GameLoop", because I am use to do it like this when I make games in C#.
In C# i typically have a "StopWatch" and all my updating logic in a 'if'. If X miliseconds haven't passed since the last time it just skips the if, and then don't update the game.
But to get back to Torque. I couldn't update it on the 'onUpdateScene', so I was told to try doing it with a timer. I thought that sounded like a great idea. I should beable to called a %this.setTimerOn(25); method and a OnTick(%this) (or a name simular to this ;) ) function/event should be fired.
When I tryed this out, I found out the you can't set a timer on a t2dSceneObject.
So what to do now? Im stock here, and need some adwise, hope someone can help me out here. I can't be the only one who wants my game to run at the same speed at different PC's :P
PS: I haven't been working on this game lately, because I been working on a little C# project i wanna use at my work :) blog.laumania.net - Project Timer it is called.
I have had this problem for some time now, but haven't been able to fix it my self. I have created and posted in different threads, but I still haven't been able to fix the problem... :(
Threads:
- www.garagegames.com/mg/forums/result.thread.php?qt=54975
- garagegames.com/mg/forums/result.thread.php?qt=52682
(I have posted in this thread)
To make a long story short, the problem is that my game runs at different speed, depending on the CPU of the users PC. I have been looking at the TankBuster source code, to get inspired to how to design the game, codewise. Can't find the link to the source code anymore, so i can't give it to you :(
But my current code/scripts is in the first forum link. It's the private forum.
To sum it all up
What I have found out so far is that the my problem started because I was updating all my entities in the 'onUpdateScene' function. Like they do on the TankBuster game.
Code removed
I was then told that I shouldn't update my game here, because this function is called as many times at the users computer can handle. Ok, that was my guess too. Next problem, where do I update my game then? Because I really wanna do it this way by have some kind of "GameLoop", because I am use to do it like this when I make games in C#.
In C# i typically have a "StopWatch" and all my updating logic in a 'if'. If X miliseconds haven't passed since the last time it just skips the if, and then don't update the game.
But to get back to Torque. I couldn't update it on the 'onUpdateScene', so I was told to try doing it with a timer. I thought that sounded like a great idea. I should beable to called a %this.setTimerOn(25); method and a OnTick(%this) (or a name simular to this ;) ) function/event should be fired.
When I tryed this out, I found out the you can't set a timer on a t2dSceneObject.
So what to do now? Im stock here, and need some adwise, hope someone can help me out here. I can't be the only one who wants my game to run at the same speed at different PC's :P
PS: I haven't been working on this game lately, because I been working on a little C# project i wanna use at my work :) blog.laumania.net - Project Timer it is called.
Recent Blog Posts
| List: | 07/29/07 - AstroMania (alpha) 02/20/07 - Web Monitor 02/10/07 - Ninja Nick - Part 1 02/02/07 - MCTS, Torque and C++ 01/24/07 - Can't be the only one with this problem...? 12/10/06 - Parachute - Part 1 12/03/06 - Putting the MMORPG on hold for a while... 11/20/06 - Tutorial hunting |
|---|
Submit your own resources!| Phil Carlisle (Jan 24, 2007 at 21:34 GMT) |
What I'd recommend, is calling that and storing the value, then every update loop, you check if new time > last time + time step.. (timestep being a value you choose to lock your update rate at), if > then you update all game objects, otherwise you simply return, next time through the loop you check UNTIL you get a value > and it then calls the update.
If your game is running too slow, what you can do is see how much time has elapsed and if > update frequency, you simply update and loop until it isnt.. Basically setting a fixed time step.
One alternative, there are others (like multiplying positions and velocities * time elapsed).
| Mads Laumann (Jan 24, 2007 at 21:44 GMT) |
| Chris Labombard (Jan 25, 2007 at 18:17 GMT) |
EDIT: Also should you be posting TGB code into a public blog post? I think that's against the EULA
Edited on Jan 25, 2007 18:18 GMT
| David Higgins (Jan 25, 2007 at 18:51 GMT) |
You can perform your time logic with that in your onUpdateScene method, or you can schedule an event with a timer using the below block;
new t2dSceneObject(myObject)
{
field1 = 0;
}
myObject.setTimerOn(300);
function myObject::onTimer(%this)
{
%this.field1 = %this.field1 + 1;
echo("myObject.field1 = " @ %this.field1);
}

| Mads Laumann (Jan 25, 2007 at 21:34 GMT) |
About the code, didn't thought of that one. I have removed the link for the .zip file with code, so the code is only download able from the private forum. But isn't the EULA only about that you cant show off the source code of the engine?
@David
Thanks, using the code in the code block would force me to set timers for all my object individually... I don't like that :)
But the GetSimTim() looks great, Ill try that out.
| Chris Labombard (Jan 25, 2007 at 21:45 GMT) |
David's method works, but it wont properly sequence events between multiple objects.
| Mads Laumann (Jan 26, 2007 at 12:16 GMT) |
I tryed out the getSimTime() yesterday and it actually seemed to work as it should :) Ofcause it gave me some other problems, but yeah, that's coding! :)
Thanks guys!
You must be a member and be logged in to either append comments or rate this resource.



Not Rated


