mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 13:51:53 +09:00
added resources for ambient sound
Former-commit-id: 85517a87b4d2d64808ccfc3fae7effa4cf92eb55 Former-commit-id: 1ddfcd3db3db138d047f6defe5d87ddf7eefac8f
This commit is contained in:
@@ -20,6 +20,8 @@ object CSVFetcher {
|
||||
csvString = StringBuffer() // reset buffer every time it called
|
||||
readCSVasString(csvFilePath)
|
||||
|
||||
println("Reading CSV $csvFilePath")
|
||||
|
||||
val csvParser = CSVParser.parse(
|
||||
csvString!!.toString(),
|
||||
CSVFormat.DEFAULT.withIgnoreSurroundingSpaces()
|
||||
|
||||
@@ -22,6 +22,8 @@ object JsonFetcher {
|
||||
jsonString = StringBuffer() // reset buffer every time it called
|
||||
readJsonFileAsString(jsonFilePath)
|
||||
|
||||
println("Reading JSON $jsonFilePath")
|
||||
|
||||
val jsonParser = JsonParser()
|
||||
val jsonObj = jsonParser.parse(jsonString!!.toString()).asJsonObject
|
||||
|
||||
@@ -33,6 +35,8 @@ object JsonFetcher {
|
||||
jsonString = StringBuffer() // reset buffer every time it called
|
||||
readJsonFileAsString(jsonFile.canonicalPath)
|
||||
|
||||
println("Reading JSON ${jsonFile.path}")
|
||||
|
||||
val jsonParser = JsonParser()
|
||||
val jsonObj = jsonParser.parse(jsonString!!.toString()).asJsonObject
|
||||
|
||||
|
||||
@@ -1,53 +1,66 @@
|
||||
* *Terrarum* by Torvald
|
||||
Copyright 2015-2016 Torvald. All rights reserved.
|
||||
mailto: skyhi14 *64* __115875741922660__ *46* __6516589__
|
||||
*Terrarum* by Torvald
|
||||
|
||||
Copyright (C) 2015-2016 Torvald. All rights reserved.
|
||||
mailto: skyhi14 *64* __115875741922660__ *46* __6516589__
|
||||
|
||||
----
|
||||
|
||||
* *Simplex Noise Generator*, version 2012-03-09 by Stefan Gustavson
|
||||
Released as public domain
|
||||
*Simplex Noise Generator*, version 2012-03-09 by Stefan Gustavson
|
||||
|
||||
Released as public domain
|
||||
|
||||
----
|
||||
|
||||
* *Joise* modular noise library
|
||||
Copyright (C) 2013 Jason Taylor.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*Joise* modular noise library
|
||||
|
||||
Copyright (C) 2013 Jason Taylor.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
----
|
||||
|
||||
* *Vector2* from Dyn4j
|
||||
Copyright (c) 2010-2015 William Bittle http://www.dyn4j.org/
|
||||
All rights reserved.
|
||||
*Vector2* from Dyn4j
|
||||
|
||||
Copyright (c) 2010-2015 William Bittle http://www.dyn4j.org/
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of dyn4j nor the names of its contributors may be used to endorse or
|
||||
promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Kotlin translated and modified code Copyright (C) 2016 Torvald aka skyhi14.
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of dyn4j nor the names of its contributors may be used to endorse or
|
||||
promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Kotlin translated and modified code Copyright (c) 2016 Torvald aka skyhi14.
|
||||
---
|
||||
|
||||
Amazing ambient sound recordings in ```sound/ambient/klankbeeld-freesound```
|
||||
|
||||
Samples used: 173111, 183181, 185290, 195287, 240108, 326914, 337691, 347753
|
||||
|
||||
Copyright (C) 2012, 2013, 2015, 2016 Klankbeeld
|
||||
Sound from http://www.freesound.org/people/klankbeeld/
|
||||
@@ -59,9 +59,9 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
||||
}
|
||||
}
|
||||
|
||||
//game = StateGame()
|
||||
//addState(game)
|
||||
addState(StateMonitorCheck())
|
||||
ingame = StateInGame()
|
||||
addState(ingame)
|
||||
//addState(StateMonitorCheck())
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -241,7 +241,7 @@ object LightmapRenderer {
|
||||
}
|
||||
// luminous tile on top of air
|
||||
else if (thisWall == AIR && thisTileLuminosity.toInt() > 0) {
|
||||
lightLevelThis = maximiseRGB(sunLight, thisTileLuminosity) // maximise to not exceed 1.0 with normal (<= 1.0) light
|
||||
lightLevelThis = sunLight maxBlend thisTileLuminosity // maximise to not exceed 1.0 with normal (<= 1.0) light
|
||||
}
|
||||
// opaque wall and luminous tile
|
||||
else if (thisWall != AIR && thisTileLuminosity.toInt() > 0) {
|
||||
@@ -252,7 +252,7 @@ object LightmapRenderer {
|
||||
// mix luminous actor
|
||||
for ((posX, posY, luminosity) in lanternMap) {
|
||||
if (posX == x && posY == y)
|
||||
lightLevelThis = maximiseRGB(lightLevelThis, luminosity) // maximise to not exceed 1.0 with normal (<= 1.0) light
|
||||
lightLevelThis = lightLevelThis maxBlend luminosity // maximise to not exceed 1.0 with normal (<= 1.0) light
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ object LightmapRenderer {
|
||||
nearby = 0 // exclude 'me' tile
|
||||
}
|
||||
|
||||
ambient = maximiseRGB(ambient, nearby) // keep base value as brightest nearby
|
||||
ambient = ambient maxBlend nearby // keep base value as brightest nearby
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ object LightmapRenderer {
|
||||
thisTileOpacity) // get real ambient by appling opacity value
|
||||
|
||||
// mix and return lightlevel and ambient
|
||||
return maximiseRGB(lightLevelThis, ambient)
|
||||
return lightLevelThis maxBlend ambient
|
||||
}
|
||||
else {
|
||||
return lightLevelThis
|
||||
@@ -355,27 +355,19 @@ object LightmapRenderer {
|
||||
* +-+-+
|
||||
* d
|
||||
*/
|
||||
val a = maximiseRGB(
|
||||
thisLightLevel,
|
||||
getLight(x, y - 1) ?: thisLightLevel
|
||||
)
|
||||
val d = maximiseRGB(
|
||||
thisLightLevel,
|
||||
getLight(x, y + 1) ?: thisLightLevel
|
||||
)
|
||||
val b = maximiseRGB(
|
||||
thisLightLevel,
|
||||
getLight(x - 1, y) ?: thisLightLevel
|
||||
)
|
||||
val c = maximiseRGB(
|
||||
thisLightLevel,
|
||||
getLight(x + 1, y) ?: thisLightLevel
|
||||
)
|
||||
val a = thisLightLevel maxBlend (getLight(x, y - 1) ?: thisLightLevel)
|
||||
val d = thisLightLevel maxBlend (getLight(x, y + 1) ?: thisLightLevel)
|
||||
val b = thisLightLevel maxBlend (getLight(x - 1, y) ?: thisLightLevel)
|
||||
val c = thisLightLevel maxBlend (getLight(x + 1, y) ?: thisLightLevel)
|
||||
|
||||
val colourMapItoL = IntArray(4)
|
||||
colourMapItoL[0] = colourLinearMix(a, b)
|
||||
colourMapItoL[1] = colourLinearMix(a, c)
|
||||
colourMapItoL[2] = colourLinearMix(b, d)
|
||||
colourMapItoL[3] = colourLinearMix(c, d)
|
||||
val colMean = (a linMix d) linMix (b linMix c)
|
||||
val colDelta = thisLightLevel colSub colMean
|
||||
|
||||
colourMapItoL[0] = a linMix b colAdd colDelta
|
||||
colourMapItoL[1] = a linMix c colAdd colDelta
|
||||
colourMapItoL[2] = b linMix d colAdd colDelta
|
||||
colourMapItoL[3] = c linMix d colAdd colDelta
|
||||
|
||||
for (iy in 0..1) {
|
||||
for (ix in 0..1) {
|
||||
@@ -505,34 +497,46 @@ object LightmapRenderer {
|
||||
* @param rgb2
|
||||
* @return
|
||||
*/
|
||||
private fun maximiseRGB(rgb: Int, rgb2: Int): Int {
|
||||
val r1 = rgb.rawR()
|
||||
val r2 = rgb2.rawR()
|
||||
private infix fun Int.maxBlend(other: Int): Int {
|
||||
val r1 = this.rawR()
|
||||
val r2 = other.rawR()
|
||||
val newR = if (r1 > r2) r1 else r2
|
||||
val g1 = rgb.rawG()
|
||||
val g2 = rgb2.rawG()
|
||||
val g1 = this.rawG()
|
||||
val g2 = other.rawG()
|
||||
val newG = if (g1 > g2) g1 else g2
|
||||
val b1 = rgb.rawB()
|
||||
val b2 = rgb2.rawB()
|
||||
val b1 = this.rawB()
|
||||
val b2 = other.rawB()
|
||||
val newB = if (b1 > b2) b1 else b2
|
||||
|
||||
return constructRGBFromInt(newR, newG, newB)
|
||||
}
|
||||
|
||||
private fun screenBlend(rgb: Int, rgb2: Int): Int {
|
||||
val r1 = rgb.r()
|
||||
val r2 = rgb2.r()
|
||||
private infix fun Int.screenBlend(other: Int): Int {
|
||||
val r1 = this.r()
|
||||
val r2 = other.r()
|
||||
val newR = 1 - (1 - r1) * (1 - r2)
|
||||
val g1 = rgb.g()
|
||||
val g2 = rgb2.g()
|
||||
val g1 = this.g()
|
||||
val g2 = other.g()
|
||||
val newG = 1 - (1 - g1) * (1 - g2)
|
||||
val b1 = rgb.b()
|
||||
val b2 = rgb2.b()
|
||||
val b1 = this.b()
|
||||
val b2 = other.b()
|
||||
val newB = 1 - (1 - b1) * (1 - b2)
|
||||
|
||||
return constructRGBFromFloat(newR, newG, newB)
|
||||
}
|
||||
|
||||
private infix fun Int.colSub(other: Int) = constructRGBFromInt(
|
||||
(this.rawR() - other.rawR()).clampChannel() ,
|
||||
(this.rawG() - other.rawG()).clampChannel() ,
|
||||
(this.rawB() - other.rawB()).clampChannel()
|
||||
)
|
||||
|
||||
private infix fun Int.colAdd(other: Int) = constructRGBFromInt(
|
||||
(this.rawR() + other.rawR()).clampChannel() ,
|
||||
(this.rawG() + other.rawG()).clampChannel() ,
|
||||
(this.rawB() + other.rawB()).clampChannel()
|
||||
)
|
||||
|
||||
fun Int.rawR() = this / MUL_2
|
||||
fun Int.rawG() = this % MUL_2 / MUL
|
||||
fun Int.rawB() = this % MUL
|
||||
@@ -581,10 +585,10 @@ object LightmapRenderer {
|
||||
return constructRGBFromInt(intR, intG, intB)
|
||||
}
|
||||
|
||||
private fun colourLinearMix(colA: Int, colB: Int): Int {
|
||||
val r = (colA.rawR() + colB.rawR()) ushr 1
|
||||
val g = (colA.rawG() + colB.rawG()) ushr 1
|
||||
val b = (colA.rawB() + colB.rawB()) ushr 1
|
||||
private infix fun Int.linMix(other: Int): Int {
|
||||
val r = (this.rawR() + other.rawR()) ushr 1
|
||||
val g = (this.rawG() + other.rawG()) ushr 1
|
||||
val b = (this.rawB() + other.rawB()) ushr 1
|
||||
return constructRGBFromInt(r, g, b)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user