Stygia: End of Day 2

At the end of day 2, where am I?

To be frank, I’m behind, as I spent most of today sorting out saving/continuing, but to be honest, as I’ve never managed to do this before for any roguelike I’ve started to write, I’m quite chuffed about this:

More details of my progress on Day 2 can be found here.

7 thoughts on “Stygia: End of Day 2”

  1. How did you implement save/load?

    I’m using binary serialization, fast and you can use it with any object:

    public class Persistence where T : class {
    public T Load( string path )
    {
    var formatter = new BinaryFormatter();
    var stream = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Read );
    var obj = (T)formatter.Deserialize(stream);
    stream.Close();
    return obj;
    }

    public void Save( T obj, string path )
    {
    var formatter = new BinaryFormatter();
    var stream = new FileStream( path, FileMode.Create, FileAccess.Write, FileShare.None );
    formatter.Serialize( stream, obj );
    stream.Close();
    }
    }

    Then:

    var mapPersistence = new Persistence();
    var map = mapPersistence.Load( “map.dat” );
    //do something to map
    mapPersistence.Save( map, “map.dat” );

Leave a Reply