Overral game performance

Place to report bugs in MoM IME and suggest ideas for enhancements (please read rules before posting)
Post Reply
hammer
Posts: 9
Joined: Sat Jan 06, 2007 1:46 pm

Overral game performance

Post by hammer » Sat Jan 06, 2007 9:48 pm

Hi, there! First i want to congratulate you for doing this project for so long, and keeping it up! :) I really like MoM.

So here is my question, suggestion.

I've noticed that the game runs quite slowly on my pc. And i cant say its slow or something its a 2200+ mhz, 1gb RAM, 256MB ATI Video and so on. But the game itself runs very laggy. Why would that be??

Also there seems to be some problem with the menu's. Its like the buttons are moved width one half of their length to the left. So basically when i click a button in the menu if i click on the left middle the button doesnt activate, if i click on the right middle the button clicks, even if its outside of the visible button. I dont know if you understand me :) ... I can make a screen shot if i have to, just say so.

User avatar
Implode
Site Admin
Posts: 432
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

Re: Overral game performance

Post by Implode » Sun Jan 07, 2007 2:01 am

hammer wrote:I've noticed that the game runs quite slowly on my pc. And i cant say its slow or something its a 2200+ mhz, 1gb RAM, 256MB ATI Video and so on. But the game itself runs very laggy. Why would that be??
Because the map is made up of 60 x 40 squares * 2 = nearly 5,000 triangles, plus plenty more for the map features (towers, minerals, etc.), units, buttons and other stuff - it has a lot more to draw than you think. 0.9.0 is actually (and by accident) a bit faster again than 0.8.9. I runs at almost 30 fps now. Also in 0.9.0 its easier to turn the fps display on and off, so people can actually post exactly what frame rate they get. What you call "slow" I might think is actually pretty good :)

BTW, one thing you can do if it really is too slow is zoom the map in. If you click the magnifying glass with a + on the right hand side of the button bar above the map until the map stops zooming any further, this sets the map zoom the same as the original MoM and, because it has less to draw on the screen, speeds up the frame rate by at least 50%.

hammer wrote:Also there seems to be some problem with the menu's. Its like the buttons are moved width one half of their length to the left. So basically when i click a button in the menu if i click on the left middle the button doesnt activate, if i click on the right middle the button clicks, even if its outside of the visible button. I dont know if you understand me :) ... I can make a screen shot if i have to, just say so.
If you look that's already on the bug list, and actually I've fixed it in 0.9.0 so just wait a few weeks. What's funny is I'm so used to it, I find myself clicking off the right hand side of text buttons and expecting it to work :)

Implode.

hammer
Posts: 9
Joined: Sat Jan 06, 2007 1:46 pm

Post by hammer » Sun Jan 07, 2007 8:13 am

hm, my bad i though i have downloaded 0.9.0 version. I just saw that its 0.8.9 :) i guess you havent released 0.9.0 yet :) Keep up the good work! :)
And about the drawing, a simple way to optimise stuff is to draw only the visible area of the map, but i guess you already know that from what i've seen so far :))

Also can you say when the 0.9.0 will be released? :)

edit: i've just tried to play with a friend of mine ... well his PC is a little slow 2000mhz, 256 MB Ram, 256 MB Video, and the game was hardly to say "playable". Can you do some optimisations so it runs on normal pcs?(cant say slow because these pc-s have quite a good speed)

User avatar
Implode
Site Admin
Posts: 432
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

Post by Implode » Sun Jan 07, 2007 7:57 pm

hammer wrote:i guess you havent released 0.9.0 yet :)
Yup that's what I'm saying, there's some (accidental) speed improvements in the new not-yet-finished version :)

hammer wrote:Also can you say when the 0.9.0 will be released? :)
Depends on when the last part I need to rebuild my PC shows up from ebay, been waiting about 3 weeks now (grrrrrrr!). If that doesn't show up, I'll keep going, I only have 2 changes left to make so MAYBE it'll be done by next weekend. If it finally shows up, I'll be a few days building the new PC and getting everything moved onto it so that'll probably delay it a bit.

