PDA

View Full Version : The best way to save memory?


jrrTolkien
06-25-2014, 04:13 PM
What's the best way to make a multilevel game without using too much RAM? :confused: I always have way too many models in my games, so it uses up too much virtual memory. :( Anyway, thanks in advance! :)

-jrr

MrMoke
06-28-2014, 09:52 AM
I think that you just answered your own question! Too many objects.

The answer might be to re-use the existing objects. using Dummies might involve a little more effort on your part, but save some space.

(1) Take everything that you want to use in Scene Two, including the camera, and drop Dummies on them in their Starting Positions.
(2) Write a quick Method using a "doTogether" that moves everything back to their starting positions making sure to use a duration of zero for the moves(will come in handy as a game Starter).
(3) Move everything that needs to be repositioned in Scene Two, including the camera, to their new places, and drop new Dummies on them.
(4) Write a quick Method using a "doTogether" using "set point of view" to migrate everything to their New starting positions making sure to use a duration of zero for the moves.
(5) Repeat for each scene.
(6) Start coding the rest of the game Methods.

Theoretically, the Dummies don't take much space and the transitions will be mostly instantaneous unless you want to throw in Billboards or Fade-ins/fade-outs.

jrrTolkien
06-30-2014, 11:44 AM
Yeah, I tried that once and it made my code reeeeaaaally messy. Theoretically, it would work, though...

-jrr

MrMoke
06-30-2014, 02:30 PM
My test program that used an array of four objects, four parallel arrays of markers, and a single method to do the scene transitions took about 1.53MB.

Adding enough duplicate characters to accommodate the additional placements, but no additional code, raised the program size to 6.12MB.

A paltry 400% increase. :eek:

chickentree
07-04-2014, 04:14 PM
Yeah, I tried that once and it made my code reeeeaaaally messy. Theoretically, it would work, though...

-jrr

I think this goes back to using some kind of naming convention to associate your dummy objects with their main objects and sequence in the movie. If one dummy object is used for several objects, then I would name it according to the location it represents. In short, come up with a naming system so that when you look at an object's name (dummy or otherwise) it gives you enough information to remember how it fits into the big picture.

MrMoke
07-05-2014, 08:21 AM
Logical naming is definitely important for readability, especially for someone who might have to maintain your software at a later date. Always consider the people who might have to work on your stuff after you move on, and up, as Mark and I have over the years.

However, for this topic it would mean using multiple Dummy objects as place holders for specific objects that need to be reused at different locations as the world moves one scene to the next.

An easy process if you create a set of parallel arrays, and calls to a single relocate method that accepts a parameter for scene number.

As mentioned, it also saves a significant amount of memory by replacing objects with pointers, and reduces coding.

Structure and efficiency are also keys to success.

chickentree
07-08-2014, 11:50 AM
Logical naming is definitely important for readability, especially for someone who might have to maintain your software at a later date. Always consider the people who might have to work on your stuff after you move on, and up, as Mark and I have over the years.

However, for this topic it would mean using multiple Dummy objects as place holders for specific objects that need to be reused at different locations as the world moves one scene to the next.

An easy process if you create a set of parallel arrays, and calls to a single relocate method that accepts a parameter for scene number.

As mentioned, it also saves a significant amount of memory by replacing objects with pointers, and reduces coding.

Structure and efficiency are also keys to success.

So, if I understand you, there would be an array of dummy objects for each object that moves. The length of the array would be the number of scenes in the movie and you would create a world method called something like "setUpScene" and pass it the scene number.
setUpScene would go through each array setting each object's point of view to the dummy object in the corresponding array.

Is that the procedure you are describing?

Mark

MrMoke
07-08-2014, 01:22 PM
An even better idea that I used to minimize the If Statements was to stack all of the Dummies in a single array, and then use the parameter to compute the offset starting point of the Dummy array.
It cut the sceneChanger method down to a single if/else statement followed by
one-line loop.
Almost as good as having a two-dimensional array;)