Skip to content

Instantly share code, notes, and snippets.

import static org.lwjgl.opengl.GL11.*;
public class Block {
public boolean tiles[][] = new boolean[4][4];
/*
* Allowed shapes
* (Regular tetris shapes)
* i
* j
@MattRoelle
MattRoelle / gist:3984340
Created October 31, 2012 01:51
first draft of algorithm
import random
MAP_HEIGHT = 24
MAP_WIDTH = 80
CELL_WIDTH = 3
CELL_HEIGHT = 3
def initMap(Map):
for x in xrange(MAP_WIDTH):
for y in xrange(MAP_HEIGHT):
import org.lwjgl.LWJGLException
import org.lwjgl.opengl.Display
import org.lwjgl.opengl.DisplayMode
import org.lwjgl.input.Keyboard
import org.lwjgl.input.Mouse
import org.lwjgl.opengl.GL11._
import org.lwjgl.Sys
import math.abs
import scala.math._
import scala.collection.mutable.ArrayBuffer
rect = new Rect(x+dx,y,w,h);
if (collides()) {
rect = new Rect(x+(dx/2), y,w,h);
if (collides()) {
rect = new Rect(x+(dx/4), y,w,h);
if (collides()) {
rect = new Rect(x+(dx/8), y,w,h);
if (collides()) {
if (dx > 0) {
int index = getIndexOfCollidingBlock();
import static java.lang.Math.*;
public class Vector {
public float x, y, magnitude;
public Vector(double angle) {
this.x = (float) cos(angle);
this.y = (float) sin(angle);
class TwoDimensionalArray
attr_accessor :map
def initialize w, h
@w = w
@h = h
self.map = []
(0...w).each do |x|
(0...h).each do |y|
map[(x*@w) + y] = nil
end
@MattRoelle
MattRoelle / gist:7331081
Last active December 27, 2015 13:09
Basic implementation of derivatives and limits in JavaScript Extends the Function object
console.clear();
Function.prototype.limit = function (x, accuracy) {
var f = this; // for clarity
var C; // constant
if (accuracy === undefined) {
accuracy = 6; // if no accuracy is passed, check to the sixth decimal
}
/*
* CSS matrix3d transform API
* Simplification of 3d transforms
* Matt Roelle
* 2013
*
* Dependent on the Sylvester math library (http://sylvester.jcoglan.com/)
*/
function Surface() {
var regexps = [
{
'regexp': /`([^`]*)`/g,
'flag': 'code'
},
{
'regexp': /\*\*([^\*]*)\*\*/g,
'flag': 'bold'
},
{
/*
* CSS matrix3d transform API
* Simplification of 3d transforms
* Matt Roelle
* 2013
*
* Dependent on the Sylvester math library (http://sylvester.jcoglan.com/)
*/
function Surface() {