Skip to content

Instantly share code, notes, and snippets.

View tedigc's full-sized avatar

ted tedigc

View GitHub Profile
{
"buttonBackgroundColor": "#77DB89",
"buttonForegroundColor": "#000",
"submitButtonText": "Submit",
"fileUrl": "https://media.wizards.com/2014/downloads/dnd/DMBasicRulesv.0.3_PrinterFriendly.pdf",
}
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using rpg.Source.Assets;
namespace rpg {
public class NinePatch {
private const int DefaultSpacing = 1;
private const int Bleed = 1;
namespace rpg {
public class StateMachine<T> {
private T entity;
private State<T> currentState;
private State<T> previousState;
private State<T> globalState;
public StateMachine(T entity, State<T> initialState, State<T> globalState = null) {
this.entity = entity;
@tedigc
tedigc / Edg32.java
Created October 20, 2018 22:56
All of the colours from @ENDESGA's edg32 palette, in order of hue
package com.halfcut.galaxygarden.util;
import com.badlogic.gdx.graphics.Color;
/**
* @author halfcutdev
* @since 09/09/2017
*
* All of the colours from @ENDESGA's edg32 palette, in order of hue
*
@tedigc
tedigc / send.py
Created June 16, 2018 00:09
Python snippet for sending emails with Gmail
import smtplib
from email.parser import Parser
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
USR = "<gmail_username>"
PWD = "<gmail_app_password>"
# Set up server
server = smtplib.SMTP("smtp.gmail.com", 587)
@tedigc
tedigc / Player.java
Created March 15, 2018 19:31
Player class for Galaxy Garden
package com.halfcut.galaxygarden.level.object.entity.player;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Intersector;
import com.badlogic.gdx.math.Vector2;
import com.halfcut.galaxygarden.level.object.animation.Animation;
@tedigc
tedigc / scale.sh
Created February 28, 2018 15:04
Bash script for batch-scaling images in a directory.
#!/bin/bash
#
# Check that the correct number of arguments have been given.
#
if [ "$#" -ne 3 ]; then
echo
echo "[Error]: Usage \"./scale.sh <input_dir> <output_dir> <scale>\""
echo
exit 1
@tedigc
tedigc / scale-and-crop.sh
Last active February 28, 2018 17:14
Bash script for scaling all images in a directory. Includes cropping for ninepatch images
#
# Check that the correct number of arguments have been given.
#
if [ $# -ne 3 ]; then
echo
echo [Error] Usage .scale.sh input_dir output_dir scale
echo
exit 1
fi
@tedigc
tedigc / HtmlLauncher.java
Last active December 26, 2017 23:54
A not-ugly HTML launcher and loading screen for libGDX
package com.halfcut.galaxygarden.client;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import com.badlogic.gdx.backends.gwt.preloader.Preloader;
import com.badlogic.gdx.graphics.Pixmap;
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.Context2d;
@tedigc
tedigc / line(v1, v1)
Created September 16, 2017 15:44
calculate a line of points between two vectors
static public ArrayList<Vector2> line(Vector2 v1, Vector2 v2) {
int x = (int) v1.x;
int y = (int) v1.y;
int x2 = (int) v2.x;
int y2 = (int) v2.y;
ArrayList<Vector2> result = new ArrayList<Vector2>();
int w = x2 - x ;
int h = y2 - y ;