100s of objects on screen halves FPS
by Jonathan Mendenhall · in Torque Game Builder · 12/16/2009 (8:05 pm) · 6 replies
I have started into trying to create my first game. In this 2D game the creation of about 200 objects (along with 200 text fields) is possible. In the base state on my development computer the game runs at about 200 FPS. After the 200 objects are created it plummets down to 95 FPS, which is still not bad at all. The problem is that I am developing this game to be run on a much weaker computer, with a joke of a video card. In the base state it runs at 15 FPS (which might be acceptable), but it then drops down to 8 FPS.
So, my main concern at this point in time is: How can I create these 200 objects without a 50% drop in FPS? They do not need to have any physics information, they all use the same single image map, and the position for each of the 200 chips is unique, but fixed. In other words, all these objects need to do is sit there and look pretty, eventually they may need to move in one direction off the screen, but they will never need to collide with anything. Is there a better way to do this?
Here is how I am creating them right now in script:
new t2dStaticSprite(betChip @ %betId)
{
scenegraph = $sceneGraph;
imageMap = "ImageMapGrey_Chip";
frame = "0";
canSaveDynamicFields = "1";
position = %position;
size = "49 48";
Layer = "10";
GraphGroup = "21";
BuiltInShaderType = "NONE";
WorldLimitMode = "KILL";
WorldLimitMax = "1366 768";
AutoMassInertia = "0";
CollisionPhysicsSend = "0";
CollisionPhysicsReceive = "0";
CollisionCircleSuperscribed = "0";
};
Thanks in advance for any help.
So, my main concern at this point in time is: How can I create these 200 objects without a 50% drop in FPS? They do not need to have any physics information, they all use the same single image map, and the position for each of the 200 chips is unique, but fixed. In other words, all these objects need to do is sit there and look pretty, eventually they may need to move in one direction off the screen, but they will never need to collide with anything. Is there a better way to do this?
Here is how I am creating them right now in script:
new t2dStaticSprite(betChip @ %betId)
{
scenegraph = $sceneGraph;
imageMap = "ImageMapGrey_Chip";
frame = "0";
canSaveDynamicFields = "1";
position = %position;
size = "49 48";
Layer = "10";
GraphGroup = "21";
BuiltInShaderType = "NONE";
WorldLimitMode = "KILL";
WorldLimitMax = "1366 768";
AutoMassInertia = "0";
CollisionPhysicsSend = "0";
CollisionPhysicsReceive = "0";
CollisionCircleSuperscribed = "0";
};
Thanks in advance for any help.
About the author
#2
12/16/2009 (8:49 pm)
That is kind of the situation right now, but that worst case scenario still worries me. Is there some kind of "lesser" object I could be using? I get the feeling that when I create these objects there is a whole lot more going into them than I need. Aside form dynamic text, these objects do not take any input, and have no output that I care about.
#3
Otherwise you will have to use the profiler and see what is slow.
12/17/2009 (2:36 am)
If they don't move or change, why not just have one big image? Or a few large images?Otherwise you will have to use the profiler and see what is slow.
#4
Is there a way to do this with just one, or a couple images?
Another thing to note is, that each place you can put a chip I also have invisible objects acting as buttons, I am sure that is slowing things down as well. Is there a better way to do that as well?
12/17/2009 (11:50 am)
They are chips on a betting field. There are 200+ places you can bet on this field. Any combination of chips can be active at one time, but once they are there, all they do is sit around until I kill them.Is there a way to do this with just one, or a couple images?
Another thing to note is, that each place you can put a chip I also have invisible objects acting as buttons, I am sure that is slowing things down as well. Is there a better way to do that as well?
#5
You could put the collision (clicking) in the same object so you didn't need the invisible objects. You can see how stuff like this would vastly bring down the number of objects.
I am not sure exactly what you are doing so it is a bit hard to know exactly how to address it, but doing things similar to this would bring down the number of objects.
It will probably come down to code your own object up. Coding gui objects if you have pretty good c++ skills isn't too hard and there are tons of examples that come with torque to look at. Unless of course it is just a background then you just use one big image object. They key is figuring how to group objects into single images or tiling images and making the object bigger or smaller.
NOTE: I have not used TGB much so not sure of all the object types, but I am sure there is something that is static and doesn't have things like collision going on that will drop the performance as well. This is another reason why many of my answers used guis as examples, but there isn't a lot different from what it sounds like you want to do and a gui, I am sure the code is similar.
Hope that helps and good luck.
12/17/2009 (1:34 pm)
Well you could do what many betting games do and show them stacked and have a top image and a bottom image that can tile down then you just write an object that can be scaled. So it just renders the top image and then tiles the bottom image below that (single object). So as you scale the height of the object it keeps adding/tiling the bottom image, then if you wanted to know how tall to make it based on how many chips they wanted to place you would just take the height of object and divide it by the height of the image (assuming top and bottom images where the same). Note: you would probably use an image array much like the the one used for the checkbox gui.You could put the collision (clicking) in the same object so you didn't need the invisible objects. You can see how stuff like this would vastly bring down the number of objects.
I am not sure exactly what you are doing so it is a bit hard to know exactly how to address it, but doing things similar to this would bring down the number of objects.
It will probably come down to code your own object up. Coding gui objects if you have pretty good c++ skills isn't too hard and there are tons of examples that come with torque to look at. Unless of course it is just a background then you just use one big image object. They key is figuring how to group objects into single images or tiling images and making the object bigger or smaller.
NOTE: I have not used TGB much so not sure of all the object types, but I am sure there is something that is static and doesn't have things like collision going on that will drop the performance as well. This is another reason why many of my answers used guis as examples, but there isn't a lot different from what it sounds like you want to do and a gui, I am sure the code is similar.
Hope that helps and good luck.
#6
C++ is actually my primary language, So I might give that a shot. And, I can keep looking through TGB, maybe there is somethign more basic than a t2dStaticSprite already built in.
Thanks for the reply and suggestions.
Edit: Tile maps seem like such a probable solution to replace all of my invisible boxes. My bet field is basically a Roulette table, would a tile map be a good solution for that? If so, are there good tutorials out there for that?
12/17/2009 (1:45 pm)
Hmm, well I can't really do the stack thing. There are actually about 200 different places to bet, each needs its only single chip when bet on. The problem with having just one click object is that there is a big board with many different areas to bet, I need to know which area was clicked on, and place a chip there.C++ is actually my primary language, So I might give that a shot. And, I can keep looking through TGB, maybe there is somethign more basic than a t2dStaticSprite already built in.
Thanks for the reply and suggestions.
Edit: Tile maps seem like such a probable solution to replace all of my invisible boxes. My bet field is basically a Roulette table, would a tile map be a good solution for that? If so, are there good tutorials out there for that?
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
Which basically means: 200 objects potentially, optimally 100, but not 400 objects (text fields are objects too)