top of page
Search
kimbarcia2207yc

Tropic Storm Cheats Unlimited Energy







1 item was added to your cart. Category: Heavy Transport. . .Q: How to transform a structure from a file to an object? A while back I was building an engine in Java for a game and I had a layer that was responsible for building a list of "tiles" and a tile class which had fields to hold it's coordinates and dimensions, color, and behavior. There was a tilemap.txt file with a bunch of lines to hold the tile positions and the tile classes. The tilemap.txt was so simple that I could easily read it in into a List, and then get the object representation, but this didn't stop me from having a hard time mapping the file to my object. The problem was, I needed to keep track of the tileMap.txt file from which it was loaded, so I made the tilemap.txt into a "Tilemap" object with a field that could reference the file that it was loaded from and be loaded from in future. The problem with this, is that it only works if the same file is used in the same program. Now that the tilemap.txt file is separated out into a new class, I can't easily reuse the same file. Here's what I want to do. Given: A tilemap.txt file that holds the map of tiles Goal: A list of TileMap objects that I can use to create the tile map. And that's how I wrote a simple loader. public class TileMapLoader { private File file; public TileMap load(String fileName) { this.file = new File(fileName); return new TileMap(file); } public class TileMap { private File file; public TileMap(File file) { this.file = file; } private static final List tileMaps; static { tileMaps = new ArrayList(50); load("tilemap.txt"); } public static List getTileMaps() { return tileMaps; } public be359ba680


Related links:

1 view0 comments

Comentários


bottom of page