Jumpy performance
by Scott Jaworski · in Torque Game Builder · 09/18/2006 (8:48 am) · 7 replies
I made a thread earlier that got no replies, so I'll actually give an example of what i'm talking about here. You can download the latest version of my game here:
http://webpages.uncc.edu/~sajawors/vp002.zip
The controls just move the helicopter around the map. Up moves it forward, regardless of direction and left and right turn it in a different direction. Can anyone explain to me why after about a half second of movement the frame rate appears to stop, or the heli appears to "skip" forward and doesn't move smoothly. The graphics are all in factors of two (though the frames themselves aren't), ie. the heli is roughly 31 x 19 pixels, but the map it comes from is 64 x 128. I don't think it's the map tiles in the background causing the problem either, because the jumpiness was an issue in an earlier version without the map.
Here's my code:
Any help would be hugely appreciated, as I'm only getting started, and having poor performance now, only means bigger problems later.
http://webpages.uncc.edu/~sajawors/vp002.zip
The controls just move the helicopter around the map. Up moves it forward, regardless of direction and left and right turn it in a different direction. Can anyone explain to me why after about a half second of movement the frame rate appears to stop, or the heli appears to "skip" forward and doesn't move smoothly. The graphics are all in factors of two (though the frames themselves aren't), ie. the heli is roughly 31 x 19 pixels, but the map it comes from is 64 x 128. I don't think it's the map tiles in the background causing the problem either, because the jumpiness was an issue in an earlier version without the map.
Here's my code:
function PlayerHeli::onLevelLoaded(%this, %scenegraph)
{
$heliPlayer = %this;
$heliPlayer.setPosition(600, 400);
$flag = 0;
$heliPlayer.heliPlayerPulse(%this, %scenegraph);
moveMap.bindCmd(keyboard, "up", "heliPlayerForward();", "heliPlayerForwardStop();");
moveMap.bindCmd(keyboard, "left", "heliPlayerLeft();", "heliPlayerLeftStop();");
moveMap.bindCmd(keyboard, "right", "heliPlayerRight();", "heliPlayerRightStop();");
}
function PlayerHeli::heliPlayerPulse(%this, %scenegraph)
{
if ($heliPlayer.flag == 1)
{
$heliPlayer.setPositionY($heliPlayer.getPositionY()-2);
$heliPlayer.flag = 0;
echo("1");
}
else
{
$heliPlayer.setPositionY($heliPlayer.getPositionY()+2);
$heliPlayer.flag = 1;
echo("0");
}
%this.schedule(1000, "heliPlayerPulse");
}
function heliPlayerForward()
{
switch($heliPlayer.direction)
{
case 1: %x=0; %y=-75;
case 2: %x=100; %y=-50;
case 3: %x=150; %y=0;
case 4: %x=100; %y=50;
case 5: %x=0; %y=75;
case 6: %x=-100; %y=50;
case 7: %x=-150; %y=0;
case 8: %x=-100; %y=-50;
}
$heliPlayer.setLinearVelocityY(%y);
$heliPlayer.setLinearVelocityX(%x);
}
function heliPlayerForwardStop()
{
$heliPlayer.setLinearVelocityY(0);
$heliPlayer.setLinearVelocityX(0);
}
function heliPlayerLeft()
{
heliPlayerForwardStop();
$heliPlayer.direction--;
if ($heliPlayer.direction < 1) {$heliPlayer.direction=8;}
heliPlayerSetDirection();
}
function heliPlayerRight()
{
heliPlayerForwardStop();
$heliPlayer.direction++;
if ($heliPlayer.direction > 8) {$heliPlayer.direction=1;}
heliPlayerSetDirection();
}
function heliPlayerSetDirection()
{
switch($heliPlayer.direction)
{
case 1: $heliPlayer.playAnimation("redheliupAnim");
case 2: $heliPlayer.playAnimation("redheliuprtAnim");
case 3: $heliPlayer.playAnimation("redhelirtAnim");
case 4: $heliPlayer.playAnimation("redhelibtrtAnim");
case 5: $heliPlayer.playAnimation("redhelibtAnim");
case 6: $heliPlayer.playAnimation("redhelibtltAnim");
case 7: $heliPlayer.playAnimation("redheliltAnim");
case 8: $heliPlayer.playAnimation("redheliupltAnim");
}
}Any help would be hugely appreciated, as I'm only getting started, and having poor performance now, only means bigger problems later.
#2
For completeness' sake, it's happened on my old rig (AthlonXP 3200+, 1GB, Radeon 9800Pro 128) as well as my current compy (TabletPC, 1.5GB, Intel 915 GMA).
09/18/2006 (10:25 am)
I've actually seen this happen before. It' pretty intermittent, but when it does happen, it's very noticeable. I've seen it happen in the shooter demo that ships with TGB (this was present as well in the early adopter releases of T2D), though I don't know that it's exactly the same problem.For completeness' sake, it's happened on my old rig (AthlonXP 3200+, 1GB, Radeon 9800Pro 128) as well as my current compy (TabletPC, 1.5GB, Intel 915 GMA).
#3
09/18/2006 (10:34 am)
It's happened to me in the shooter demo too - and it was usually clear that another process on my computer had just started or something similar.
#4
09/18/2006 (10:38 am)
I don't know that I can comfortably chalk it up to another process starting up, unless TGB/T2D is overly sensitive to fluctuations in cpu cycles (i can start up a flash-heavy page loading in firefox or opera, for example, and this won't cause the jumps once the page is done loading).
#5
09/18/2006 (10:52 am)
Well, the other things that can screw up my performance drastically are short schedules that are running when they aren't necessary (get a lot of them and performance bombs), particle effects that are on infinite and don't get stopped and keep getting generated, and also (big one) echoing text every frame or very often.
#6
I didn't notice too much spamming in the console, not nearly as much as I do...
Heres my hardware:
//-------------------------- 9/18/2006 -- 14:24:59 -----
Processor Init:
Intel Pentium 4, ~3.20 Ghz
(timed at roughly 3.19 Ghz)
FPU detected
MMX detected
SSE detected
Math Init:
Installing Standard C extensions
Installing Assembly extensions
Installing FPU extensions
Installing MMX extensions
Installing SSE extensions
Input Init:
keyboard0 input device created.
mouse0 input device created.
DirectInput enabled.
Initializing chunk mappings...
o 'TEXT' maps to TextChunk
o 'SCHK' maps to UnknownChunk
o 'SCHK' maps to SimChunk
Loading compiled script common/main.cs.
--------- Parsing Arguments ---------
--------- Initializing Common ---------
Loading compiled script common/preferences/defaultPrefs.cs.
Reading Display Device information...
Primary Display Device Found:
Vendor Id: VEN_0000
Device Id: DEV_0000
Using OpenGL rendering. Fullscreen: 0
Compiling common/preferences/prefs.cs...
Loading compiled script common/preferences/prefs.cs.
Loading compiled script common/gameScripts/common.cs.
Loading compiled script common/gameScripts/audio.cs.
Loading compiled script common/gameScripts/canvas.cs.
Loading compiled script common/gameScripts/cursor.cs.
Binding server port to default IP
UDP initialized on port 0
Video Init:
Accelerated OpenGL display device detected.
Accelerated D3D device detected.
Voodoo 2 display device not detected.
Activating the OpenGL display device...
Activating the OpenGL display device...
Setting screen mode to 1024x768x32 (w)...
Creating a new window...
Acquiring a new device context...
Pixel format set:
32 color bits, 24 depth bits, 8 stencil bits
Creating a new rendering context...
Making the new rendering context current...
OpenGL driver information:
Vendor: ATI Technologies Inc.
Renderer: MOBILITY RADEON X600 x86/SSE2
Version: 1.5.4650 WinXP Release
OpenGL Init: Enabled Extensions
ARB_multitexture (Max Texture Units: 8)
EXT_blend_color
EXT_blend_minmax
EXT_compiled_vertex_array
EXT_texture_env_combine
EXT_packed_pixels
EXT_fog_coord
ARB_texture_compression
EXT_texture_compression_s3tc
(ARB|EXT)_texture_env_add
EXT_texture_filter_anisotropic (Max anisotropy: 16)
WGL_EXT_swap_control
OpenGL Init: Disabled Extensions
EXT_paletted_texture
NV_vertex_array_range
3DFX_texture_compression_FXT1
Max Texture Size reported as: 2048
OpenAL Driver Init:
Vendor: Creative Labs Inc.
Version: OpenAL 1.0
Renderer: Software
Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3
09/18/2006 (11:28 am)
Runs really smoothly for me. I didn't notice too much spamming in the console, not nearly as much as I do...
Heres my hardware:
//-------------------------- 9/18/2006 -- 14:24:59 -----
Processor Init:
Intel Pentium 4, ~3.20 Ghz
(timed at roughly 3.19 Ghz)
FPU detected
MMX detected
SSE detected
Math Init:
Installing Standard C extensions
Installing Assembly extensions
Installing FPU extensions
Installing MMX extensions
Installing SSE extensions
Input Init:
keyboard0 input device created.
mouse0 input device created.
DirectInput enabled.
Initializing chunk mappings...
o 'TEXT' maps to TextChunk
o 'SCHK' maps to UnknownChunk
o 'SCHK' maps to SimChunk
Loading compiled script common/main.cs.
--------- Parsing Arguments ---------
--------- Initializing Common ---------
Loading compiled script common/preferences/defaultPrefs.cs.
Reading Display Device information...
Primary Display Device Found:
Vendor Id: VEN_0000
Device Id: DEV_0000
Using OpenGL rendering. Fullscreen: 0
Compiling common/preferences/prefs.cs...
Loading compiled script common/preferences/prefs.cs.
Loading compiled script common/gameScripts/common.cs.
Loading compiled script common/gameScripts/audio.cs.
Loading compiled script common/gameScripts/canvas.cs.
Loading compiled script common/gameScripts/cursor.cs.
Binding server port to default IP
UDP initialized on port 0
Video Init:
Accelerated OpenGL display device detected.
Accelerated D3D device detected.
Voodoo 2 display device not detected.
Activating the OpenGL display device...
Activating the OpenGL display device...
Setting screen mode to 1024x768x32 (w)...
Creating a new window...
Acquiring a new device context...
Pixel format set:
32 color bits, 24 depth bits, 8 stencil bits
Creating a new rendering context...
Making the new rendering context current...
OpenGL driver information:
Vendor: ATI Technologies Inc.
Renderer: MOBILITY RADEON X600 x86/SSE2
Version: 1.5.4650 WinXP Release
OpenGL Init: Enabled Extensions
ARB_multitexture (Max Texture Units: 8)
EXT_blend_color
EXT_blend_minmax
EXT_compiled_vertex_array
EXT_texture_env_combine
EXT_packed_pixels
EXT_fog_coord
ARB_texture_compression
EXT_texture_compression_s3tc
(ARB|EXT)_texture_env_add
EXT_texture_filter_anisotropic (Max anisotropy: 16)
WGL_EXT_swap_control
OpenGL Init: Disabled Extensions
EXT_paletted_texture
NV_vertex_array_range
3DFX_texture_compression_FXT1
Max Texture Size reported as: 2048
OpenAL Driver Init:
Vendor: Creative Labs Inc.
Version: OpenAL 1.0
Renderer: Software
Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3
#7
Thanks again, I'll post again with my findings.
09/18/2006 (3:33 pm)
Thanks for all the responses; I'll try padding out the cells to 32x32 (really didn't want to have to do that for all the frames :( ) and also try the current demo on a variety of machines and see what I get.Thanks again, I'll post again with my findings.
Torque Owner Philip Mansfield
Default Studio Name
I flew around the map from side to side and across the diaganols, and didn't really notice any problems. Is it possible that there's other stuff running the background on your PC that could cause the jumping?