new map data format and its read/writer

!! UNTESTED !! UNTESTED !! UNTESTED !!
This commit is contained in:
minjaesong
2018-10-03 19:20:11 +09:00
parent 4cfd3b8c45
commit d2b7c76734
10 changed files with 569 additions and 17 deletions

View File

@@ -3,14 +3,23 @@ package net.torvald.terrarum.gameworld
/**
* Created by minjaesong on 2016-01-17.
*/
open class MapLayer(val width: Int, val height: Int) : Iterable<Byte> {
open class MapLayer : Iterable<Byte> {
val width: Int; val height: Int
internal @Volatile var data: ByteArray // in parallel programming: do not trust your register; always read freshly from RAM!
init {
constructor(width: Int, height: Int) {
this.width = width
this.height = height
data = ByteArray(width * height)
}
constructor(width: Int, height: Int, data: ByteArray) {
this.data = data
this.width = width
this.height = height
}
/**
* Returns an iterator over elements of type `T`.