Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Level Streaming


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Elrinth   Members   -  Reputation: 130

Like
0Likes
Like

Posted 14 October 2012 - 04:15 PM

Hi!

I'm working on a level editor for a 2D game atm, and I'd like to have the file you're editing to stream from/to a file or many files.

I've got Resolution 800x600.
I make sections outta 256x256 pixels. Where there are 16x16 pixels large tiles. Which makes 256 tiles per section.

NrOfSectionsX = ceil(resolutionX / sectionXpixels) + 2
NrOfSectionsY = ceil(resolutionY / sectionYpixels) + 2
i add +2 so I can get sections -1 and +1 outside of the screen so I got that in memory and can display it instantly without having to load anything.
However the problem comes when I wanna load sections outside the screen.
I store each section as it's own file. Where I call them for example: 0,0,0.txt being the upper left screen which can be seen when starting.
Then next is called 1,0,0.txt which is 256 pixels to the right of previous section.

Problem is. There's choppiness when I load these sections which are outside of the screen. It happens because I write sections to disk which aren't important anymore. and I read sections which become important.
So I put the level save/load in separate thread. Sure there is no choppiness any longer.. However, there is delay before they are presented.

So I thought, hmmm what about having one large file containing all the level data with pointer-data in the beginning of the file which says where in the file each section is... Sure that works.. However, what happens when data is changed? Yes that's right, it doesn't work, because you cannot edit stuff you've already written to the file.

I thought about putting it all into a zip file aswell. But there seems to be no libraries which can fix my problems.

Now I'm asking if you guys have any good idea to fix this problem?

If I remove the whole file i/o then my program runs smooth at 1000 fps. But sadly no sections are stored which kinda sucks.

Visual example of what I'm trying to deal with:

Edited by Elrinth, 14 October 2012 - 04:19 PM.


Sponsor:

#2 Elrinth   Members   -  Reputation: 130

Like
0Likes
Like

Posted 14 October 2012 - 05:52 PM

Well I figured out why my file i/o was so slow... I rewrote the code to load / save the sections via FILE *fp and use fgetc and fputc.. This was soooo much faster... Before I had to convert strings into values this was probably slowing down my code considerably... Now it's working flawlessly even if I move the camera really fast :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS