Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (725)
Games in Android Showcase (216)
games submitted by our members
Games in WIP (791)
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  
  3D dungeon crawler  (Read 405 times)
0 Members and 1 Guest are viewing this topic.
Offline Coding17

Senior Newbie


Exp: 1-3 months



« Posted 2017-03-19 22:04:12 »

I'm looking to develop a 3D dungeon crawler, i was wondering how i would implement a map loader using a .txt file. I want the map loader to read the text file and render a wall when it reads "1", and nothing when it reads "0". What would be the best way to go about implementing this feature?
Offline jonjava
« Reply #1 - Posted 2017-03-19 22:30:57 »

There is no best way.

Offline Coding17

Senior Newbie


Exp: 1-3 months



« Reply #2 - Posted 2017-03-19 22:36:40 »

okay... would you be able to give me some sort of idea how to implement this feature?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline orange451

JGO Kernel


Medals: 272
Projects: 5
Exp: 6 years


Your face. Your ass. What's the difference?


« Reply #3 - Posted 2017-03-20 00:35:15 »

Here's a nice post on the best way to read a text file line-by-line:
http://stackoverflow.com/questions/4716503/reading-a-plain-text-file-in-java

Hope that helps.

Hint. Parse each character in each line to figure out which type of object to place.

First Recon. A java made online first person shooter!
Offline SteveSmith
« Reply #4 - Posted 2017-03-20 10:50:50 »

I just happened to have a project open that reads a CSV file (although mine is seperated by tabs, which I find makes things easier).

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
      
      Path path = FileSystems.getDefault().getPath("./data/maps", file);
      List<String> lines = Files.readAllLines(path);

      int y=0;
      for (String line :  lines) {
         String tokens[] = line.split("\t");
         int x = 0;
         for (String t : tokens) {
                                // Do you what you want depending on t.  x and y are the coords.
            x++;
         }
         y++;
      }

Offline Coding17

Senior Newbie


Exp: 1-3 months



« Reply #5 - Posted 2017-03-20 13:00:41 »

Thanks guys for the help Cheesy, i'll see if i can get it working today
Pages: [1]
  ignore  |  Print  
 
 

 
Archive (54 views)
2017-04-27 17:45:51

buddyBro (266 views)
2017-04-05 03:38:00

CopyableCougar4 (689 views)
2017-03-24 15:39:42

theagentd (691 views)
2017-03-24 15:32:08

Rule (734 views)
2017-03-19 12:43:22

Rule (709 views)
2017-03-19 12:42:17

Rule (713 views)
2017-03-19 12:36:21

theagentd (723 views)
2017-03-16 05:07:07

theagentd (656 views)
2017-03-15 22:37:06

theagentd (497 views)
2017-03-15 22:32:18
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!