You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.
Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.
90% of the programs time is only using 10% of the code. (90/10 law)
Optimisations required for this game:
1. Load and store media in memory from the beginning.
This is causing a bottleneck in performance when switching from the menu
to the game as the media is getting dumped and then reloaded when the
game starts and vice versa.
When the game starts the only things that need processing is the setting
up of the level. The media can be pre-loaded, trees, the bike, sounds
(when they're added). Thus making the switch from menu to game faster.
When the game ends the level can stay set up and only dumped when a new
If at the beginning of the code all the references to media can be set
to NULL and each time it may need loading then that reference can be
double checked and loaded if it has been flushed from memory.
ie. When it comes to loading the bike model, if the ID is NULL then load
it in, if not then there's no need to re-load it.
Only when the screen resolution has been changed then all these
ID's will have to be reset to NULL.
2. Tree collision may (will) need optimising.
Instead of calculating the distance for every tree in the scene, it
would be much faster just to check the distances on the X and Z axis
first. Currently only one distance check is actually using the sqrt()
There was a slight frame drop when the timer based movement was
implemented so this optimisation is most important.
ie. Anything within the first rectangle to be checked can then be
checked for distance collision. This will shave a lot of clock
cycles on large batch collision checks.
In assembler the 'imul' command uses a lot of cycles so if I can
reduce that amount then the collision on 5000 or 15000 trees will
speed up frame rates and give the oppurtunity to add more features.
Currently the highest level has 12,000 trees.
3. Freeing up DirectX resources.
In the TGC forums there's a subject on images not being loaded into
memory when the game is run and I've also had the same problem whilst
Hopefully some of the above methods may resolve this issue as media
will be kept in memory. Still the issue with DBPro and GDK still seems
to be with PNG's.
4. Add a lot more comments to code.
In the future help with optimisation I will need to go through each
night and add comments as the project is getting larger each day as
more and more code is being added.
This will be most unfortunate for others when the code is released as
I'm not using easy coding techniques (ie C++ classes etc) for easier
reading. Tons of my code is what us programmers call cheating,
especially when it comes to my collision techniques.
5. Timer base the menu screen.
Yes, at last I come to think about this. It runs fine on my laptop but
will probably go crazy on other faster computers so I will have to add
this timer functionality to the menu even.
Login to post a reply