Phantom107 Forum

Phantom107's Forum. Discuss about games, GML, 3d, game design here. Enjoy your stay ;)
 
HomeFAQSearchRegisterMemberlistUsergroupsLog in

Share | 
 

 Speed Techniques

Go down 
AuthorMessage
Phantom107
Admin
avatar

Posts : 206
Join date : 2008-01-03
Location : The Netherlands

PostSubject: Speed Techniques   Thu Jan 03, 2008 2:38 pm

In my opinion the most important aspect of game programming is keeping the game optimized. Nobody likes a laggy game. Using speed techniques the game will run smoother, and allow more calculating and more drawing on the screen.

Technique 1
Keep culling on. This is done by: d3d_set_culling(1). Keep culling on will remove all backface drawing, and thus increasing the drawing performance 100%. The only trouble is drawing the faces in the right order. This will take some getting used to.

Technique 2
Execute as little code as possible. Often things do not need to be checked. My advice is to have a controller object that keeps track of the most important things of gameplay.

Technique 3
Executing background_get_texture(...) every step is a big waste of memory, so define all textures only once. Do this in the [Create Event] of the controller object as follows:
Code:
tex[1] = background_get_texture(bg_tex1);
tex[2] = background_get_texture(bg_tex2);
tex[3] = background_get_texture(bg_tex3);
etc...
Now, when drawing the texture, simply put tex[texture_index] in the texture argument. Do not define all textures in each object that uses them, but load the texture from the controller object. For instance, say object_1 wants to load tex[2] from the controller object. The code will be this for the texture argument:
Code:
obj_controller.tex[2]
Technique 4
Always use models. When using models Gamemaker only needs to draw them. When using d3d_draw... functions Gamemaker needs to construct the model first, and then draw it on the screen. This will cause a big loss of drawing performance. Also, keep in mind that the lesser polygons in your model, the lesser they consume.

Technique 5
Just like the textures, define all models only once. Load them from a controller object just like the textures.

Technique 6
Caution: This technique only works if you know exactly what you're doing; otherwise it will lower performance.
Generate terrain to big models. For example, if you have a terrain with grass and ground, generate all grass to one big grass model, and generate all ground to one big ground model.

Technique 7
Make a draw distance system. Objects at a certain distance won't be drawn. You could do something like this in the
[Draw Event]:
Code:
if point_distance(x,y,global.camera_x,global.camera_y) < 128
{
//draw
}

An other technique is to set and unset the visibility of objects. You could have an alarm run all the time to keep checking it. Be sure to set the alarm in the [Create Event] to start running the alarm! This is for example the
[Alarm 0 Event]:
Code:
alarm[0] = 3; //keep the alarm running
with (all)
{
if point_distance(x,y,global.camera_x,global.camera_y) < 128
visible = 1;
else
visible = 0;
}
obj_controller.visible = 1; //make sure the controller remains visible.

If you have a lot of objects to check just set the alarm to a greater value to decrease the speed of checking.
This will greatly increase performance if you do it right.

Technique 8
This isn't really a technique, and you most likely know this, but when running the game close all unnecessary programs. Closing downloads, media players and even internet explorer will increase the runtime of your game.

Technique 9
An important aspect of RAM usage is the loading of external files. Often unused textures/models/sounds are kept in the RAM memory when they aren't needed. This is obviously wasted memory. Try to load resources when you need them, and get rid of them when you don't.

I hope it helps Smile


Last edited by on Mon Jan 07, 2008 12:27 am; edited 7 times in total
Back to top Go down
View user profile http://phantom107.actieforum.com
slayer64
Heavy Poster
avatar

Posts : 143
Join date : 2008-01-05

PostSubject: Re: Speed Techniques   Sat Jan 05, 2008 2:41 am

good things to do to make games run as FAST as possible.

why is putting all the textures in an array in the controller faster than putting them in the object itself that will use it.
wouldn't that be slower? because u must say Contoller.tex[0];
Back to top Go down
View user profile
Phantom107
Admin
avatar

Posts : 206
Join date : 2008-01-03
Location : The Netherlands

PostSubject: Re: Speed Techniques   Sat Jan 05, 2008 2:54 am

slayer64 wrote:
good things to do to make games run as FAST as possible.

why is putting all the textures in an array in the controller faster than putting them in the object itself that will use it.
wouldn't that be slower? because u must say Contoller.tex[0];
When you load a texture it will be placed in the memory of your computer. For instance, say when loading texture_1 up in the controller object it will consume 500 kB RAM. Other objects can load it from the object with no problem.

Now, when putting the texture in every object, it will consume 500 kB RAM for each of those objects. If you have 12 of those object, the texture will actually consume 12 x 500 = 6000 kB RAM. Shocked
Back to top Go down
View user profile http://phantom107.actieforum.com
slayer64
Heavy Poster
avatar

Posts : 143
Join date : 2008-01-05

PostSubject: Re: Speed Techniques   Sat Jan 05, 2008 3:04 am

hhhhmmmmm. that makes sense. i think i will start to think more about how i make my games now. i could speed everything up. dam just as i though i was being MOST efficient. i never really though about how much actual RAM was being used. more variables, more textures in the variables. yup that's more useful space being taken up.
Back to top Go down
View user profile
Guilty Sparks
Heavy Poster
avatar

Posts : 154
Join date : 2008-01-05
Location : USA East Coast

PostSubject: Re: Speed Techniques   Sat Jan 05, 2008 4:22 pm

I knew half of these things, but the culling will help Very Happy Thanks
Back to top Go down
View user profile
Phantom107
Admin
avatar

Posts : 206
Join date : 2008-01-03
Location : The Netherlands

PostSubject: Re: Speed Techniques   Mon Jan 07, 2008 12:23 am

  • Updated technique 4
  • Added technique 8
  • Added technique 9
Back to top Go down
View user profile http://phantom107.actieforum.com
Sponsored content




PostSubject: Re: Speed Techniques   

Back to top Go down
 
Speed Techniques
Back to top 
Page 1 of 1
 Similar topics
-
» Patrol tactics, techniques, and procedures (TTPs)
» how to set speed for my selenium test
» Review: Need for Speed: Undercover (Wii Retail)
» Review: Need For Speed Nitro (Wii Retail)
» The Need for Speed movie

Permissions in this forum:You cannot reply to topics in this forum
Phantom107 Forum :: Techniques-
Jump to: