Skip to content

Instantly share code, notes, and snippets.

@Tom-Ski
Tom-Ski / bulid.gradle
Created November 14, 2013 21:06
Gradle task to call some Exec :)
apply plugin: "java"
apply plugin: "application"
sourceCompatibility = 1.6
mainClassName = "me.tomski.levelediting.LevelEditor"
sourceSets.main.resources.srcDirs = [file("../desktop/assets").getAbsolutePath()]
// idea doesn't like relative paths outside of content root...
tasks.ideaModule.doFirst {
@Tom-Ski
Tom-Ski / TempBodyPool.java
Created January 7, 2014 11:13
Pooled objects
public TempBodyPool(final World world, final Level level) {
toastParticles = new Pool<ToastParticle>() {
@Override
protected ToastParticle newObject() {
return new ToastParticle(world, 1, 1f, 1f, 1, 0.5f, 0.2f);
}
};
cerealParticles = new Pool<CerealParticle>() {
@Override
protected CerealParticle newObject() {
project(":gwt") {
apply plugin: "gwt"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
}
@Tom-Ski
Tom-Ski / index
Created January 13, 2014 23:48
gwt index
<!doctype html>
<html>
<head>
<title>%APP_NAME%</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
canvas {
cursor: default;
outline: none;
}
@Tom-Ski
Tom-Ski / AlertMenu.java
Created January 22, 2014 15:11
Simple Dialog
public static void simpleOkAlert(Stage stage, Skin skin, String title, String text) {
Dialog dialog = new Dialog(title, skin);
dialog.defaults().center();
dialog.setBackground(new TextureRegionDrawable(skin.get("Alert", TextureRegion.class)));
dialog.text(text).padTop(20).align(Align.center);
dialog.getButtonTable().defaults().pad(0).expandX().fillX().width(200);
dialog.button("Ok, Ill stop misbehaving").padBottom(3);
dialog.setWidth(400);
dialog.setHeight(140);
dialog.setPosition(Gdx.graphics.getWidth() / 2 - 400, Gdx.graphics.getHeight() / 2 - 140);
@Tom-Ski
Tom-Ski / Tooltips.java
Created January 25, 2014 18:01
Nex's tooltips
/*******************************************************************************
* Copyright 2013 See AUTHORS File
*
* 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
@Tom-Ski
Tom-Ski / LevelEditorScreen.java
Created January 25, 2014 18:04
Usage of tooltips
private void addToolTips() {
tooltips.registerTooltip(toolbar.grabCursor, "Translate Tool");
tooltips.registerTooltip(toolbar.gravityGlobe, "Gravity Toggle");
tooltips.registerTooltip(toolbar.pinButton, "Joint Pin ");
tooltips.registerTooltip(toolbar.lightButton, "Lighting Toggle");
tooltips.registerTooltip(toolbar.normalCursor, "Select Tool");
}
@Tom-Ski
Tom-Ski / Settings
Created February 7, 2014 17:10
Tper
TexturePacker.Settings settings = new TexturePacker.Settings();
settings.maxHeight = 1024;
settings.maxWidth = 1024;
settings.duplicatePadding = true;
settings.edgePadding = true;
settings.paddingX = 2;
settings.paddingY = 2;
settings.bleed = true;
settings.alias = true;
settings.useIndexes = true;
@Tom-Ski
Tom-Ski / build.gradle
Created February 14, 2014 17:17
Hoop Jumping
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
@Tom-Ski
Tom-Ski / secretstuff.java
Created February 15, 2014 01:37
maximtwo is my hero
protected void loadFixtures(TiledMap map, World world) {
MapLayer fixturesLayer = map.getLayers().get("fixtures");
Array<PolylineMapObject> fixtures = fixturesLayer.getObjects().getByType(PolylineMapObject.class);
BodyDef bd = new BodyDef();
bd.type = BodyType.StaticBody;
groundBody = world.createBody(bd);
groundBody.setUserData(-1);