Mirage Source

Free ORPG making software.
It is currently Fri Apr 19, 2024 11:07 pm

All times are UTC




Post new topic Reply to topic  [ 51 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Gameloop optimizing
PostPosted: Thu Apr 17, 2008 7:45 pm 
Offline
Regular
User avatar

Joined: Tue Oct 09, 2007 1:40 am
Posts: 93
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.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Thu Apr 17, 2008 7:52 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
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?


Image


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 7:19 am 
Offline
Persistant Poster
User avatar

Joined: Wed Nov 29, 2006 11:25 pm
Posts: 860
Location: Ayer
800 FPS?

WTF..

I don't believe it, seriously.

Thought that you were a newcomer or something.

lol

_________________
Image


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 12:29 pm 
Offline
Knowledgeable
User avatar

Joined: Wed Jul 26, 2006 11:22 pm
Posts: 143
Location: Virginia, USA
Low post count doesn't always mean low skill. ;)

It does for me generally, but I'm working with features before optimizations so I can get the game itself done and operational. :D 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.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 1:13 pm 
Offline
Pro
User avatar

Joined: Wed Jun 07, 2006 8:04 pm
Posts: 464
Location: MI
Google Talk: asrrin29@gmail.com
doing major optimizations that cut file sizes in half or significantly reduce memory and bandwidth usage are always important, but yes, I'd rather code in features then spend 5 hours in my code to get a 1% performance boost. that can wait until more important things are done.

It's all about picking your battles. Also, always make sure to code your features efficiently, or you end up with a software like elysium.

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 5:32 pm 
Offline
Regular
User avatar

Joined: Tue Oct 09, 2007 1:40 am
Posts: 93
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.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 5:34 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Aug 17, 2006 5:27 pm
Posts: 866
Location: United Kingdom
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.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 5:43 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
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.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 5:45 pm 
Offline
Regular
User avatar

Joined: Tue Oct 09, 2007 1:40 am
Posts: 93
So I can use your alphablending and use ai efficiently. Chill out. Why waste loops on stuff you don't need anyways?


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 5:47 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
But.. why would your AI be controlled Client side?

-.^;


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 5:53 pm 
Offline
Regular
User avatar

Joined: Tue Oct 09, 2007 1:40 am
Posts: 93
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 :\


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 5:55 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
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.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 5:56 pm 
Offline
Pro
User avatar

Joined: Thu Dec 14, 2006 3:20 am
Posts: 495
Location: California
Google Talk: Rezeyu@Gmail.com
I win because I cap my fps at 18.

Ftw.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 6:07 pm 
Offline
Regular
User avatar

Joined: Tue Oct 09, 2007 1:40 am
Posts: 93
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?


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 6:45 pm 
Offline
Regular
User avatar

Joined: Tue Oct 09, 2007 1:40 am
Posts: 93
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.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 6:59 pm 
Offline
Pro
User avatar

Joined: Wed Jun 07, 2006 8:04 pm
Posts: 464
Location: MI
Google Talk: asrrin29@gmail.com
Honestly I can't see what all the big fuss is about uncapped FPS. You need the cap on FPS to control how fast everything is processed, so that one player with a crap computer isn't going 1 frame per second while another player is cruising accross the screen in the blink of an eye. I have my game capped at 21 FPS, it's just smooth enough to make it pleasant to the eye, but not so fast that the NPC AI gives you that "wedding march" follow path.

In my opinion, Optimize the client to be able to run on computers designed 5 years ago and don't worry about anything else. it doesn't need to be 100% super optimized, as it's only the client.

The server on the other hand, every optimization server side is multiplied in value by the number of concurrent connections, so if you have 50 players and a process that takes 100 milliseconds, you've just saved your self alot of lag by reducing that process to 50 milliseconds.

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 11:19 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
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:

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Fri Apr 18, 2008 11:24 pm 
Offline
Pro
User avatar

Joined: Wed Jun 07, 2006 8:04 pm
Posts: 464
Location: MI
Google Talk: asrrin29@gmail.com
Spodi hit it on the nail.

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Sat Apr 19, 2008 1:05 am 
Offline
Regular
User avatar

Joined: Tue Oct 09, 2007 1:40 am
Posts: 93
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 :P
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.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Sat Apr 19, 2008 1:13 am 
Offline
Knowledgeable
User avatar

Joined: Wed Jul 26, 2006 11:22 pm
Posts: 143
Location: Virginia, USA
Aye, Spodi. :D

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.


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Sat Apr 19, 2008 2:39 am 
Offline
Pro

Joined: Mon May 29, 2006 2:58 pm
Posts: 370
time based movement is something that was created many many years ago =)

_________________
Image


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Sat Apr 19, 2008 5:35 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
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. :P

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.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Sat Apr 19, 2008 5:40 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
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?


Image


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Sun Apr 20, 2008 7:13 am 
Offline
Persistant Poster
User avatar

Joined: Wed Nov 29, 2006 11:25 pm
Posts: 860
Location: Ayer
What the fuck are you guys doing to get your FPS so high?

_________________
Image


Top
 Profile  
 
 Post subject: Re: Gameloop optimizing
PostPosted: Sun Apr 20, 2008 11:20 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
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?


Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group