Tips and Tricks
From GameStudio Wiki
Some various tips and tricks related to game design:
Contents |
Level design
These are tips and tricks that apply mainly to level design.
- Use LOD. For far greater flexibility with LOD control, the flexible LOD system could be used.
- Make levels using models instead of blocks as much as possible. Models render much faster than level geometry does.
- MDL terrains have much more flexibility in design and shape, and can be nearly as fast as HMP terrains if they are small (no bigger than 30x30 vertices). They do take considerably longer to make, however, and don't offer the size, multitexture capabilities, and rendering speed of HMP terrain.
Modelling
These are tips and tricks that apply mainly to making models.
- For maximum detail and the fastest frame rate, have your models have between 3000 and 6000 polygons.
- Vertices take about twice as long to process than polygons and textures do.
Scripting
These are tips and tricks that apply to scripting, C-script and Lite-C programming.
- For enhanced accuracy of calculations, use the largest numbers you can within the var's limit. That is, instead of 100 for the maximum health, make it 1,000,000.
- If you need more decimal places of precision, there is a mathematical trick you can use that uses the design of the number system. It only works for standard add and subtract though and it can be tricky to work with. It gives up to 9 decimal places of precision rather than just 3. A similar thing can be done for numbers into the billions and trillions.
var myvar; // main variable
var myvar_fine; // fractional part - fine as in fine adjustment (like for a microscope)
var myvar_course; // integerical part - course as in course adjustments
function some_function()
{
// adds 70.7106781186547...
myvar_course += 70; // add the course value
myvar_fine += 710678.119 // as close as you can get
while (myvar_fine >= 1000000)
{
myvar_course += 1;
myvar_fine -= 1000000;
}
myvar = myvar_course + (myvar_fine / 1000000);
}
- For extreme accuracy, beyond that of even the double, use strings and do the computations using these single-digit strings. Think about the way you work out general arithmatic by hand then apply it to your script. Theoretically, you could find 21024 to exact precision in considerable time if done properly. The output is a string rather than a variable which allows for this extreme precision.
- Global variables are faster than local variables.
- Fixing bugs can be rather tricky. One of the best methods is to take careful note of the circumstances in which is causing the bug then examine the code related to those circumstances. That is, if a bug involves movement faster than 70 mph in a racing game but doesn't occur at slower speed, check for anything relating to 70 in your movement code.
- To quickly count characters for line feeds of lengthy strings, of which applies best to bitmap fonts, use a system like this:
string lengthy_string; // 123456789A123456789B123456789C123456789D lengthy_string = "I am a lengthy string. I have\n32 characters per \"row\"; I have 3 lines.";
The letters mixed in signify a multiple of ten. C is the third letter of the alphabet so it represents 30. The numbers that follow are for the ones digit. For 32 characters per line, find the letter C and 2. When \"'s or \\'s are used, add 1 extra for each. The line feed, \n goes after the word "have" but before the "3" as the quotes increase the limit to 34 instead of 32. The count starts from the end of the last \n or the very start of the string. This works best for strings defined within a function and not changed by input. The counting stuff should always be commented out. When a \n is placed, the counting stuff needs to be realigned (by using the space bar).
- Learning the four fundamentals to scripting can get you far. With knowing the four fundamentals, you can work wonders. The four fundamentals to scripting are:
- String and Variable manipulation. This includes declaring strings and variables, manipulating them, and performing calculations.
- If statements and loops. This includes how to use conditions and how to use loops properly.
- Function handling. This includes creating functions and calling them.
- Debugging. This includes how to find bugs and knowing how to fix them.
Shader scripting
These are tips and tricks that apply to writing, testing, and creating shaders.
Texturing
These are tips and tricks related to texturing and texture-creation.
- Use 256x256 textures as they render the fastest.
- Use the smallest texture size you can with the least loss of detail.
- Use 16-bit textures when there is no noticable difference with the 24-bit version.
- Avoid using textures with alpha channel where parts are partially transparent and others are fully opaque. Use the transparent parts as separate skins (or separate enties in older versions). For something with a consistant transparency, use the transparent flag and the alpha setting instead.
- To allow for odd-sized textures, lay them out on a single model skin.
- For objects meant as background scenery, use small textures. With the higher strength of fog, even close objects don't need large texture sizes.
- Avoid using textures bigger than 1024x1024 unless mipmaps are created. This ensures considerable compatibility with older systems.
Lighting
OK, for lighting I’ll try and give you some quick tips…
Figure A : Lights won’t make a cone shape (unless you use blocks ) because they cast light in a sphere shape. If you WANT the impression of a cone shape spotlight you have to fake it, because using small blocks assembled as a 'tube' is a huge waste of calculation time. A small light at the source (like a light fixture) and a larger light on the opposite surface (in this case, the floor) will make your light appear to ba casting in a certain direction. Make sure your light ‘bulbs’ aren’t right on top of a surface.
Figure B : I see you have enclosed light fixtures on your ceiling. These should not cast light on the ceiling as if they were bare bulbs. You want a bit of shadow surrounding the light fixtures. If your fixtures are blocks, move your lights up close to the block so it creates some shadow at the sides. But if your light fixtures are models, the way to create shadows is to still put a block the size of the fixture there. Then select all the surfaces of the block and set them all to ‘none’. Invisible blocks don’t block light, so you must set the surface flags to ‘none’, and it will still be invisible and still block light.
Figure C : What if you have a ledge within your imaginary cone of light? You will need to add another light to make it appear the light is shining on the ledge too. Simple To make the most realistic lighting, you must do all lights so they follow the light source. If it’s a cone shape light, your light for the ledge should be bigger than the source, but smaller than the floor in this case.
Figure D : This step is almost the most important step for good lighting. Ambient lighting. Notice how your areas of shadow are completely black and dark? You won’t find this in real life. All those lights you have will naturally reflect off walls and the floor to some degree, and while areas may be dark, they won’t be completely black in a room with a lot of lights.
There are 2 methods for creating the bit of light you need. As mentioned above, and what I do too, is create a light, and set its diameter large enough to reach all walls. Then set it’s brightness to 10, 10, 10 for starters. if it’s too bright, lower the numbers, and if it’s too dark, raise the numbers.
Now look closely at Figure D… there’s a ledge there, so you must use 2 lights for ambient in this case. If you use only one up high, the underside will still be black. If you put only one down low, then the upper side of the ledge will be black shadows. If you use only one light right in the middle, odds are you’ll be too dark on top of the ledge AND below it. So put one higher than the ledge, and one lower.
Now, chances are you’ll need multiple lights as well depending on the shapes of your rooms.
Now for the second, and easiest method for ambient light. At the top of WED, go to FILE > Map Properties
Here you can set the level ambient. Again, start with, like 10, 10, 10. This method will make it so you don’t have to use big ambient lights.
There is a trade off though. This will effect every room in your level. If you don’t plan on having any super dark areas at all, it’s an easy method. But if you want the ambient to be brighter in one room, you’ll have to use lights again.
Just a quick note. When you make a change to the map properties, first you must click SAVE to save your level and then reopen it. Only THEN build your level again to see the changes. Just placing lights, as you know, all you need to do is rebuild the level to see the changes. But not when setting map properties.
General
These are tips and tricks that don't apply to any other category or fit multiple categories well.
- Run experiments. Running experiments can help optimize your level and design for better design. Always establish some sort of baseline, a control, then choose what variables you want to try out and take plenty of notes.
- Always plan things out. Before even beginning to make levels, characters, and other objects, plan things out and decide how you want things to be. This'll lessen the chances of making mistakes and having to redo parts of your level. Study your plan and stick to it making changes carefully.
- Always do things at your own skill level to gain experience quickly and easily. That is, don't start on making your dream game right away, which'll likely be more complex than you can handle. Start with smaller side projects and build up your skill. As you accomplish the smaller side projects, work on a medium-sized project doing smaller side projects as practice.
Other Tips
Save CPU when task swiched No game pausing: cpu usage ~97%
Freezing funcs only: cpu usage ~60%
var wndf=0;
starter pause_game_at_alt_tab() //pause game on loose focus
{
while (1)
{
if (window_focus == 0){
if (!wndf){
wndf=1;
*//* camera.visible=off;
*//* fps_max=4;
freeze_mode = 1;
}
}else{
if (wndf){
freeze_mode = 0;
*//* fps_max=40;
*//* camera.visible=on;
wndf=0;
}
}
wait(1);
}
}
restrict fps: cpu usage ~7%
var wndf=0;
starter pause_game_at_alt_tab() //pause game on loose focus
{
while (1)
{
if (window_focus == 0){
if (!wndf){
wndf=1;
*//* camera.visible=off;
fps_max=4;
freeze_mode = 1;
}
}else{
if (wndf){
freeze_mode = 0;
fps_max=40;
*//* camera.visible=on;
wndf=0;
}
}
wait(1);
}
}
disable camera: cpu usage ~0%
var wndf=0;
starter pause_game_at_alt_tab() //pause game on loose focus
{
while (1)
{
if (window_focus == 0){
if (!wndf){
wndf=1;
camera.visible=off;
fps_max=4;
freeze_mode = 1;
}
}else{
if (wndf){
freeze_mode = 0;
fps_max=40;
camera.visible=on;
wndf=0;
}
}
wait(1);
}
}
Ok, if you read this, you understand now, for low cpu usage catch loose focus event and disable your camera.


