This file contains hidden or 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
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 | |
} |
This file contains hidden or 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
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 |
This file contains hidden or 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 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); |
This file contains hidden or 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
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(); |
This file contains hidden or 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 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 |
This file contains hidden or 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 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): |
This file contains hidden or 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 static org.lwjgl.opengl.GL11.*; | |
public class Block { | |
public boolean tiles[][] = new boolean[4][4]; | |
/* | |
* Allowed shapes | |
* (Regular tetris shapes) | |
* i | |
* j |
NewerOlder