hammer wrote:edit: i've just tried to play with a friend of mine ... well his PC is a little slow 2000mhz, 256 MB Ram, 256 MB Video, and the game was hardly to say "playable".
Wait until 0.9.0 so you can actually tell me what frame rate it runs at.

hammer wrote:Can you do some optimisations so it runs on normal pcs?
I already did... I spend quite a while in the past few versions trying to speed it up but its getting to the point that there's very little left I can do about it, besides which I really need to be working on adding new things (like ability to attack cities) instead of just spending ages on trying to tweak performance.

My laptop has a 3.06Ghz CPU, 1 GB RAM but is held back by its fairly crappy 64 MB ATI Radeon 9000 gfx chip and is nearly 4 years old, so I don't consider it a decent PC for games at all. On there, the old versions of MoM IME I think used to run about 8-12 fps, now it runs at 30-35 which is blazingly fast. So that's why I'm saying I've already done plenty of optimizations on it...

I doubt the RAM has much to do with anything, it really doesn't use much, I'd expect anything over 256 MB would make no noticable difference. I'd expect its all dependant on CPU & graphics card speed. I'm itching to find how fast it'll work on my newly built desktop (which has a slower CPU and less RAM than my laptop, but the CPU is 64 bit and it has a killer graphics card :) )

Implode.

hammer
Posts: 9
Joined: Sat Jan 06, 2007 1:46 pm

Post by hammer » Sun Jan 07, 2007 10:46 pm

Well good luck with finding that last part :)

Yes you are right there are more things that need to be finished before tweaking the project. But what i am saying is that MOM works on 386 on 30 mhz :)

But enough small talk, i dont want to distract you from the project development :)

Suor
Posts: 1
Joined: Wed Apr 11, 2007 5:21 pm
Location: Russia, Krasnoyarsk
Contact:

Post by Suor » Wed Apr 11, 2007 7:15 pm

I've tried your mom ime and I think it is really great work. But I was very very surprised by its performance. I used to write some game-like code myself in Delphi using Direct3D for 2D graphics with 32bit textures and actual alpha blending. It's no doubt for me that it should work much faster. Probably you are doing something wrong. May be should find someone to look at your code - it is sometimes near impossible to find own mistakes.

And one more performance issue, which very suprised me as well. Generating of heroes when starting new game - it took so much time that I was able to get myself a tea in a meanwhile - this is on Athlon 64 X2 3800+, 1GB DDR-II-800, Radeon X1600Pro 512Mb.

However, your intention to focus on developing gameplay features seems making sense. And I dont trying to convince you to spend much time optimizing instead of it.

Maybe you can send me some pieces of code. For that heroes generation, for example, so I can try to optimize them and sugest any ideas.

User avatar
Implode
Site Admin
Posts: 432
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

Post by Implode » Thu Apr 12, 2007 12:31 am

Suor wrote:I've tried your mom ime and I think it is really great work. But I was very very surprised by its performance. I used to write some game-like code myself in Delphi using Direct3D for 2D graphics with 32bit textures and actual alpha blending. It's no doubt for me that it should work much faster. Probably you are doing something wrong. May be should find someone to look at your code - it is sometimes near impossible to find own mistakes.
If you want access to the CVS server to download at look at the code, send me an email with a user ID password you want and I'll try to set it up. I'm assuming you realise its in Delphi? Also bear in mind none of it compiles at the moment because of the massive amount of changes I'm making for 0.9.1. But you could still look at the drawing code. Or if you just want me to email you the relevant bits of code only, that's fine too.

The code that draws the units onto the map I know is really inefficient, but I've tried commenting this out before to see how much it sped up (to prove whether that was what was causing the slowdown) and it didn't make much difference at all. So it must just be drawing the terrain tiles, but I've optimized that to death and I can't see much else to do with it.

Suor wrote:And one more performance issue, which very suprised me as well. Generating of heroes when starting new game
Yes... I'm puzzled by that too. It used to take a few seconds but then in a later version of MoM IME I noticed it had slowed down drastically, probably takes 20-25 seconds on my PC. I debugged it to prove that it was actually still working correctly, so I was happy with knowing that, I didn't spend ages trying to find exactly what had caused it. What I suspect has caused it is the unit calculation routines, I've added various levels of complexities to these, e.g. taking into account modifications due to spells. That being the case, those routines have all changed completely in 0.9.1 so the performance is probably going to have changed drastically again (for the better, or worse, is anybody's guess). So I don't see its worth looking at this yet until 0.9.1 is working.

