kotcity4 / kotcity.data / BlockCoordinate

BlockCoordinate

data class BlockCoordinate

The main coordinate system used in this game. Everything is on an X-Y grid and we use this all over the place.

Constructors

<init>

BlockCoordinate(x: Int, y: Int)

The main coordinate system used in this game. Everything is on an X-Y grid and we use this all over the place.

Properties

x

val x: Int

y

val y: Int

Functions

circle

fun circle(radius: Int = 1): List<BlockCoordinate>

distanceTo

fun distanceTo(otherCoordinate: BlockCoordinate): Double

fuzz

fun fuzz(): BlockCoordinate

Used when we want to place something at a coordinate, but not exactly. It returns a coordinate as far away as MAX_BUILDING_SIZE

neighbors

fun neighbors(radius: Int = 1): List<BlockCoordinate>

plus

fun plus(otherCoordinate: BlockCoordinate): BlockCoordinate

Companion Object Functions

iterate

fun iterate(from: BlockCoordinate, to: BlockCoordinate, callback: (BlockCoordinate) -> Unit): Unit

Used to call a function on rectangle of BlockCoordinates