fixed a NaN bug caused by a zero-width/height hitbox

Also inventory is widened to 10x7 of prev 9x7
This commit is contained in:
minjaesong
2018-11-06 04:02:33 +09:00
parent 5c8cdd3162
commit c7c68187eb
14 changed files with 78 additions and 43 deletions

View File

@@ -29,13 +29,6 @@ class CircularArray<T>(val size: Int) {
}
inline fun forEach(action: (T) -> Unit) {
/*if (tail >= head) { // queue not full
(head..tail - 1).map { buffer[it] }.forEach { action(it) }
}
else { // queue full
(0..size - 1).map { buffer[(it + head) % size] }.forEach { action(it) }
}*/
// has slightly better iteration performance than lambda
if (tail >= head) {
for (i in head..tail - 1)
@@ -47,6 +40,22 @@ class CircularArray<T>(val size: Int) {
}
}
// FIXME not working as intended
inline fun <R> fold(initial: R, operation: (R, T) -> R): R {
var accumulator = initial
//for (element in buffer) accumulator = operation(accumulator, element)
if (tail >= head) {
for (i in head..tail - 1)
operation(accumulator, buffer[i])
}
else {
for (i in 0..size - 1)
operation(accumulator, buffer[(i + head) % size])
}
return accumulator
}
inline fun forEachConcurrent(action: (T) -> Unit) {
TODO()
}