Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gameloop optimizing
#1
I spent this week optimizing the gameloop and got an app 800fps (on a crap comp). I set up a hybrid gfx system using a lowerbuffer and I put most of the blting calls in ProcessMovement and ProcessNpcMovement.

I was wondering what others have done to raise their fps.
Reply
#2
Stop calling all the shit over and over and do it once when it's needed.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#3
800 FPS?

WTF..

I don't believe it, seriously.

Thought that you were a newcomer or something.

lol
Reply
#4
Low post count doesn't always mean low skill. Wink

It does for me generally, but I'm working with features before optimizations so I can get the game itself done and operational. Big Grin Make it pretty, then make it efficient.

I still have to find a way to repent for my sins of ever using elysium source, though. >_> Ewww.

But back on topic, gonna have to agree with Robin on this. Calling all that junk all of the time doesn't make much sense.
Reply
#5
Well, I'm pretty frustrated at this point. I completely recode the gameloop like 10 times a day. Right now I have 850-900 fps but I cant get the fringe to blt properly without packets.

I'm so pissed. Robin, will you send me your optimized source? (or jus the gameloop) lol. On top of that I don't have text blting done properly but I could care less for right now. And even when I have my fps capped at 32, it can still jump down to 30 when npc ai is active. UGH!!! If I could find an efficient way to use the MiddleBuffer, I would just use all the layers. I'm never going to be happy :[
Kousaten Wrote:Make it pretty, then make it efficient.
That's a bad idea.
Reply
#6
Counterstrike Source is by default cut off at 60 fps. Why the hell you need any more than that for a 2d RPG coded in visual basic is completely beyond me.
Reply
#7
I personally don't bother optimizing the client. I use 2% - 4% CPU roughly, if someone has an issue running that, that's their problem, the majority of the world should be fine.
Reply
#8
So I can use your alphablending and use ai efficiently. Chill out. Why waste loops on stuff you don't need anyways?
Reply
#9
But.. why would your AI be controlled Client side?

-.^;
Reply
#10
Rezeyu Wrote:But.. why would your AI be controlled Client side?

-.^;

It's not.. Why my fps drops slightly during the matrix loops Im not sure.. maybe the client has to wait for the server to finish and therefore loops less due to waiting. I guess the only way around that then is to optimize the ai, which I partially did.

Whatever, I still want an uncapped high fps :\
Reply
#11
seraphelic Wrote:
Kousaten Wrote:Make it pretty, then make it efficient.
That's a bad idea.

Actually its a good idea. Better to have something slow but complete instead of an incomplete, non-functional, buggy, but fast game.
Reply
#12
I win because I cap my fps at 18.

Ftw.
Reply
#13
Spodi Wrote:
Kousaten Wrote:Make it pretty, then make it efficient.
That's a bad idea.

Actually its a good idea. Better to have something slow but complete instead of an incomplete, non-functional, buggy, but fast game.[/quote]

Who says a fast game is buggy, non-functional, incomplete? LOL I know my engine isnt blting everything properly atm but I'm not going to release it buggy. Also I think it's better to work on the engine itself before releasing it with good gfx, so you don't have to release as many patches and updates.

Rezeyu Wrote:I win because I cap my fps at 18.

Ftw.
I might do that, Im pretty sure I'm going to use 16x16. What code do you use for your fps lock?
Reply
#14
Psh. As much as I'd like to have a beautiful 900fps source, I have decided that it may be a waste of time, which I dont have alot of. So I have thrown my 800fps source into the archive and will use my not so fast but no flaws 500fps source as my base.
Reply
#15
seraphelic Wrote:Who says a fast game is buggy, non-functional, incomplete? LOL I know my engine isnt blting everything properly atm but I'm not going to release it buggy. Also I think it's better to work on the engine itself before releasing it with good gfx, so you don't have to release as many patches and updates.

