Skip to content

Instantly share code, notes, and snippets.

View jrenner's full-sized avatar

Jon Renner jrenner

  • Minneapolis, Minnesota, USA
View GitHub Profile
@jrenner
jrenner / kot-strings-bytecode
Created October 12, 2014 14:00
testing kotlin string concatenation bytecode results
fun test() {
val x = "a" + "b" + "c"
}
fun test2() {
val sb = StringBuilder()
sb.append("a").append("b").append("c")
val x = sb.toString()
}
@jrenner
jrenner / expressive-kotlin.kt
Created September 20, 2014 05:11
Expressive Kotlin
package org.jrenner.tactical.utils
import com.badlogic.gdx.utils.TimeUtils
object Timer {
enum class TimeUnit(val name: String) {
Seconds : TimeUnit("seconds")
Millis : TimeUnit("millis")
Micros : TimeUnit("micros")
Nanos : TimeUnit("nanos")
@jrenner
jrenner / groundchunk.java
Created August 30, 2014 07:53
GroundChunk.java
public class GroundChunk extends ModelInstance implements Visible {
private static final BoundingBox box = new BoundingBox();
public Vector3 position;
public Vector3 dimensions;
public float radius;
public GroundChunk(Model model) {
super(model);
calculateTransforms();
calculateBoundingBox(box);
@jrenner
jrenner / heightmapmodel.java
Created August 30, 2014 03:55
HeightMapModel.java
package org.jrenner.tac;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.g3d.Material;
import com.badlogic.gdx.graphics.g3d.Model;
@jrenner
jrenner / heightmap.java
Created August 30, 2014 03:55
HeightMap.java
package org.jrenner.tac;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.GdxRuntimeException;
import org.jrenner.tac.utils.Tools;
/** Heightmap (heightfield) implementation with adjustable height/width scaling and iterative smoothing
* @author jrenner */
@jrenner
jrenner / astar.java
Created June 14, 2014 08:53
Libgdx A* A Star path finding example
package org.jrenner.tac.ai;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.BinaryHeap;
import com.badlogic.gdx.utils.DelayedRemovalArray;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.badlogic.gdx.utils.ObjectFloatMap;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectSet;
package org.jrenner.tac;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.g3d.Material;
import com.badlogic.gdx.graphics.g3d.Model;
Vector3 forwardInRest = Vector3.Z; // object's front is facing Z
Vector3 target = tmp.set(Input.worldMouse); // object should face mouse
q.setFromCross(forwardInRest, target.sub(pos).nor());
gameObj.transform.set(q);
gameObj.transform.setTranslation(pos);
fun StringBuilder.plus(added: String?): StringBuilder {
this.append(added ?: "null")
return this
}
fun example() {
val sb = StringBuilder()
sb + "hello" + "I" + "am" + "a" + "StringBuilder".toString()
}
RoboVM Compile Bash Script
Compiling robokot.RobokotPackage (linux x86)
Compiling jet.runtime.typeinfo.JetValueParameter (linux x86)
Compiling kotlin.jvm.internal.KotlinPackage (linux x86)
Compiling robokot.RobokotPackage-Start-80c4f241 (linux x86)
Compiling kotlin.io.IoPackage (linux x86)
Compiling kotlin.ByteIterator (linux x86)
Compiling kotlin.Function1 (linux x86)
Compiling kotlin.Function2 (linux x86)
Compiling kotlin.io.IoPackage-Files-7bf2ec89 (linux x86)