LibGDX, here I am.

This commit is contained in:
minjaesong
2017-06-22 02:31:07 +09:00
parent 1ecbc57f83
commit ad481853bb
356 changed files with 3125 additions and 21138 deletions

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" />
<version value="1.0" />
</settings>
</component>

12
.idea/libraries/KotlinJavaRuntime.xml generated Normal file
View File

@@ -0,0 +1,12 @@
<component name="libraryTable">
<library name="KotlinJavaRuntime">
<CLASSES>
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -6,17 +6,20 @@
<JAVADOC>
<root url="http://slick.ninjacave.com/javadoc/" />
<root url="file://$PROJECT_DIR$/lib/javadoc" />
<root url="file://$PROJECT_DIR$/lib/apidocs" />
<root url="http://libgdx.badlogicgames.com/nightlies/docs/api/" />
</JAVADOC>
<NATIVE>
<root url="file://$PROJECT_DIR$/lib" />
<root url="file://$PROJECT_DIR$/lib/x86" />
<root url="file://$PROJECT_DIR$/lib/x86_64" />
</NATIVE>
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/kotlin-runtime-sources.jar!/" />
<root url="file://$PROJECT_DIR$/lib" />
<root url="file://$PROJECT_DIR$/lib/slick-source" />
<root url="file://$PROJECT_DIR$/lib/source" />
<root url="jar://$PROJECT_DIR$/lib/Terrarum_Joise.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/source/gdx-backend-lwjgl-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/TerrarumSansBitmap.jar!/" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" type="SOURCES" />
<jarDirectory url="file://$PROJECT_DIR$/lib/source" recursive="false" type="SOURCES" />
</library>
</component>

View File