Implode.

momfreeek
Posts: 5
Joined: Fri Jul 20, 2007 12:55 am

Post by momfreeek » Fri Feb 22, 2008 8:01 pm

Have you considered keeping the entire map pre-drawn in a buffer? High memory usage, but its easy to calculate exactly what the usage would be and it could cut the intensive cpu usage massively.

use one of the following methods:
- blit the visible area from the map buffer every frame before drawing creatures and effects on top.
- pre-draw everything and use a 'dirty rect' system (mark areas to be redrawn when things move) then blit the visible area.
- a combination of the above

2d games would generally use these methods to improve performance. In days when memory was expensive, big scrolling maps would be implemented by keeping the visible area in memory, shifting that image then drawing the newly visible edges (google maps is a good example of this method).

Does any of that help? I understand that you want to add features first. Make it work first, then optimise.

User avatar
Implode
Site Admin
Posts: 432
Joined: Fri Feb 24, 2006 3:35 am
Location: Newfoundland, Canada
Contact:

Post by Implode » Tue Feb 26, 2008 1:23 am

momfreeek wrote:Have you considered keeping the entire map pre-drawn in a buffer?
Wait for 0.9.3... I've done similar to that, it generates 4 vertex buffers to draw the entire map, units, etc. and then just uses shifting transform matrices to change the viewable area. Its MUCH faster, I get >60 fps when viewing the whole map.

Implode.

momfreeek
Posts: 5
Joined: Fri Jul 20, 2007 12:55 am

Post by momfreeek » Thu Feb 28, 2008 11:43 pm

Sounds like a big improvement. There is still a whole new level to be reached with proper buffering though. Optimising the rendering code is one thing but the real payoff is to be had from massively reducing the number of pixels to be rendered each frame by storing the rendered image.

Any work that can be saved between frames in a buffer (directx surface) could have a dramatic effect on frame rates as polygons would only be redrawn when things change (and generally, things change very rarely). Ideally, the average work done per frame should be a fraction of what it is now making a zippy app that only lags when scrolling or zooming the map rather than an app that is constantly sluggish. Frame rates due to graphics really shouldn't be an issue in a 2d strategy game.

Either way, its not as important as finishing the game.. but worth considering once everything is working I think.

User avatar
klausbreuer
Posts: 19
Joined: Mon Oct 20, 2008 8:38 am

Re: Overral game performance

Post by klausbreuer » Mon Oct 20, 2008 2:53 pm

A performance problem I find myself with is the animation speed (latest version, of course):

* Please add an option to simply snap units to the next tile instead of sloooowly moving them there.
* Dito for the map scrolling - it can take quite a while to scroll to the next unit on the map.

Together, these two animation delays, while not seeming to require more CPU power, slow down the game a *lot*.

And while we're at it - the creatures are shown including their ground square. This does not make them look particularly good, especially when moving them... any chance of changing that as well, merely showing the creature itself?

As to map creation speed: personally, I create a basic map in RAM, then create a copy. On that copy I place everything mobile and blit it into the screen. This makes things nice and fast. If something changes permanently (for example, a road is built), the basic background map is modified.

(Yes, I write stuff in Delphi 7 - been using Delphi/Turbo Pascal since '86 ;)

Looking at your FAQ under 'Performance':

* Yes, you do draw more graphics, but why use an API? Create an array, draw pixels into there, and then blit the whole thing on screen. Or (better yet, IMNSHO) use http://grhttp://graphics32.org/wiki/ - it's for Windozw graphics, it's for Delphi, it's free and very very fast.
* Why are you parsing the XML files more than once? Why not simply read them once at the start, parse them into global variables, and bingo?
* Yes, thread safety can slow you down quite a bit...

OTOH - seeing that you're switching to Java, does it matter anymore at all? ;)

Ciao,
Klaus

Post Reply