This file contains 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
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; |
This file contains 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
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 */ |
This file contains 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
float dragForce; | |
Vector2 appliedDrag = new Vector2(); | |
float dragAngle; | |
float p, A, Cd, v; // elements of the formula see wikipedia entry for Drag (physics) | |
/* | |
ρ is the density of the fluid, | |
v is the speed of the object relative to the fluid, | |
A is the cross-sectional area | |
Cd is the drag coefficient – a dimensionless number. | |
sample drag co-efficients (http://en.wikipedia.org/wiki/Drag_coefficient) |
This file contains 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 static void generateFonts() { | |
// if fonts are already generated, just load from file | |
Preferences fontPrefs = Gdx.app.getPreferences("org.jrenner.superior.font"); | |
int displayWidth = fontPrefs.getInteger("display-width", 0); | |
int displayHeight = fontPrefs.getInteger("display-height", 0); | |
boolean loaded = false; | |
if (displayWidth != Gdx.graphics.getWidth() || displayHeight != Gdx.graphics.getHeight()) { | |
Tools.log.debug("Screen size change detected, regenerating fonts"); | |
} else { | |
try { |
This file contains 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 main(args: Array<String>) { | |
val arr = array("cats", "dogs") | |
for (i in 0..10) { | |
println(arr.random()) | |
} | |
// this version works fine | |
fun <T> Array<T>.random() : T { | |
val rand = Random() | |
return this.get(rand.nextInt(this.size)) |
This file contains 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
float frameTime = dt; | |
if (frameTime > 0.5f) { | |
frameTime = 0.5f; | |
} | |
accumulatedDT += frameTime; | |
while (accumulatedDT >= Physics.TIME_STEP) { | |
frame++; | |
tick(); | |
Physics.runPhysics(); | |
//System.out.printf("ran physics - accum: %.3f\n", accumulatedDT); |
This file contains 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
package com.example.libgdx.skeleton; | |
import com.badlogic.gdx.ApplicationAdapter; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.Net; | |
import com.badlogic.gdx.math.MathUtils; | |
import com.badlogic.gdx.math.Vector2; | |
import com.badlogic.gdx.net.ServerSocket; | |
import com.badlogic.gdx.net.Socket; | |
import com.badlogic.gdx.physics.box2d.Body; |
This file contains 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
float frameTime = dt; | |
if (frameTime > 0.5f) { | |
frameTime = 0.5f; | |
} | |
accumulatedDT += frameTime; | |
while (accumulatedDT >= Physics.TIME_STEP) { | |
frame++; | |
tick(); | |
Physics.runPhysics(); | |
//System.out.printf("ran physics - accum: %.3f\n", accumulatedDT); |
This file contains 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
package com.example.libgdx.skeleton; | |
import com.badlogic.gdx.ApplicationListener; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.graphics.GL10; | |
import com.badlogic.gdx.graphics.OrthographicCamera; | |
import com.badlogic.gdx.math.Matrix4; | |
import com.badlogic.gdx.math.Rectangle; | |
import com.badlogic.gdx.math.Vector2; | |
import com.badlogic.gdx.physics.box2d.*; |
This file contains 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 com.badlogic.gdx.backends.lwjgl.LwjglApplication; | |
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; | |
public class DesktopStarter { | |
private static final short FULLSCREEN = 0; | |
private static final short GALAXY_S3 = 1; | |
private static final short NEXUS_ONE = 2; | |
private static final short EVO3D = 3; | |
private static final short BIG_WINDOW = 4; | |
private static final short SMALL_PHONE = 5; |
NewerOlder