@@ -15,6 +15,17 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="library" name="groovy-2.4.10" level="application" />
<orderEntry type="module-library">
<library name="KotlinJavaRuntime">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/kotlin-runtime.jar!/" />
<root url="jar://$MODULE_DIR$/lib/kotlin-reflect.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/lib/kotlin-runtime-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -5,7 +5,7 @@
import net.torvald.point.Point2d
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.TerrarumGDX
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.ActorWithPhysics
import net.torvald.terrarum.itemproperties.Calculate
@@ -14,7 +14,6 @@ import net.torvald.terrarum.itemproperties.Material
import net.torvald.terrarum.blockproperties.Block
// following two are NOT UNUSED!
import org.jetbrains.annotations.NotNull
import org.newdawn.slick.GameContainer
@@ -56,42 +55,42 @@ class TestPick extends GameItem {
}
@Override
boolean primaryUse(@NotNull GameContainer gc, int delta) {
int mouseTileX = Terrarum.getMouseTileX()
int mouseTileY = Terrarum.getMouseTileY()
boolean primaryUse(float delta) {
int mouseTileX = TerrarumGdx.getMouseTileX()
int mouseTileY = TerrarumGdx.getMouseTileY()
def mousePoint = new Point2d(mouseTileX, mouseTileY)
def actorvalue = Terrarum.ingame.player.actorValue
def actorvalue = TerrarumGDX.ingame.player.actorValue
using = true
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
// return false if hitting actors
Terrarum.ingame.actorContainer.forEach({
TerrarumGDX.ingame.actorContainer.forEach({
if (it instanceof ActorWithPhysics && it.tilewiseHitbox.intersects(mousePoint))
return false
})
// return false if here's no tile
if (Block.AIR == Terrarum.ingame.world.getTileFromTerrain(mouseTileX, mouseTileY))
if (Block.AIR == TerrarumGDX.ingame.world.getTileFromTerrain(mouseTileX, mouseTileY))
return false
// filter passed, do the job
double swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)
Terrarum.ingame.world.inflictTerrainDamage(
TerrarumGDX.ingame.world.inflictTerrainDamage(
mouseTileX, mouseTileY,
Calculate.pickaxePower(Terrarum.ingame.player, material) * swingDmgToFrameDmg
Calculate.pickaxePower(TerrarumGDX.ingame.player, material) * swingDmgToFrameDmg
)
return true
}
@Override
boolean endPrimaryUse(@NotNull GameContainer gc, int delta) {
boolean endPrimaryUse(float delta) {
using = false
// reset action timer to zero
Terrarum.ingame.player.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
TerrarumGDX.ingame.player.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
return true
}
}

View File

@@ -1,3 +1,12 @@
## Note to modders
- You DON'T just edit built-in modules; you must make your own module even if you want to replace defaults.
### To devs
- make that happen :\
## Register modules
Only the modules that enlisted in LoadOrder.csv will be loaded.

Binary file not shown.

Binary file not shown.

BIN
lib/TerrarumSansBitmap.jar Normal file

Binary file not shown.

BIN
lib/Terrarum_Joise.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/libjinput.zip Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,178 +0,0 @@
/*
* Copyright (C) 2013 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import com.sudoplay.joise.module.Module;
import com.sudoplay.joise.module.SeedableModule;
import com.sudoplay.util.Assert;
public class Joise {
private Module module;
private ModuleMap moduleMap;
private HashMap<String, ArrayList<SeedableModule>> seedMap = new HashMap<String, ArrayList<SeedableModule>>();
/**
* Creates a new instance of Joise with the supplied module chain.
* <p>
* This method duplicates the module chain by first converting the chain to a
* {@link ModuleMap}, then converting it back to a {@link Module} while
* mapping any seed names to the seedmap.
* <p>
* Changes made to the original module passed in will not be reflected in this
* instance of Joise.
*
* @param module
*/
public Joise(Module module) {
Assert.notNull(module);
moduleMap = module.getModuleMap();
this.module = fromModuleMap(moduleMap);
}
/**
* Creates a new instance of Joise from the supplied {@link ModuleMap}.
* <p>
* This method duplicates the module map by first converting the map to a
* {@link Module}, then converting it back to a module map. Seed names are
* mapped during the conversion from map to module.
* <p>
* Changes made to the original module map passed in will not be reflected in
* this instance of Joise.
*
* @param moduleMap
*/
public Joise(ModuleMap moduleMap) {
Assert.notNull(moduleMap);
this.module = fromModuleMap(moduleMap);
this.moduleMap = module.getModuleMap();
}
private Module fromModuleMap(ModuleMap map) {
try {
ModuleInstanceMap im = new ModuleInstanceMap();
Iterator<Entry<String, ModulePropertyMap>> it = map.mapIterator();
Module module = null;
while (it.hasNext()) {
Entry<String, ModulePropertyMap> e = it.next();
ModulePropertyMap props = e.getValue();
String moduleName = "com.sudoplay.joise.module." + props.get("module");
module = (Module) Class.forName(moduleName).newInstance();
module.buildFromPropertyMap(props, im);
if (module instanceof SeedableModule
&& ((SeedableModule) module).hasSeedName()) {
SeedableModule sm = (SeedableModule) module;
String seedName = sm.getSeedName();
ArrayList<SeedableModule> list = seedMap.get(seedName);
if (list == null) {
list = new ArrayList<SeedableModule>();
seedMap.put(seedName, list);
}
list.add(sm);
}
im.put(e.getKey(), module);
}
return module;
} catch (Exception e) {
throw new JoiseException(e);
}
}
/**
* Sets the seed of the module linked by seedName.
*
* @param seedName
* @param seed
* @throws IllegalStateException
* if the seed name is not found in the seed map
*/
public void setSeed(String seedName, long seed) {
ArrayList<SeedableModule> list = seedMap.get(seedName);
if (list == null || list.isEmpty()) {
throw new IllegalStateException("Seed name not found: " + seedName);
}
for (SeedableModule sm : list) {
sm.setSeed(seed);
}
}
public boolean hasSeed(String seedName) {
return seedMap.get(seedName) != null;
}
/**
* @return the stored module map for this Joise
*/
public ModuleMap getModuleMap() {
return moduleMap;
}
public double get(double x, double y) {
return module.get(x, y);
}
public double get(double x, double y, double z) {
return module.get(x, y, z);
}
public double get(double x, double y, double z, double w) {
return module.get(x, y, z, w);
}
public double get(double x, double y, double z, double w, double u, double v) {
return module.get(x, y, z, w, u, v);
}
}

View File

@@ -1,66 +0,0 @@
/*
* Copyright (C) 2013 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise;
@SuppressWarnings("serial")
public class JoiseException extends RuntimeException {
public JoiseException(String msg) {
super(msg);
}
public JoiseException(Exception e) {
super(e);
}
public JoiseException(String msg, Exception e) {
super(msg, e);
}
}

View File

@@ -1,107 +0,0 @@
/*
* Copyright (C) 2013 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import com.sudoplay.joise.module.Module;
@SuppressWarnings("serial")
public class ModuleInstanceMap extends HashMap<String, Module> {
@Override
public Module put(String id, Module module) {
if (id == null) {
throw new NullPointerException("null id");
}
if (module == null) {
throw new NullPointerException("null module, id=" + id);
}
return super.put(id, module);
}
@Override
public Module get(Object key) {
Module module = super.get(key);
if (module == null) {
throw new NullPointerException("null module, id=" + key);
}
return module;
}
public boolean contains(String id) {
return super.get(id) != null;
}
public Iterator<Entry<String, Module>> iterator() {
return super.entrySet().iterator();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[");
Iterator<Entry<String, Module>> it = iterator();
while (it.hasNext()) {
Entry<String, Module> e = it.next();
sb.append("[");
sb.append(e.getKey());
sb.append("|");
sb.append(e.getValue());
sb.append("]");
}
sb.append("]");
return sb.toString();
}
}

View File

@@ -1,103 +0,0 @@
/*
* Copyright (C) 2013 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
@SuppressWarnings("serial")
public class ModuleMap extends LinkedHashMap<String, ModulePropertyMap> {
@Override
public ModulePropertyMap put(String module, ModulePropertyMap propertyMap) {
if (propertyMap == null) {
throw new NullPointerException("property map for module [" + module
+ "] null");
}
return super.put(module, propertyMap);
}
@Override
public ModulePropertyMap get(Object key) {
ModulePropertyMap props = super.get(key);
if (props == null) {
throw new NullPointerException("property map [" + key + "] null");
}
return super.get(key);
}
public boolean contains(String id) {
return super.get(id) != null;
}
public Iterator<Entry<String, ModulePropertyMap>> mapIterator() {
return super.entrySet().iterator();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[");
Iterator<Entry<String, ModulePropertyMap>> it = mapIterator();
while (it.hasNext()) {
Entry<String, ModulePropertyMap> e = it.next();
sb.append("[");
sb.append(e.getKey());
sb.append("|");
sb.append(e.getValue());
sb.append("]");
}
sb.append("]");
return sb.toString();
}
}

View File

@@ -1,154 +0,0 @@
/*
* Copyright (C) 2013 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import com.sudoplay.joise.module.Module;
@SuppressWarnings("serial")
public class ModulePropertyMap extends LinkedHashMap<String, Object> {
public ModulePropertyMap() {
// serialization
}
public ModulePropertyMap(Module module) {
setModule(module);
}
public void setModule(Module module) {
super.put("module", module.getClass().getSimpleName());
}
@Override
public Object put(String key, Object value) {
if (key == null) {
throw new NullPointerException();
}
if (value == null) {
return super.put(key, null);
} else {
return super.put(key, value.toString());
}
}
@Override
public Object get(Object key) {
if (key == null) {
throw new NullPointerException();
}
Object value = super.get(key);
return value;
}
public String getAsString(String key) {
return get(key).toString();
}
public long getAsLong(String key) {
try {
return Long.parseLong(getAsString(key));
} catch (NumberFormatException e) {
throw new JoiseException("Expecting property [" + key + ", "
+ getAsString(key) + "] to be a long");
}
}
public double getAsDouble(String key) {
try {
return Double.parseDouble(getAsString(key));
} catch (NumberFormatException e) {
throw new JoiseException("Expecting property [" + key + ", "
+ getAsString(key) + "] to be a double");
}
}
public boolean getAsBoolean(String key) {
String candidate = getAsString(key).toLowerCase();
if ("true".equals(candidate) || "false".equals(candidate)) {
return Boolean.parseBoolean(getAsString(key));
} else {
throw new JoiseException("Expecting property [" + key + ", "
+ getAsString(key) + "] to be a boolean");
}
}
public boolean isModuleID(String key) {
return getAsString(key).startsWith("func_");
}
public boolean contains(String key) {
return super.get(key) != null;
}
public Iterator<Entry<String, Object>> iterator() {
return super.entrySet().iterator();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Iterator<Entry<String, Object>> it = iterator();
while (it.hasNext()) {
Entry<String, Object> e = it.next();
sb.append("[");
sb.append(e.getKey());
sb.append("|");
sb.append(e.getValue());
sb.append("]");
}
return sb.toString();
}
}

Binary file not shown.

View File

@@ -1,81 +0,0 @@
/*
* Copyright (C) 2013 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise.generator;
public abstract class BasePRNG {
public abstract int get();
public abstract void setSeed(long seed);
public void setSeedTime() {
setSeed(System.currentTimeMillis());
}
public int getTarget(int t) {
double v = get01();
return (int) (v * (double) t);
}
public double get01() {
return ((double) get() / (double) 4294967295L) + 0.5;
}
public int getRange(int low, int high) {
if (high < low) {
int temp = low;
low = high;
high = temp;
}
double range = (double) ((high - low) + 1);
double val = (double) low + get01() * range;
return (int) val;
}
}

View File

@@ -1,31 +0,0 @@
package com.sudoplay.joise.generator
/**
* Created by SKYHi14 on 2017-02-20.
*/
class Xorshift128plus : BasePRNG() {
private var s0: Long = 0
private var s1: Long = 0
init {
setSeed(10000L)
}
override fun get(): Int {
var x = s0
val y = s1
s0 = y
x = x xor (x shl 23)
s1 = x xor y xor (x ushr 17) xor (y ushr 26)
return (s1 + y).toInt()
}
override fun setSeed(seed: Long) {
if (seed == 0L)
throw IllegalArgumentException("Invalid seed: cannot be zero")
s0 = (6364136223846793005L * seed + 1442695040888963407L)
s1 = (6364136223846793005L * s0 + 1442695040888963407L)
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright (C) 2013 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise.mapping;
public class Array2Double {
public static final byte X = 0;
public static final byte Y = 1;
private int[] size = new int[2];
private double[] data;
@SuppressWarnings("unused")
private Array2Double() {}
public Array2Double(int x, int y) {
this(x, y, new double[x * y]);
}
public Array2Double(int x, int y, double[] data) {
size[X] = x;
size[Y] = y;
this.data = data;
}
public void set(int x, int y, double v) {
data[x + size[X] * y] = v;
}
public double get(int x, int y) {
return data[x + size[X] * y];
}
public double[] getData() {
return data;
}
public int[] getSize() {
return size;
}
public int getWidth() {
return size[X];
}
public int getHeight() {
return size[Y];
}
}

View File

@@ -1,72 +0,0 @@
/*
* Copyright (C) 2013 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise.mapping;
public class Array2DoubleWriter implements Mapping2DWriter {
private Array2Double data;
public Array2DoubleWriter(int x, int y) {
this(new Array2Double(x, y));
}
public Array2DoubleWriter(Array2Double data) {
this.data = data;
}
public Array2Double getData() {
return data;
}
@Override
public void write(int x, int y, double value) {
data.set(x, y, value);
}
}

Some files were not shown because too many files have changed in this diff Show More