GridInSprite
This commit is contained in:
parent
6305886775
commit
027b4bcc3d
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.render
|
||||
|
||||
@Suppress("unused")
|
||||
data class GridSprite(
|
||||
data class GridInSprite(
|
||||
val parent: AbstractMatterySprite,
|
||||
val width: Float,
|
||||
val height: Float,
|
||||
@ -14,7 +14,7 @@ data class GridSprite(
|
||||
val currentX: Float get() = column * width
|
||||
val currentY: Float get() = row * height
|
||||
|
||||
fun skip(): GridSprite {
|
||||
fun skip(): GridInSprite {
|
||||
column++
|
||||
|
||||
if (column >= columns) {
|
||||
@ -24,37 +24,37 @@ data class GridSprite(
|
||||
return this
|
||||
}
|
||||
|
||||
fun jump(): GridSprite {
|
||||
fun jump(): GridInSprite {
|
||||
row++
|
||||
column = 0
|
||||
return this
|
||||
}
|
||||
|
||||
fun next(): AbstractMatterySprite {
|
||||
val element = parent.subElement(currentX, currentY, width, height)
|
||||
val element = parent.sprite(currentX, currentY, width, height)
|
||||
skip()
|
||||
return element
|
||||
}
|
||||
|
||||
fun reset(): GridSprite {
|
||||
fun reset(): GridInSprite {
|
||||
row = 0
|
||||
column = 0
|
||||
return this
|
||||
}
|
||||
|
||||
fun seek(row: Int, column: Int): GridSprite {
|
||||
fun seek(row: Int, column: Int): GridInSprite {
|
||||
this.row = row
|
||||
this.column = column
|
||||
return this
|
||||
}
|
||||
|
||||
operator fun get(column: Int, row: Int) =
|
||||
parent.subElement(column * width, row * height, width, height)
|
||||
parent.sprite(column * width, row * height, width, height)
|
||||
}
|
||||
|
||||
fun AbstractMatterySprite.subGrid(
|
||||
fun AbstractMatterySprite.grid(
|
||||
width: Float,
|
||||
height: Float,
|
||||
columns: Int = 16,
|
||||
rows: Int = 16,
|
||||
) = GridSprite(this, width, height, columns, rows)
|
||||
) = GridInSprite(this, width, height, columns, rows)
|
Loading…
Reference in New Issue
Block a user