Jump to content

  • Log In with Google      Sign In   
  • Create Account


EmmetCooper

Member Since 26 Aug 2012
Offline Last Active Jul 10 2014 06:01 AM

#5140221 Optimizing Random Generated Terrain Rendering for a Side Scrolling Game

Posted by EmmetCooper on 18 March 2014 - 10:03 PM

You may not NEED to optimize the code. Be sure that you do and measure the cost of your rendering function before you start tinkering with it. If you decide some optimizations are necessary, measure again after you're done to be sure you didn't make the problem worse! smile.png

 

You only see one screen's worth of stuff so rendering the entire world is a waste. Let's say you have X and Y coordinates for your player. You can calculate a rectangle of world coordinates that you should draw by drawing everything within 30 tiles of your player (or whatever number works for your game). Subtract 30 * tileWidth from player.x and add 30 * tileHeight to player.x to get your minX and maxX values. Do the same for your min/max Y's and then only draw the tiles and enemies that are within that range.

 

Here's a post that explains that idea in a little more detail, along with some other tricks for reducing texture swapping costs.

 

http://stackoverflow.com/questions/9877123/xna-culling-performance-issue

 

- Eck

 

As far as serialization goes, it's just a matter of coming up with a logical file format. Since you're using SFML, have a look at the tutorials for user data streams:

 

http://www.sfml-dev.org/tutorials/2.1/system-stream.php

 

If you're saving your "world" it could be as simple as outputting your x and y coordinates along with the tile id into a text file one line at a time.

 

Loading it would be just the opposite. You just create one tile for each line you read in, and add that to your world.

 

There should be PLENTY of tutorials online about file i/o for whatever language you want.

 

- Eck


Thanks alot. :D This is a good start on fixing this issue. :) I will try and update if it's fixed. :D




#4980656 CryEngine 3 or Unity 3d?

Posted by EmmetCooper on 16 September 2012 - 10:40 AM

actually we're not yet thinking for how much we'll charge for our game..our number one concern for now is the quality of the graphics and the realism of the AIs. And we are still researching on which engine is much better,.. How about UDK?.. It also have many cool and very useful features though i haven't really used it yet. I saw it's youtube vid 'Unreal Engine 3 (2012) feature highlights' ...the physics and graphics is very amazing..as to what platform we'll use, xbox is just an option..but we are prioritizing a PC game..


#4973550 Novice Game Developers Need help...

Posted by EmmetCooper on 26 August 2012 - 01:44 PM

I'am currently in 2nd year college and i need advice and/or help about game programming.
The problem is that we're complete novice to the whole game development community and we kinda need some heads up of what we need to know to be able to start in game development.Our thesis project is also about game development so we're in a big mess. Any help or guide will be greatly appriciated.


Thank you so much guys..peace ^^v


#4973548 Need help...

Posted by EmmetCooper on 26 August 2012 - 01:42 PM

I'am currently in 2nd year college and i need advice and/or help about game programming.
The problem is that we're complete novice to the whole game development community and we kinda need some heads up of what we need to know to be able to start in game development.Our thesis project is also about game development so we're in a big mess. Any help or guide will be greatly appriciated.


Thank you so much guys..peace ^^v


PARTNERS