Actually its the whole concept of premature optimizing. Optimizing generally (definitely not always) increases complexity, whether it is code complexity, format complexity (binary files vs ini files or a database), dependency complexity (ie removing dependencies from objects to reduce reference type instance overhead, which could result in making it more difficult to find your way from one object to another later), etc. This just leads to more difficult designing from that point on. Optimizing is not a free process, either - it takes time. If you increase code complexity, development time increases even if the time spent optimizing remains a constant in comparison if you optimized last. Also, since optimizing is generally cutting out operations or replacing operations with faster counter-parts, it is expected that code could change its resulting value and thus potentially cause bugs.

The only way you could possibly, logically, create a program faster (in terms of development time) if you optimize it than if you don't is if you are refactoring while you optimize. But refactoring is something you should do while developing. In fact, probably should spend quite a lot of time doing it for any project of a decent size.

So, whats my point? I never said fast code is buggy, but all logic points to that if you spend time optimizing, the same features will take longer than if you do not optimize. Its best if you optimize when you need the better performance. Does your game bog down at 30 connections? Well, if you don't ever have 30 people playing at once, who cares? Spending your time focusing on supporting more people instead of giving people a reason to play will result in you having no one playing your game that can support hundreds of connections.

Of course optimizing is great. The faster something runs, the better. But when your time could be spent doing something more important, you should be doing that which is more important. Optimize your time, not your code. :wink:
Reply
#16
TonyNooblet Wrote:800 FPS?
WTF..
I don't believe it, seriously.
Thought that you were a newcomer or something.
lol
Ow lol I looked over this.. Yeah i'm pretty new to vb, but I used to program some awesome 2d rpg javascript games. So Tongue
Spodi Wrote:Of course optimizing is great. The faster something runs, the better. But when your time could be spent doing something more important, you should be doing that which is more important. Optimize your time, not your code. :wink:
Didn't know you could write speeches too :]. Well said.
Reply
#17
Aye, Spodi. Big Grin

Biggest Sakuramisora has ever gotten was like twelve players on at one time, and the community has just about died after the laptop (which we hosted the server on) was physically destroyed. I made the decision then to hop over to miragesource again, especially since William finally finished MSE2 (which has been great thus far, by the way).

Doing things like binary compression, and the tile encoding you mentioned once basic features are all set in place are definitely two things I'm looking at personally, but every little detail isn't really necessary for even as big as my game has gotten in the past.
Reply
#18
time based movement is something that was created many many years ago =)
Reply
#19
I just never went to sleep two nights ago so after about 30 hours of being awake, I was too tired to do much and thus that rant was born. Tongue

I've spent a lot of my time programming just optimizing stuff. While this has taught me a ton, it has also resulted in a lot of wasted time. On my recent project, I have been trying to change things a bit. I now write out something quickly, often with a very poor design until it is working. At that point, I do some of the basic optimizations while refactoring it. After testing it to make sure it works, I never go back to it until I profile my code and the times it is executed and how long it takes is just too high, or when I get to working with the code again and realize it needs to be redesigned.

I think its good to know the relative performance of certain functions, along with alternative ways to do it, for more broad concepts. For example, if you are making a high performance server in .NET, do you use BinaryReader/Writer and streams? Or do you make your own? What about cropping out unused bits? Who cares, you can inline replace it later since as long as it functions properly. But what type of networking scheme do you use? This actually affects a huge chunk of the networking and is best if you use the correct concept right. If you initially use threaded, blocking sockets, you will have to rewrite it all later to something more like async sockets which is a huge design change. But as long as you are using async sockets, you don't have to make the performance of its components great (ie you don't have to worry about your send queues or receive buffer performing well). So I guess make sure you use high performing designs when you know you will need them because they often will require large rewrites, but don't optimize until you do need it because optimizing is often small and contained rewrites.
Reply
#20
I made my source faster and it actually made programming a lot easier.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#21
What the fuck are you guys doing to get your FPS so high?
Reply
#22
Not re-rendering the entire scene every loop.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#23
Robin Wrote:Not re-rendering the entire scene every loop.

Sounds hard.

I'm still ripping things from MS and trying to function scratch.

I have a feeling it's going to be fine though.
Reply
#24
TonyNooblet Wrote:
Robin Wrote:Not re-rendering the entire scene every loop.

Sounds hard.

viewtopic.php?f=69&t=696&start=0
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#25
Oh.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)