From 23f09e8d214b0f11792788ea4883433f055cc266 Mon Sep 17 00:00:00 2001 From: Ferdinand Saurenbach Date: Tue, 1 Apr 2025 18:20:50 +0200 Subject: [PATCH 1/8] All pieces --- src/commonMain/kotlin/Block.kt | 96 ++++++++++++++++++++++++---------- src/commonMain/kotlin/main.kt | 2 +- 2 files changed, 68 insertions(+), 30 deletions(-) diff --git a/src/commonMain/kotlin/Block.kt b/src/commonMain/kotlin/Block.kt index d91c94d..ea33cd3 100644 --- a/src/commonMain/kotlin/Block.kt +++ b/src/commonMain/kotlin/Block.kt @@ -6,21 +6,59 @@ import korlibs.math.geom.* import kotlin.math.* enum class BlockType { - ONEbyONE, TWObyTWO, BigL, - // OnebyThree, TWObyTHREE, THREEbyTHREE, - - -} -enum class BlockRotation { - zero, quarter, half, threequarters -} -object BlockRotationHelper { - fun getRandomRotation(): BlockRotation { - val blockRotations = BlockRotation.values().toList() - return blockRotations.random() // Picks a random BlockType - } + // Single block + ONE_BY_ONE, + + // Straight blocks (all rotations are the same) + ONE_BY_TWO, + TWO_BY_ONE, + ONE_BY_THREE, + THREE_BY_ONE, + ONE_BY_FOUR, + FOUR_BY_ONE, + ONE_BY_FIVE, + FIVE_BY_ONE, + + // Square blocks (all rotations are the same) + TWO_BY_TWO, + THREE_BY_THREE, + + // L-Shaped blocks (all rotations) + L_2X2_0, + L_2X2_90, + L_2X2_180, + L_2X2_270, + + L_2X3_0, + L_2X3_90, + L_2X3_180, + L_2X3_270, + + L_3X3_0, + L_3X3_90, + L_3X3_180, + L_3X3_270, + + // T-Shaped blocks (all rotations) + T_2X3_0, + T_2X3_90, + T_2X3_180, + T_2X3_270, + + // Rectangle blocks (all rotations) + TWO_BY_THREE_0, + TWO_BY_THREE_90, + THREE_BY_TWO_0, + THREE_BY_TWO_90, + + // S-Shaped blocks (all rotations) + S_2X3_0, + S_2X3_90, + S_2X3_180, + S_2X3_270 } + enum class StartPosition { LEFT, MIDDLE, RIGHT } @@ -46,10 +84,10 @@ object BlockColors { } } -fun Container.block(color: RGBA, blockType: BlockType, startPosition: StartPosition, rotation: BlockRotation) = - Block(color, blockType, startPosition, rotation).addTo(this) +fun Container.block(color: RGBA, blockType: BlockType, startPosition: StartPosition) = + Block(color, blockType, startPosition).addTo(this) -class Block(private var color: RGBA, blockType: BlockType, startPosition: StartPosition, rotation: BlockRotation) : Container() { +class Block(private var color: RGBA, blockType: BlockType, startPosition: StartPosition) : Container() { private var placed: Boolean = false init { @@ -60,18 +98,13 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP StartPosition.RIGHT -> this.position(380, 680) } when (blockType) { - BlockType.ONEbyONE -> theWhole.roundRect(Size(cs, cs), RectCorners(5f), fill = color) - BlockType.TWObyTWO -> twobytwo(theWhole) - BlockType.BigL -> bigL(theWhole) - else -> throw error("Block has to be defined") - } - when (rotation){ - BlockRotation.zero -> this.rotation = Angle.ZERO - BlockRotation.quarter -> this.rotation = Angle.QUARTER - BlockRotation.half -> this.rotation = Angle.HALF - BlockRotation.threequarters -> this.rotation = 270.degrees + BlockType.ONE_BY_ONE -> theWhole.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + BlockType.TWO_BY_TWO -> twobytwo(theWhole) + BlockType.L_3X3_0 -> bigL(theWhole) + else -> bigL(theWhole) } this.scale(0.5) + var closeable: DraggableCloseable? = null closeable = this.draggableCloseable { if (it.start) { @@ -87,13 +120,13 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP println("viewNextX: ${round(it.viewNextX).toInt()}, viewNextY: ${round(it.viewNextY).toInt()}") val blockPosition1 = Point( - convertToCoordX(round(it.view.globalPos.x).toInt()).toInt(), convertToCoordY( + convertToCoordX(round(it.view.globalPos.x).toInt()), convertToCoordY( round(it.view.globalPos.y).toInt() ).toInt() ) for (field in fields) { val fieldPosition = Point( - convertToCoordX(round(field.globalPos.x).toInt()).toInt(), convertToCoordY( + convertToCoordX(round(field.globalPos.x).toInt()), convertToCoordY( round(field.globalPos.y).toInt() ).toInt() ) @@ -143,6 +176,7 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP private fun twobytwo(container: Container) { val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(one) val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(three) @@ -150,13 +184,17 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } private fun bigL(container: Container) { - val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + //container.rotation = 90.degrees + container.size = Size(cs*3,cs*3) + container.rotation(90.degrees) + val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).anchor(Anchor.TOP_LEFT) val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(three) .alignTopToBottomOf(two) container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(four) .alignTopToBottomOf(two) + } } diff --git a/src/commonMain/kotlin/main.kt b/src/commonMain/kotlin/main.kt index 09cf272..bc7370e 100644 --- a/src/commonMain/kotlin/main.kt +++ b/src/commonMain/kotlin/main.kt @@ -130,7 +130,7 @@ fun createPieces(container: Container) { } } val color = BlockColors.getRandomColor() - var c = container.block(color, BlockTypeHelper.getRandomBlockType(), location!!, BlockRotationHelper.getRandomRotation()) + var c = container.block(color, BlockTypeHelper.getRandomBlockType(), location!!) allblocks.add(c) } From 3a138cb917f1208001365d78a03abfed07bcba6c Mon Sep 17 00:00:00 2001 From: Ferdinand Saurenbach Date: Fri, 11 Apr 2025 21:50:52 +0200 Subject: [PATCH 2/8] kind of works ? --- src/commonMain/kotlin/Block.kt | 48 ++++++++++++++++++++-------------- src/commonMain/kotlin/main.kt | 19 ++++++++++---- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/commonMain/kotlin/Block.kt b/src/commonMain/kotlin/Block.kt index ea33cd3..f2e1e3f 100644 --- a/src/commonMain/kotlin/Block.kt +++ b/src/commonMain/kotlin/Block.kt @@ -89,16 +89,17 @@ fun Container.block(color: RGBA, blockType: BlockType, startPosition: StartPosit class Block(private var color: RGBA, blockType: BlockType, startPosition: StartPosition) : Container() { private var placed: Boolean = false - + private var master:RoundRect? = null init { + val theWhole = this // Was originally a container() but should work like this too when (startPosition) { - StartPosition.LEFT -> this.position(-40, 680) - StartPosition.MIDDLE -> this.position(170, 680) - StartPosition.RIGHT -> this.position(380, 680) + StartPosition.LEFT -> this.position(windowWidth*0.3, windowHeight*0.8) + StartPosition.MIDDLE -> this.position(windowWidth*0.6, windowHeight*0.8) + StartPosition.RIGHT -> this.position(windowWidth*0.9, windowHeight*0.8) } when (blockType) { - BlockType.ONE_BY_ONE -> theWhole.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + BlockType.ONE_BY_ONE -> theWhole.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED) == master BlockType.TWO_BY_TWO -> twobytwo(theWhole) BlockType.L_3X3_0 -> bigL(theWhole) else -> bigL(theWhole) @@ -106,7 +107,9 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP this.scale(0.5) var closeable: DraggableCloseable? = null - closeable = this.draggableCloseable { + closeable = this.draggableCloseable { it -> + println("viewNextX: ${round(master!!.getPositionRelativeTo(first!!).x).toInt()}, viewNextY: ${round(master!!.getPositionRelativeTo(first!!).y).toInt()}") + if (it.start) { println(this.zIndex) @@ -117,18 +120,17 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP if (it.end) { this.zIndex(0) println("dragging ended: snapping!") - println("viewNextX: ${round(it.viewNextX).toInt()}, viewNextY: ${round(it.viewNextY).toInt()}") - + println("viewNextX: ${master!!.globalPos.x}, viewNextY: ${master!!.globalPos.y}") val blockPosition1 = Point( - convertToCoordX(round(it.view.globalPos.x).toInt()), convertToCoordY( - round(it.view.globalPos.y).toInt() - ).toInt() + convertToCoordX(round(master!!.globalPos.x).toInt()), convertToCoordY( + round(master!!.globalPos.y).toInt() + ) ) for (field in fields) { val fieldPosition = Point( convertToCoordX(round(field.globalPos.x).toInt()), convertToCoordY( round(field.globalPos.y).toInt() - ).toInt() + ) ) //println("Block position converted ${blockPosition1.x}, ${blockPosition1.y}") @@ -136,7 +138,9 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP if (blockPosition1 == fieldPosition && checkIfCorrectlyPlaced(this)) { println("Placed correctly snapping:") - it.view.position(field.globalPos) + field.colorMul = Colors.RED + master!!.position(field.globalPos) + println("this global: ${this.globalPos}") this.forEachChild { sContainer!!.placedBlock(color, convertToCoordX(it.globalPos.x.toInt()), convertToCoordY(it.globalPos.y.toInt())) //var oc = occupiedFields.find { it.fieldX == convertToCoordX(it.globalPos.x.toInt())&& it.fieldY == convertToCoordY(it.globalPos.y.toInt()) } @@ -175,8 +179,8 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } private fun twobytwo(container: Container) { - val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) - + val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED) + master = one container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(one) val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(three) @@ -186,14 +190,20 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP private fun bigL(container: Container) { //container.rotation = 90.degrees container.size = Size(cs*3,cs*3) - container.rotation(90.degrees) - val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).anchor(Anchor.TOP_LEFT) + /*val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) - val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) + val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED).alignTopToBottomOf(two) + master = three val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(three) .alignTopToBottomOf(two) container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(four) - .alignTopToBottomOf(two) + .alignTopToBottomOf(two)*/ + val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED) + master = one + val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) + val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) + val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(one) + val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(four) } diff --git a/src/commonMain/kotlin/main.kt b/src/commonMain/kotlin/main.kt index bc7370e..c1d9453 100644 --- a/src/commonMain/kotlin/main.kt +++ b/src/commonMain/kotlin/main.kt @@ -1,3 +1,4 @@ +import korlibs.crypto.* import korlibs.image.color.* import korlibs.image.font.* import korlibs.image.paint.* @@ -8,14 +9,18 @@ import korlibs.korge.input.* import korlibs.korge.view.* import korlibs.korge.view.align.* import korlibs.math.geom.* +import korlibs.render.* import kotlin.math.* import kotlin.properties.* +import kotlin.random.* val rows = mutableListOf>>() var font: BitmapFont by Delegates.notNull() var backgroundField: RoundRect? = null var fields = mutableListOf() -var fieldSize = Size(560, 560) +var windowWidth = 580*1.9.toInt() +var windowHeight = 740*1.9.toInt() +var fieldSize = Size(windowWidth/1.4, windowWidth/1.4) var cs = fieldSize.height / 8 var leftOccupied = false var middleOccupied = false @@ -24,9 +29,12 @@ var sContainer: Container? = null val occupiedFields = mutableListOf() val allblocks = mutableListOf() var placedBlocks = mutableListOf() +val random: Random = SecureRandom +var first: Field? = null suspend fun main() = Korge( - virtualSize = Size(480, 853), - + //windowHeight = windowHeight, + windowSize = Size(windowWidth,windowHeight), + //windowWidth = windowWidth, title = "Block Smash", bgcolor = Colors["#4c65a4"], /** @@ -50,10 +58,10 @@ suspend fun main() = Korge( backgroundField = roundRect(fieldSize, RectCorners(5f), Colors["#202443"]) backgroundField!!.centerOnStage() - backgroundField!!.y -= 70 - convertToRealX(5) + //backgroundField!!.y -= 70 populateField(this) + //val testBlock = block(BlockColors.Red, BlockType.TWObyTWO, StartPosition.LEFT) createPieces(this) @@ -88,6 +96,7 @@ fun populateField(container: Container) { rows[field.fieldY][field.fieldX].add(field) } + first = fields[0] println(rows) } From 614304860d7d9e7bce54bd98026f0dcb1eb5f50f Mon Sep 17 00:00:00 2001 From: Ferdinand Saurenbach Date: Fri, 11 Apr 2025 21:57:36 +0200 Subject: [PATCH 3/8] better implementation but still bad --- src/commonMain/kotlin/Block.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/commonMain/kotlin/Block.kt b/src/commonMain/kotlin/Block.kt index f2e1e3f..734a90d 100644 --- a/src/commonMain/kotlin/Block.kt +++ b/src/commonMain/kotlin/Block.kt @@ -142,6 +142,9 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP master!!.position(field.globalPos) println("this global: ${this.globalPos}") this.forEachChild { + if (it == master) return@forEachChild + println("one child") + sContainer!!.placedBlock(color, convertToCoordX(it.globalPos.x.toInt()), convertToCoordY(it.globalPos.y.toInt())) //var oc = occupiedFields.find { it.fieldX == convertToCoordX(it.globalPos.x.toInt())&& it.fieldY == convertToCoordY(it.globalPos.y.toInt()) } //occupiedFields.remove(oc) From 4a15f29604bed70434e358816fe5df5beaa8f8ec Mon Sep 17 00:00:00 2001 From: Ferdinand Saurenbach Date: Mon, 14 Apr 2025 11:26:23 +0200 Subject: [PATCH 4/8] update --- src/commonMain/kotlin/Block.kt | 101 +++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 30 deletions(-) diff --git a/src/commonMain/kotlin/Block.kt b/src/commonMain/kotlin/Block.kt index 734a90d..2f440eb 100644 --- a/src/commonMain/kotlin/Block.kt +++ b/src/commonMain/kotlin/Block.kt @@ -3,6 +3,8 @@ import korlibs.korge.input.* import korlibs.korge.view.* import korlibs.korge.view.align.* import korlibs.math.geom.* +import korlibs.math.random.* +import kotlin.collections.random import kotlin.math.* enum class BlockType { @@ -94,24 +96,25 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP val theWhole = this // Was originally a container() but should work like this too when (startPosition) { - StartPosition.LEFT -> this.position(windowWidth*0.3, windowHeight*0.8) - StartPosition.MIDDLE -> this.position(windowWidth*0.6, windowHeight*0.8) - StartPosition.RIGHT -> this.position(windowWidth*0.9, windowHeight*0.8) + StartPosition.LEFT -> this.position(windowWidth*0.2, windowHeight*0.8) + StartPosition.MIDDLE -> this.position(windowWidth*0.4, windowHeight*0.8) + StartPosition.RIGHT -> this.position(windowWidth*0.6, windowHeight*0.8) } when (blockType) { - BlockType.ONE_BY_ONE -> theWhole.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED) == master + BlockType.ONE_BY_ONE -> onebyone(theWhole) BlockType.TWO_BY_TWO -> twobytwo(theWhole) BlockType.L_3X3_0 -> bigL(theWhole) - else -> bigL(theWhole) + else -> onebyone(theWhole) + //else -> bigL(theWhole) } this.scale(0.5) var closeable: DraggableCloseable? = null closeable = this.draggableCloseable { it -> - println("viewNextX: ${round(master!!.getPositionRelativeTo(first!!).x).toInt()}, viewNextY: ${round(master!!.getPositionRelativeTo(first!!).y).toInt()}") + //println("viewNextX: ${round(master!!.getPositionRelativeTo(first!!).x).toInt()}, viewNextY: ${round(master!!.getPositionRelativeTo(first!!).y).toInt()}") if (it.start) { - + println("master: $master") println(this.zIndex) this.zIndex(99) @@ -138,11 +141,12 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP if (blockPosition1 == fieldPosition && checkIfCorrectlyPlaced(this)) { println("Placed correctly snapping:") - field.colorMul = Colors.RED - master!!.position(field.globalPos) + //field.colorMul = Colors.RED + //master!!.position(field.globalPos) + master!!.globalPos = field.globalPos println("this global: ${this.globalPos}") this.forEachChild { - if (it == master) return@forEachChild + //if (it == master) return@forEachChild println("one child") sContainer!!.placedBlock(color, convertToCoordX(it.globalPos.x.toInt()), convertToCoordY(it.globalPos.y.toInt())) @@ -161,6 +165,7 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP addNewPieces() allblocks.remove(this) println("count:"+ occupiedFields.count()) + master?.removeFromParent() this.removeFromParent() checkForBlast() @@ -170,9 +175,9 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } if (!placed) { when (startPosition) { - StartPosition.LEFT -> this.position(-40, 680) - StartPosition.MIDDLE -> this.position(170, 680) - StartPosition.RIGHT -> this.position(380, 680) + StartPosition.LEFT -> this.position(windowWidth*0.3, windowHeight*0.7) + StartPosition.MIDDLE -> this.position(windowWidth*0.6, windowHeight*0.7) + StartPosition.RIGHT -> this.position(windowWidth*0.9, windowHeight*0.7) } } } @@ -180,7 +185,12 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } } - + private fun onebyone(container: Container){ + val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + master = one + println("dysfaffdsaf") + println("mastertest: $master") + } private fun twobytwo(container: Container) { val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED) master = one @@ -191,25 +201,56 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } private fun bigL(container: Container) { - //container.rotation = 90.degrees - container.size = Size(cs*3,cs*3) - /*val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) - val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) - val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED).alignTopToBottomOf(two) - master = three - val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(three) - .alignTopToBottomOf(two) - container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(four) - .alignTopToBottomOf(two)*/ - val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED) - master = one - val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) - val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) - val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(one) - val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(four) + val rotation = random.get(range = 0..3) + println("Rotation: $rotation") + container.size = Size(cs * 3, cs * 3) + + when (rotation) { + 0 -> { + // Original: vertical line + rightward tail + val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) + val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) + val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(three) + val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(four) + master = three + } + 1 -> { + // 90°: horizontal line + upward tail + val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(one) + val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(two) + val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) + val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(four) + master = two + } + + 2 -> { + // 180°: vertical line + leftward tail + val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) + val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) + val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignRightToLeftOf(one) + val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignRightToLeftOf(four) + master = three + } + + 3 -> { + // 270°: horizontal line + downward tail + val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) + val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(one) + val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(two) + val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignBottomToTopOf(two) + val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignBottomToTopOf(four) + master = two + } + } + + //master!!.color = Colors.RED } + } fun checkIfCorrectlyPlaced(wholeBlock: Block): Boolean { From 8749e6c7d8afd2e8295fc18599ca8c3f55a07939 Mon Sep 17 00:00:00 2001 From: Ferdinand Saurenbach Date: Mon, 14 Apr 2025 11:38:19 +0200 Subject: [PATCH 5/8] clean --- src/commonMain/kotlin/Block.kt | 49 ++++++++++++++++-------------- src/commonMain/kotlin/main.kt | 54 +++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 39 deletions(-) diff --git a/src/commonMain/kotlin/Block.kt b/src/commonMain/kotlin/Block.kt index 2f440eb..641b450 100644 --- a/src/commonMain/kotlin/Block.kt +++ b/src/commonMain/kotlin/Block.kt @@ -91,20 +91,21 @@ fun Container.block(color: RGBA, blockType: BlockType, startPosition: StartPosit class Block(private var color: RGBA, blockType: BlockType, startPosition: StartPosition) : Container() { private var placed: Boolean = false - private var master:RoundRect? = null + private var master: RoundRect? = null + init { val theWhole = this // Was originally a container() but should work like this too when (startPosition) { - StartPosition.LEFT -> this.position(windowWidth*0.2, windowHeight*0.8) - StartPosition.MIDDLE -> this.position(windowWidth*0.4, windowHeight*0.8) - StartPosition.RIGHT -> this.position(windowWidth*0.6, windowHeight*0.8) + StartPosition.LEFT -> this.position(windowWidth * 0.2, windowHeight * 0.8) + StartPosition.MIDDLE -> this.position(windowWidth * 0.4, windowHeight * 0.8) + StartPosition.RIGHT -> this.position(windowWidth * 0.6, windowHeight * 0.8) } when (blockType) { - BlockType.ONE_BY_ONE -> onebyone(theWhole) - BlockType.TWO_BY_TWO -> twobytwo(theWhole) + BlockType.ONE_BY_ONE -> oneByOne(theWhole) + BlockType.TWO_BY_TWO -> twoByTwo(theWhole) BlockType.L_3X3_0 -> bigL(theWhole) - else -> onebyone(theWhole) + else -> bigL(theWhole) //else -> bigL(theWhole) } this.scale(0.5) @@ -125,13 +126,13 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP println("dragging ended: snapping!") println("viewNextX: ${master!!.globalPos.x}, viewNextY: ${master!!.globalPos.y}") val blockPosition1 = Point( - convertToCoordX(round(master!!.globalPos.x).toInt()), convertToCoordY( + convertToCoordinateX(round(master!!.globalPos.x).toInt()), convertToCoordinateY( round(master!!.globalPos.y).toInt() ) ) for (field in fields) { val fieldPosition = Point( - convertToCoordX(round(field.globalPos.x).toInt()), convertToCoordY( + convertToCoordinateX(round(field.globalPos.x).toInt()), convertToCoordinateY( round(field.globalPos.y).toInt() ) ) @@ -149,7 +150,11 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP //if (it == master) return@forEachChild println("one child") - sContainer!!.placedBlock(color, convertToCoordX(it.globalPos.x.toInt()), convertToCoordY(it.globalPos.y.toInt())) + sContainer!!.placedBlock( + color, + convertToCoordinateX(it.globalPos.x.toInt()), + convertToCoordinateY(it.globalPos.y.toInt()) + ) //var oc = occupiedFields.find { it.fieldX == convertToCoordX(it.globalPos.x.toInt())&& it.fieldY == convertToCoordY(it.globalPos.y.toInt()) } //occupiedFields.remove(oc) //println("removing $oc") @@ -163,8 +168,8 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } //println("Left: $leftOccupied, middle: $middleOccupied, right: $rightOccupied") addNewPieces() - allblocks.remove(this) - println("count:"+ occupiedFields.count()) + allBlocks.remove(this) + println("count:" + occupiedFields.count()) master?.removeFromParent() this.removeFromParent() checkForBlast() @@ -175,9 +180,9 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } if (!placed) { when (startPosition) { - StartPosition.LEFT -> this.position(windowWidth*0.3, windowHeight*0.7) - StartPosition.MIDDLE -> this.position(windowWidth*0.6, windowHeight*0.7) - StartPosition.RIGHT -> this.position(windowWidth*0.9, windowHeight*0.7) + StartPosition.LEFT -> this.position(windowWidth * 0.3, windowHeight * 0.7) + StartPosition.MIDDLE -> this.position(windowWidth * 0.6, windowHeight * 0.7) + StartPosition.RIGHT -> this.position(windowWidth * 0.9, windowHeight * 0.7) } } } @@ -185,13 +190,13 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } } - private fun onebyone(container: Container){ + + private fun oneByOne(container: Container) { val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) master = one - println("dysfaffdsaf") - println("mastertest: $master") } - private fun twobytwo(container: Container) { + + private fun twoByTwo(container: Container) { val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = Colors.RED) master = one container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(one) @@ -260,13 +265,13 @@ fun checkIfCorrectlyPlaced(wholeBlock: Block): Boolean { for (block in wholeBlock.children) { val blockPosition1 = Point( - convertToCoordX(round(block.globalPos.x).toInt()), convertToCoordY( + convertToCoordinateX(round(block.globalPos.x).toInt()), convertToCoordinateY( round(block.globalPos.y).toInt() ) ) for (field in fields) { val fieldPosition = Point( - convertToCoordX(round(field.globalPos.x).toInt()), convertToCoordY( + convertToCoordinateX(round(field.globalPos.x).toInt()), convertToCoordinateY( round(field.globalPos.y).toInt() ) ) @@ -286,7 +291,7 @@ fun checkIfCorrectlyPlaced(wholeBlock: Block): Boolean { field.occupied = true } } - println("test passed: ${testsPassed==testsToPass}") + println("test passed: ${testsPassed == testsToPass}") return testsPassed == testsToPass } diff --git a/src/commonMain/kotlin/main.kt b/src/commonMain/kotlin/main.kt index c1d9453..d56bd4c 100644 --- a/src/commonMain/kotlin/main.kt +++ b/src/commonMain/kotlin/main.kt @@ -9,7 +9,6 @@ import korlibs.korge.input.* import korlibs.korge.view.* import korlibs.korge.view.align.* import korlibs.math.geom.* -import korlibs.render.* import kotlin.math.* import kotlin.properties.* import kotlin.random.* @@ -18,22 +17,22 @@ val rows = mutableListOf>>() var font: BitmapFont by Delegates.notNull() var backgroundField: RoundRect? = null var fields = mutableListOf() -var windowWidth = 580*1.9.toInt() -var windowHeight = 740*1.9.toInt() -var fieldSize = Size(windowWidth/1.4, windowWidth/1.4) +var windowWidth = 580 * 1.9.toInt() +var windowHeight = 740 * 1.9.toInt() +var fieldSize = Size(windowWidth / 1.4, windowWidth / 1.4) var cs = fieldSize.height / 8 var leftOccupied = false var middleOccupied = false var rightOccupied = false var sContainer: Container? = null val occupiedFields = mutableListOf() -val allblocks = mutableListOf() +val allBlocks = mutableListOf() var placedBlocks = mutableListOf() val random: Random = SecureRandom var first: Field? = null suspend fun main() = Korge( //windowHeight = windowHeight, - windowSize = Size(windowWidth,windowHeight), + windowSize = Size(windowWidth, windowHeight), //windowWidth = windowWidth, title = "Block Smash", bgcolor = Colors["#4c65a4"], @@ -41,7 +40,7 @@ suspend fun main() = Korge( `gameId` is associated with the location of storage, which contains `history` and `best`. see [Views.realSettingsFolder] */ - gameId = "io.github.sauronbach.blockSmash", + gameId = "de.sauronbach.blockSmash", forceRenderEveryFrame = false, // Optimization to reduce battery usage! ) { val background = LinearGradientPaint( @@ -77,19 +76,17 @@ fun populateField(container: Container) { fields.add(f) f.onClick { - println("YOU CLICKED ON ${f.fieldX} ${f.fieldY}, with the real coords: ${f.realX} ${f.realY}") - println("Converted to realX: ${convertToCoordX(f.fieldX)}, realY: ${convertToCoordY(f.fieldY)}") + println("YOU CLICKED ON ${f.fieldX} ${f.fieldY}, with the real Coordinates: ${f.realX} ${f.realY}") + println("Converted to realX: ${convertToCoordinateX(f.fieldX)}, realY: ${convertToCoordinateY(f.fieldY)}") } } } for (field in fields) { - // Ensure that the rows list has enough sublists to accommodate all Y values while (rows.size <= field.fieldY) { rows.add(mutableListOf()) } - // Ensure that each row has enough sublists to accommodate all X values while (rows[field.fieldY].size <= field.fieldX) { rows[field.fieldY].add(mutableListOf()) } @@ -110,11 +107,11 @@ fun convertToRealY(fieldCoordinate: Int): Number { return backgroundField!!.y + cs * fieldCoordinate } -fun convertToCoordX(realX: Int): Int { +fun convertToCoordinateX(realX: Int): Int { return round((realX - backgroundField!!.x) / cs).toInt() } -fun convertToCoordY(realY: Int): Int { +fun convertToCoordinateY(realY: Int): Int { return round((realY - backgroundField!!.y) / cs).toInt() } @@ -139,8 +136,8 @@ fun createPieces(container: Container) { } } val color = BlockColors.getRandomColor() - var c = container.block(color, BlockTypeHelper.getRandomBlockType(), location!!) - allblocks.add(c) + val c = container.block(color, BlockTypeHelper.getRandomBlockType(), location!!) + allBlocks.add(c) } } @@ -163,7 +160,31 @@ fun checkForBlast() { println("Row: $rowY, counter: $counter") if (counter == 8) { for (block in checkedBlocks) { - var occupiedField = fields.find { it.pos == block.pos } + val occupiedField = fields.find { it.pos == block.pos } + //println("Removing occupied field:$occupiedField") + block.removeFromParent() + occupiedFields.remove(occupiedField) + placedBlocks.remove(block) + occupiedField?.occupied = false + + } + + } + checkedBlocks.clear() + } + for (columnX in 0 until 8) { + var counter = 0 + val checkedBlocks = mutableListOf() + for (placedBlock in placedBlocks) { + if (placedBlock.fieldX == columnX) { + checkedBlocks.add(placedBlock) + counter++ + } + } + println("Row: $columnX, counter: $counter") + if (counter == 8) { + for (block in checkedBlocks) { + val occupiedField = fields.find { it.pos == block.pos } //println("Removing occupied field:$occupiedField") block.removeFromParent() occupiedFields.remove(occupiedField) @@ -173,7 +194,6 @@ fun checkForBlast() { } } - //println("Current row: $rowY, counter:$counter ${checkedBlocks.count()}") checkedBlocks.clear() } From b112f6d1851f462034433bd5f1af3f5062755f34 Mon Sep 17 00:00:00 2001 From: Ferdinand Saurenbach Date: Tue, 15 Apr 2025 12:17:49 +0200 Subject: [PATCH 6/8] update --- build.gradle.kts | 4 +-- gradle.properties | 1 + src/commonMain/kotlin/Block.kt | 57 ++++++++++++++++------------------ src/commonMain/kotlin/main.kt | 22 ++++++++----- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 466a101..1bf6700 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,9 +5,9 @@ plugins { } korge { - id = "io.github.rezmike.game2048" + id = "de.sauronbach.blockSmash" - name = "2048" + name = "Block Smash" icon = file("src/commonMain/resources/korge.png") diff --git a/gradle.properties b/gradle.properties index 903127f..1a8c631 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ org.gradle.jvmargs=-Xmx8g +kotlin.mpp.androidSourceSetLayoutVersion=2 diff --git a/src/commonMain/kotlin/Block.kt b/src/commonMain/kotlin/Block.kt index 641b450..1a1fc7f 100644 --- a/src/commonMain/kotlin/Block.kt +++ b/src/commonMain/kotlin/Block.kt @@ -6,6 +6,7 @@ import korlibs.math.geom.* import korlibs.math.random.* import kotlin.collections.random import kotlin.math.* +import kotlin.properties.* enum class BlockType { // Single block @@ -91,22 +92,20 @@ fun Container.block(color: RGBA, blockType: BlockType, startPosition: StartPosit class Block(private var color: RGBA, blockType: BlockType, startPosition: StartPosition) : Container() { private var placed: Boolean = false - private var master: RoundRect? = null + private var master: RoundRect by Delegates.notNull() - init { - val theWhole = this // Was originally a container() but should work like this too + init { when (startPosition) { StartPosition.LEFT -> this.position(windowWidth * 0.2, windowHeight * 0.8) StartPosition.MIDDLE -> this.position(windowWidth * 0.4, windowHeight * 0.8) StartPosition.RIGHT -> this.position(windowWidth * 0.6, windowHeight * 0.8) } when (blockType) { - BlockType.ONE_BY_ONE -> oneByOne(theWhole) - BlockType.TWO_BY_TWO -> twoByTwo(theWhole) - BlockType.L_3X3_0 -> bigL(theWhole) - else -> bigL(theWhole) - //else -> bigL(theWhole) + BlockType.ONE_BY_ONE -> oneByOne(this) + BlockType.TWO_BY_TWO -> twoByTwo(this) + BlockType.L_3X3_0 -> bigL(this) + else -> bigL(this) } this.scale(0.5) @@ -124,10 +123,10 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP if (it.end) { this.zIndex(0) println("dragging ended: snapping!") - println("viewNextX: ${master!!.globalPos.x}, viewNextY: ${master!!.globalPos.y}") + println("viewNextX: ${master.globalPos.x}, viewNextY: ${master.globalPos.y}") val blockPosition1 = Point( - convertToCoordinateX(round(master!!.globalPos.x).toInt()), convertToCoordinateY( - round(master!!.globalPos.y).toInt() + convertToCoordinateX(round(master.globalPos.x).toInt()), convertToCoordinateY( + round(master.globalPos.y).toInt() ) ) for (field in fields) { @@ -142,22 +141,14 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP if (blockPosition1 == fieldPosition && checkIfCorrectlyPlaced(this)) { println("Placed correctly snapping:") - //field.colorMul = Colors.RED - //master!!.position(field.globalPos) - master!!.globalPos = field.globalPos + master.globalPos = field.globalPos println("this global: ${this.globalPos}") this.forEachChild { - //if (it == master) return@forEachChild - println("one child") - - sContainer!!.placedBlock( + sContainer.placedBlock( color, convertToCoordinateX(it.globalPos.x.toInt()), convertToCoordinateY(it.globalPos.y.toInt()) ) - //var oc = occupiedFields.find { it.fieldX == convertToCoordX(it.globalPos.x.toInt())&& it.fieldY == convertToCoordY(it.globalPos.y.toInt()) } - //occupiedFields.remove(oc) - //println("removing $oc") } placed = true closeable!!.close() @@ -170,7 +161,7 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP addNewPieces() allBlocks.remove(this) println("count:" + occupiedFields.count()) - master?.removeFromParent() + master.removeFromParent() this.removeFromParent() checkForBlast() @@ -179,10 +170,11 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP } if (!placed) { + this.scale(0.5) when (startPosition) { - StartPosition.LEFT -> this.position(windowWidth * 0.3, windowHeight * 0.7) - StartPosition.MIDDLE -> this.position(windowWidth * 0.6, windowHeight * 0.7) - StartPosition.RIGHT -> this.position(windowWidth * 0.9, windowHeight * 0.7) + StartPosition.LEFT -> this.position(windowWidth * 0.2, windowHeight * 0.8) + StartPosition.MIDDLE -> this.position(windowWidth * 0.4, windowHeight * 0.8) + StartPosition.RIGHT -> this.position(windowWidth * 0.6, windowHeight * 0.8) } } } @@ -210,6 +202,7 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP println("Rotation: $rotation") container.size = Size(cs * 3, cs * 3) + when (rotation) { 0 -> { // Original: vertical line + rightward tail @@ -217,7 +210,7 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(three) - val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(four) + container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(four) master = three } @@ -225,9 +218,9 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP // 90°: horizontal line + upward tail val one = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color) val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(one) - val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(two) + container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(two) val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) - val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(four) + container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(four) master = two } @@ -237,7 +230,7 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP val two = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(one) val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignTopToBottomOf(two) val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignRightToLeftOf(one) - val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignRightToLeftOf(four) + container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignRightToLeftOf(four) master = three } @@ -248,10 +241,12 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP val three = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignLeftToRightOf(two) val four = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignBottomToTopOf(two) val five = container.roundRect(Size(cs, cs), RectCorners(5f), fill = color).alignBottomToTopOf(four) - master = two + master = one + master.color = Colors.CHOCOLATE } - } + + } //master!!.color = Colors.RED } diff --git a/src/commonMain/kotlin/main.kt b/src/commonMain/kotlin/main.kt index d56bd4c..1779a57 100644 --- a/src/commonMain/kotlin/main.kt +++ b/src/commonMain/kotlin/main.kt @@ -15,7 +15,7 @@ import kotlin.random.* val rows = mutableListOf>>() var font: BitmapFont by Delegates.notNull() -var backgroundField: RoundRect? = null +var backgroundField: RoundRect by Delegates.notNull() var fields = mutableListOf() var windowWidth = 580 * 1.9.toInt() var windowHeight = 740 * 1.9.toInt() @@ -24,12 +24,15 @@ var cs = fieldSize.height / 8 var leftOccupied = false var middleOccupied = false var rightOccupied = false -var sContainer: Container? = null +var sContainer: Container by Delegates.notNull() val occupiedFields = mutableListOf() val allBlocks = mutableListOf() var placedBlocks = mutableListOf() val random: Random = SecureRandom var first: Field? = null +var leftStart:RoundRect by Delegates.notNull() +val middleStart:RoundRect by Delegates.notNull() +val rightStart: RoundRect by Delegates.notNull() suspend fun main() = Korge( //windowHeight = windowHeight, windowSize = Size(windowWidth, windowHeight), @@ -56,13 +59,16 @@ suspend fun main() = Korge( sContainer = this backgroundField = roundRect(fieldSize, RectCorners(5f), Colors["#202443"]) - backgroundField!!.centerOnStage() + backgroundField.centerOnStage() + + //backgroundField!!.y -= 70 populateField(this) //val testBlock = block(BlockColors.Red, BlockType.TWObyTWO, StartPosition.LEFT) createPieces(this) + } @@ -100,19 +106,19 @@ fun populateField(container: Container) { fun convertToRealX(fieldCoordinate: Int): Number { - return backgroundField!!.x + cs * fieldCoordinate + return backgroundField.x + cs * fieldCoordinate } fun convertToRealY(fieldCoordinate: Int): Number { - return backgroundField!!.y + cs * fieldCoordinate + return backgroundField.y + cs * fieldCoordinate } fun convertToCoordinateX(realX: Int): Int { - return round((realX - backgroundField!!.x) / cs).toInt() + return round((realX - backgroundField.x) / cs).toInt() } fun convertToCoordinateY(realY: Int): Int { - return round((realY - backgroundField!!.y) / cs).toInt() + return round((realY - backgroundField.y) / cs).toInt() } fun createPieces(container: Container) { @@ -143,7 +149,7 @@ fun createPieces(container: Container) { } fun addNewPieces() { - if (!leftOccupied && !middleOccupied && !rightOccupied) createPieces(sContainer!!) + if (!leftOccupied && !middleOccupied && !rightOccupied) createPieces(sContainer) } From 336aaa13f9ce883b5f3e33bb33a07e8ba9dd8fb8 Mon Sep 17 00:00:00 2001 From: Ferdinand Saurenbach Date: Tue, 15 Apr 2025 12:27:02 +0200 Subject: [PATCH 7/8] update --- src/commonMain/kotlin/Block.kt | 1 + src/commonMain/kotlin/main.kt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/Block.kt b/src/commonMain/kotlin/Block.kt index 1a1fc7f..74a3773 100644 --- a/src/commonMain/kotlin/Block.kt +++ b/src/commonMain/kotlin/Block.kt @@ -197,6 +197,7 @@ class Block(private var color: RGBA, blockType: BlockType, startPosition: StartP .alignTopToBottomOf(one) } + private fun bigL(container: Container) { val rotation = random.get(range = 0..3) println("Rotation: $rotation") diff --git a/src/commonMain/kotlin/main.kt b/src/commonMain/kotlin/main.kt index 1779a57..d44144f 100644 --- a/src/commonMain/kotlin/main.kt +++ b/src/commonMain/kotlin/main.kt @@ -64,7 +64,8 @@ suspend fun main() = Korge( //backgroundField!!.y -= 70 populateField(this) - + leftStart = roundRect(Size(cs*1.5, cs*1.5), RectCorners(5f), Colors.PURPLE) + .position(windowWidth*0.2, windowHeight*0.8) //val testBlock = block(BlockColors.Red, BlockType.TWObyTWO, StartPosition.LEFT) createPieces(this) From 477b23efcd85806ab7931cfb47b7270442939aa9 Mon Sep 17 00:00:00 2001 From: Ferdinand Saurenbach Date: Tue, 15 Apr 2025 12:31:28 +0200 Subject: [PATCH 8/8] fix --- src/commonMain/kotlin/main.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commonMain/kotlin/main.kt b/src/commonMain/kotlin/main.kt index d44144f..aa881d9 100644 --- a/src/commonMain/kotlin/main.kt +++ b/src/commonMain/kotlin/main.kt @@ -17,8 +17,8 @@ val rows = mutableListOf>>() var font: BitmapFont by Delegates.notNull() var backgroundField: RoundRect by Delegates.notNull() var fields = mutableListOf() -var windowWidth = 580 * 1.9.toInt() -var windowHeight = 740 * 1.9.toInt() +var windowWidth = (1080/4 * 1.9).toInt() +var windowHeight = (1920/4 * 1.9).toInt() var fieldSize = Size(windowWidth / 1.4, windowWidth / 1.4) var cs = fieldSize.height / 8 var leftOccupied = false