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; | |
interface Listener { | |
void picked (String b64Image, Pixmap pixmap); | |
void cancelled (); | |
void failed (); | |
} | |
public void pickFile (Listener listener) { | |
_pickFile(listener); |
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
public boolean convertSpriteVertices = true; | |
/** Draws a rectangle using the given vertices. There must be 4 vertices, each made up of 6 elements in this order: x, y, lightColor, darkColor, | |
* u, v. The {@link #getColor()} and {@link #getDarkColor()} from the TwoColorPolygonBatch is not applied. */ | |
@Override | |
public void draw (Texture texture, float[] spriteVertices, int offset, int count) { | |
if (!drawing) throw new IllegalStateException("begin must be called before draw."); | |
final short[] triangles = this.triangles; | |
final float[] vertices = this.vertices; |
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
graphics.getView().setOnTouchListener(new View.OnTouchListener() { | |
@Override public boolean onTouch (View view, MotionEvent event) { | |
final int action = event.getAction() & MotionEvent.ACTION_MASK; | |
int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; | |
switch (action) { | |
case MotionEvent.ACTION_DOWN: | |
case MotionEvent.ACTION_POINTER_DOWN: { | |
Gdx.app.log("DOWN", pointerIndex + " -> " + event.getPressure(pointerIndex)); | |
} break; | |
case MotionEvent.ACTION_UP: |
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.ApplicationAdapter; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.backends.lwjgl.LwjglApplication; | |
import com.badlogic.gdx.graphics.Color; | |
import com.badlogic.gdx.graphics.GL20; | |
import com.badlogic.gdx.graphics.OrthographicCamera; | |
import com.badlogic.gdx.graphics.g2d.ParticleEffect; | |
import com.badlogic.gdx.graphics.g2d.ParticleEmitter; | |
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | |
import com.badlogic.gdx.graphics.g2d.TextureAtlas; |
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.badlogic.gdx.tests.g2d; | |
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.VertexAttribute; | |
import com.badlogic.gdx.graphics.VertexAttributes; | |
import com.badlogic.gdx.graphics.VertexAttributes.Usage; |
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
"""Perlin noise implementation.""" | |
# Licensed under ISC | |
from itertools import product | |
import math | |
import random | |
def smoothstep(t): | |
"""Smooth curve with a zero derivative at 0 and 1, making it useful for | |
interpolating. |
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
public class PolyBatchTest extends ApplicationAdapter { | |
PolygonSpriteBatch batch; | |
@Override public void create () { | |
Pixmap white = new Pixmap(3, 3, Pixmap.Format.RGBA8888); | |
white.setColor(Color.WHITE); | |
white.drawRectangle(0, 0, 3, 3); | |
Texture texture = new Texture(white); | |
white.dispose(); | |
PolygonRegion region = new PolygonRegion(new TextureRegion(texture), new float[]{0, 0, 0, 3, 3, 3, 3, 0}, new short[]{0,1,2,0,3,2}); | |
// 6, so we cant fit 2 regions |
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
TiledMapTileLayer base = (TiledMapTileLayer)map.getLayers().get(0); | |
int[][] collision = new int[base.getWidth()][base.getHeight()]; | |
for (int x = base.getWidth() - 1; x >= 0; x--) { | |
for (int y = base.getHeight() - 1; y >= 0; y--) { | |
TiledMapTileLayer.Cell cell = base.getCell(x, y); | |
if (cell == null) { | |
Gdx.app.error(TAG, "Null cell at: " + x + " " + y); | |
continue; | |
} | |
TiledMapTile tile = cell.getTile(); |
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
rayHandler = new RayHandler(world); | |
rayHandler.setAmbientLight(0f, 0f, 0f, 0.5f); | |
rayHandler.setBlurNum(0); | |
rayHandler.setLightShader(createStepLightShader()); | |
private ShaderProgram createStepLightShader () { | |
final String vertexShader = | |
"attribute vec4 vertex_positions;\n" // | |
+ "attribute vec4 quad_colors;\n" // |