Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  landscape data in files  (Read 1958 times)
0 Members and 1 Guest are viewing this topic.
Offline Therion__

Junior Devvie





« Posted 2008-11-16 19:45:27 »

hello

i  work on an adventure game and i am now on an
complicate point. i got my map in clusters  int (20x20x3(height,ground,special )
5x5 clusters are in memory (100x100)

my first (very bad idea) was to save each cluster as seperate file
(i produce 40000 files, very bad idea)

my idea was, when the char/camera leaves the inner space the next 5 clusters
are reloaded (north,south,east,west), the files are working..but 40000 files is tooo much.

did anybody got an idea how i can fix this problem?

i think about one large file and adress direct the data (read/save) that i need

open the file...
for (int z=0;z<100;z++)
{
for (int x=0;x<100;x++)
{
file_position=((cluster_z+z)*20000)+cluster_x+x
read/write
}
}

is it possible, is it good or bad idea
and what is todo, i am not very experienced with file io stuff?

thanks for any answer Smiley
Offline moogie

JGO Knight


Medals: 13
Projects: 6
Exp: 10 years


Java games rock!


« Reply #1 - Posted 2008-11-16 20:30:52 »

What is very bad? is there a performance issue? Sure there are better ways to do what you want, but if you are not experiencing any slow downs is there a problem?

You could have a background thread pre-loading the clusters surrounding inner space clusters. This means when the char leaves the inner space clusters, the appropriate clusters are already loaded. This is slightly inefficent as you are loading extra clusters which may not be needed.
Offline Therion__

Junior Devvie





« Reply #2 - Posted 2008-11-16 20:40:41 »

hello moogie Smiley

i got no performance problem at moment,
i only reload 5 cluster files when camera is leaving inner part..
the rest is moved in memory.

but the question is, is it good to use so much files
(40000 files with each 4-8k size)
or are there better ways
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #3 - Posted 2008-11-16 21:16:06 »

If you care about storage size, then yes having that many small files may waste a lot of disk space (depending on the file format & cluster size the disc is using...)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 832
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2008-11-16 21:17:39 »

It depends on the filesystem. Both in performance and in actual space usage. (round up to 4k, on most systems)


Furter, you're putting (some) strain on your directory file listing, but I guess the OS will cache that into RAM. Still, if there is no reason to split your data over a few thousand files, why would you? Using a RandomAccessFile is probably a much better approach. You can manipulate the filepointer with seek(..)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Therion__

Junior Devvie





« Reply #5 - Posted 2008-11-16 21:21:54 »

RandomAccessFile sounds like for what i search for.

is there any online tutorial for that?

Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 832
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2008-11-16 21:24:16 »

javadocs

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Therion__

Junior Devvie





« Reply #7 - Posted 2008-11-16 21:32:30 »

much thanks Smiley
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

SHC (24 views)
2014-11-25 12:00:59

SHC (23 views)
2014-11-25 11:53:45

Norakomi (19 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (68 views)
2014-11-07 19:57:14
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!