Skip to content

Instantly share code, notes, and snippets.

View pzp1997's full-sized avatar

Palmer Paul pzp1997

View GitHub Profile
@pzp1997
pzp1997 / Pong.pde
Created November 12, 2014 02:28
Pong written in Processing.
/*
Pong.pde: The classic game "Pong" written in Processing
Author: Palmer Paul
Email: [email protected]
Twitter: @pzp1997
Version: 1.0.0 (10/29/14 07:25)
Copyright: (c) 2014, Palmer Paul
*/
float p1, p2;
function unify(a, b) {
var newObj = {};
var aKeys = Object.keys(a);
var bKeys = Object.keys(b);
for (var n = 0; n < aKeys.length; n++) {
newObj[aKeys[n]] = a[aKeys[n]];
if (aKeys[n] in b) {
@pzp1997
pzp1997 / SimpleClass.py
Created November 16, 2014 23:32
Example of a very basic class.
class myClass(object):
def __init__(self, myInt):
self.myString = "Hello"
self.myInt = myInt
def foo(self):
self.myString = self.myString + " world."
def add(self, n):
self.myInt += n
Button button;
int count;
void setup() {
size(300, 300);
rectMode(CENTER);
textSize(48);
textAlign(CENTER);
button = new Button(width/2, height/2 - 30, 100);
}
@pzp1997
pzp1997 / Hangman.py
Last active August 29, 2015 14:12
I was bored tonight, so I made Hangman.
#!/usr/bin/env python2.7
from urllib2 import urlopen
def main():
print 'Hangman.py (c) 2014, pzp1997'
print 'Input "exit" or "quit" to quit.'
print
while True:
@pzp1997
pzp1997 / Chess.pde
Last active August 29, 2015 14:14
Chess (Work in Progress)
// Chess by Palmer Paul and Josh Verscheslieser
/* Piece IDs
Black White Piece
1 7 Rook
2 8 Knight
3 9 Bishop
4 10 Queen
5 11 King
6 12 Pawn
@pzp1997
pzp1997 / BallSensor.html
Created February 12, 2015 15:59
Control the y-position of a circle using a MakeSense! sensor.
<!DOCTYPE html>
<html>
<head>
<title>BallSensor</title>
</head>
<body>
<canvas id="can" height="400" width="400" style="border:1px solid #000000;"></canvas>
<script>
@pzp1997
pzp1997 / VibratingCircles.pde
Last active August 29, 2015 14:15
When you click and hold down on a ball, it will vibrate.
// Array to hold ball objects
Ball[] balls = new Ball[int(random(8, 18))];
void setup() {
size(600, 600);
noStroke();
// Creates balls with random properties
for (int i = 0; i < balls.length; i++) {
balls[i] = new Ball(random(width), random(height), int(random(80, 120)), random(1, 5), color(random(255), random(255), random(255)));
/* /app.js */
// require() dependecies
var mongoose = require('mongoose');
// require() router objects
var user = require('./routes/user');
// app.use() middleware
var db = mongoose.connect('mongodb://test:[email protected]:47720/db_example');
@pzp1997
pzp1997 / Gravity.pde
Created February 25, 2015 17:45
Gravity example by Stephen Lewis.
// gravity is simulated by increasing the downward velocity
// in the void draw() {}
float x, y, wid, ht;
float dy; // downward speed
float gravity; // strength of gravity's pull
float damping; // factor for how much energy the ball loses
// when it hits the floor
float upThrust; // upward force by user, if desired
float dx; // for left and right movement if you want