This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlin.random.Random | |
| /** | |
| * Denotes an instance of [Random] that does not mutate its own internal state. Unlike standard [Random], | |
| * [ImmutableRandom] will always return the same value for subsequent calls to [nextBits], [nextInt], etc. One must | |
| * call [nextRandom] to get a new instance of [ImmutableRandom] with a state that would typically have been updated | |
| * internally. | |
| * | |
| * For the same seed, any sequence of `next*(), nextRandom()` should yield the same result as a normal [Random] calling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private var destination: Point = player.pos.copy() | |
| private val playerSpeed = 6.0 | |
| private val step = 20 | |
| init { | |
| addUpdater { | |
| handeKeyboardControls() | |
| } | |
| addFixedUpdater(25.milliseconds) { | |
| if (destination.distanceTo(player.pos) > playerSpeed) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * MIT License | |
| * | |
| * Copyright (c) 2022 Albert Chang | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| * of this software and associated documentation files (the "Software"), to deal | |
| * in the Software without restriction, including without limitation the rights | |
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| * copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun Any.prettyPrint(): String { | |
| var indentLevel = 0 | |
| val indentWidth = 4 | |
| fun padding() = "".padStart(indentLevel * indentWidth) | |
| val toString = toString() | |
| val stringBuilder = StringBuilder(toString.length) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlinx.coroutines.CoroutineScope | |
| import kotlinx.coroutines.Job | |
| import kotlinx.coroutines.delay | |
| import kotlinx.coroutines.launch | |
| /* | |
| This is free and unencumbered software released into the public domain. | |
| Anyone is free to copy, modify, publish, use, compile, sell, or | |
| distribute this software, either in source code form or as a compiled |