We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I'm finishing my first "big" program in Processing (its like a simple Transit Simulator in 2D using Cellular Automaton), where all the info is saved in an array of objects (objects with some variables and some other objects inside).
Visually its a Grid with an specific color every cell, depending of what is in that cell (a street, a car, a traffic light). You can edit the grid, adding streets and cars and etc using the keyboard.
My question, like the title say, its that i want to have a way to save the edited Grid to a file, to future use (and not having to write it manually in the code or doing it every time).
I guess that all the problem can be summarized in: there is a way to store an object (or an array of objects) to a file for future use.
Sorry for the bad english, not a native speaker, and thank you in advance for your help.
Answers
Would be great to see what your object look like. Could you post some code?
Kf
yeah of course, i guess that with just the classes its ok so here it goes:
sorry for the mix with spanish and english xD i have ro rewrite some parts of the code to make it look clean and pretty xD
The array is a Celda[][] type. (Celda[][] Grid;)
processing has a built in xml library that'll let you read and write xml
https://processing.org/reference/XML.html
similarly for json
https://processing.org/reference/saveJSONArray_.html
the above are both portable and human readable.
(there are binary formats you can use - java can serialise / deserialise java arbitrary objects to/from files. but i'd recommend the xml / json route for ease of debugging)