Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Creating object from reading files

This topic is 5330 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am now hard-code my map like this.... Room room1 = new Room(name, description); Room room2 = new Room(name, description); . . . Door dr1 = new Door(room1, room2); . . . map.addRoom(room1); . . . But how can I do it from loading a file to create all these thing?

Share this post

Link to post
Share on other sites
Awww, f***!

I pressed back by accident and it erased my entire message.

Basically I said use XML and TinyXml (find them using Google), and gave an example... but it''s all gone now. Stupid Internet Explorer! :mad: :@


Share this post

Link to post
Share on other sites
ACTUALLY now I use..

Hashtable gameMap = new Hashtable();

SiteFactory siteFactory = new SiteFactory();
File file = new File(fileName);
FileInputStream fis = new FileInputStream(file);

byte[] temp = new byte[(int)file.length()];

String data = new String(temp);
String[] entries = data.split("\r\n");

for(int i=0; i
String[] info = entries.split("\t");


switch ((char)info[0]){

case ''R'':
case ''r'':

Room room = siteFactory.makeRoom(info[2], info[3]);

case ''D'':
case ''d'':

Room room1 = ((Room)gameMap.get(info[2]));
Room room2 = ((Room)gameMap.get(info[3]));
Door door = siteFactory.makeDoor(room1,room2);



return gameMap;

but there is a problem of using Switch, I dunno the problem...

Share this post

Link to post
Share on other sites
Your switch problem is probably caused by not using a break statement between cases. The syntax should be:

switch ( test )
case A:
case B:

case C:

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!