Coverage Summary for Class: MainScene (<empty package name>)
Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
MainScene |
0%
(0/2)
|
0%
(0/12)
|
0%
(0/22)
|
0%
(0/273)
|
MainScene$sceneMain$1 |
|
MainScene$sceneMain$2 |
0%
(0/1)
|
0%
(0/10)
|
0%
(0/12)
|
0%
(0/103)
|
Total |
0%
(0/3)
|
0%
(0/22)
|
0%
(0/34)
|
0%
(0/376)
|
| import Commands.* |
| import Entities.* |
| import com.soywiz.klock.* |
| import com.soywiz.korev.* |
| import com.soywiz.korge.scene.* |
| import com.soywiz.korge.view.* |
| import com.soywiz.korim.format.* |
| import com.soywiz.korio.file.std.* |
| import Enums.* |
| |
| |
| |
| |
| class MainScene : Scene() { |
| |
| |
| |
| override suspend fun SContainer.sceneMain() { |
| |
| val playerSprites = arrayOf( |
| |
| resourcesVfs["Pieces/Man/Man [Up] [T].png"].readBitmapSlice(), |
| |
| resourcesVfs["Pieces/Man/Man [Right] [T].png"].readBitmapSlice(), |
| |
| resourcesVfs["Pieces/Man/Man [Down] [T].png"].readBitmapSlice(), |
| |
| resourcesVfs["Pieces/Man/Man [Left] [T].png"].readBitmapSlice(), |
| ) |
| |
| val backgroundBitmap = resourcesVfs["Pieces/Background/Background.png"].readBitmapSlice() |
| val blockBitmap = resourcesVfs["Pieces/Block/Block [T].png"].readBitmapSlice(); |
| image(backgroundBitmap) |
| |
| val wall: Wall = wall(backgroundBitmap) { |
| position(0, 0); |
| } |
| |
| val player: Player = player(playerSprites) { |
| position(256, 256) |
| } |
| |
| val block: Block = block(blockBitmap) { |
| position(256 + 33, 256); |
| } |
| |
| val commandList: MutableList<Command> = mutableListOf(); |
| var commandPosition = 0; |
| |
| player.addFixedUpdater(30.timesPerSecond) { |
| |
| player.movementUpdateCycle(); |
| |
| if (input.keys[Key.LEFT]) { |
| commandList.add(MoveCommand(player, Direction.WEST)); |
| } else if (input.keys[Key.RIGHT]) { |
| commandList.add(MoveCommand(player, Direction.EAST)); |
| } else if (input.keys[Key.UP]) { |
| commandList.add(MoveCommand(player, Direction.NORTH)); |
| } else if (input.keys[Key.DOWN]) { |
| commandList.add(MoveCommand(player, Direction.SOUTH)); |
| } |
| |
| for (i in commandPosition until(commandList.size)) { |
| commandList[i].exec(); |
| } |
| |
| commandPosition = commandList.size; |
| |
| } |
| } |
| } |