Skip to content

Instantly share code, notes, and snippets.

View twyatt's full-sized avatar

Travis Wyatt twyatt

View GitHub Profile
@twyatt
twyatt / flagparse-example.c
Created April 29, 2015 23:54
CS 320 flag parsing
// parse command line arguments for flags (i.e. help and output filename)
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') { /* flag */
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
usage(argv[0]);
exit(EXIT_SUCCESS);
}
if (strcmp(argv[i], "-o") == 0) {
if (i >= argc - 1) {
@twyatt
twyatt / gist:206664
Created October 10, 2009 05:58 — forked from jaredatron/face
clear();
Object.extend = function(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
};
Object.cloneWithInheritance = function(source, extension){
var sourceClass = function(){};
Car = function() {
this.color = 'red';
alert('car was made');
}
Truck.prototype = new Car();
Truck = function() {
// how do I call the parent constructor (i.e. make the alert box appear)
}
@twyatt
twyatt / HeightmapUtils.java
Created July 14, 2012 09:29
Simple utility class for reading libGDX's Pixmaps for use as heightmaps.
package com.traviswyatt.example.helpers.terrain;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.traviswyatt.example.models.Heightmap;
public class HeightmapUtils {
public static Heightmap load(FileHandle file) {
package com.traviswyatt.example.models;
public class Heightmap {
public final int width;
public final int height;
public final float[] elevations;
public final boolean flipY;
@twyatt
twyatt / ModelView
Created July 20, 2012 01:53
Renders a mesh within a libGDX widget.
package com.traviswyatt.example.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GLCommon;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g3d.model.Model;
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.print.PrinterJob;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class PrintTest extends Application {
@twyatt
twyatt / letter_grade.gdoc
Created July 8, 2017 01:41
Google Sheet formula for determining letter grade from score.
=IF(A1>89,"A",IF(A1>79,"B",IF(A1>69,"C",IF(A1>59,"D","F"))))
@twyatt
twyatt / proguard.cfg
Created July 25, 2012 03:47
An Android ProGuard configuration that works with libGDX.
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
typealias ColorFunction = (currentTimeMillis: Long) -> Int
class CustomView : View {
val paint = Paint()
var colorFunction: ColorFunction? = null
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)