Skip to content

Instantly share code, notes, and snippets.

View CSchoel's full-sized avatar

Christopher Schölzel CSchoel

View GitHub Profile
@CSchoel
CSchoel / binary_clock.pde
Created January 27, 2015 13:31
Binary clock
//Autor: Nadja Krümmel
class BinaryDigit {
int[] binary;
int decimal;
BinaryDigit() {
this.binary = new int[4];
this.binary[3] =0;
this.decimal = 0;
}
@CSchoel
CSchoel / snow.pde
Created January 27, 2015 13:30
Snow falling on a randomly generated mountain
//Autor: Christopher Schölzel
float FRONT_WIDTH = 20;
class Snowflake {
float noiseX;
float noiseY;
float x,y;
float vx,vy;
float w;
Snowflake(float x, float y, float vx, float vy, float w) {
@CSchoel
CSchoel / tree.pde
Created January 27, 2015 13:28
Recursive tree structure with angles depending on mouse position
//Autor: Christopher Schölzel
float angle = 0;
void setup() {
size(400,400);
}
void draw() {
background(255);
@CSchoel
CSchoel / fibonacci.pde
Created January 27, 2015 13:27
Three different fibonacci variants with simple performance tests and Stackframe analysis
//Autor: Christopher Schölzel
// -------------------------------------------
// -- Musterlösungen zu Fibonacci-Varianten --
// -------------------------------------------
int fib(int n) {
if (n <= 1) return n;
else return fib(n-2)+fib(n-1);
}
@CSchoel
CSchoel / connect_four.pde
Created January 27, 2015 13:25
Connect four game
//Autor: Christopher Schölzel, Nadja Krümmel
int TYPE_EMPTY = 0;
int TYPE_BLUE = 1;
int TYPE_RED = -1;
class ConnectFour {
float brickWidth = 50;
float margin = 50;
int[][] field;
// 0 = leer, +1 = blau, -1 = rot
ConnectFour(int cols, int rows) {
@CSchoel
CSchoel / labyrinth.pde
Created January 27, 2015 13:23
Labyrinth game with rudimentary Labyrinth generation
//Autor: Christopher Schölzel
class Square {
boolean negotiable; //begehbar oder nicht?
boolean isExit;
Square(boolean negotiable, boolean isExit) {
this.negotiable = negotiable;
this.isExit = isExit;
}
boolean isExit() {
@CSchoel
CSchoel / pixel_art.pde
Created January 27, 2015 13:22
Create pixel art by flipping values in a two-dimensional Array with mouse clicks.
//Autor: Christopher Schölzel
class Field {
int[][] content;
float fh,fw;
float px,py;
Field(float posX, float posY, int fieldsX, int fieldsY, float fieldWidth, float fieldHeight) {
content = new int[fieldsY][fieldsX];
this.fw = fieldWidth;
this.fh = fieldHeight;
@CSchoel
CSchoel / birds_and_balloons.pde
Created January 27, 2015 13:20
A bird destroys flying balloons
//Autor: Christopher Schölzel
//Abstrakte Superklasse für Bird und Balloon
//Vermeidet, dass z.b. visible doppelt implementiert werden muss
abstract class Movable {
float w,h;
float x,y;
Movable(float w, float h, float x, float y) {
this.w = w;
this.h = h;
@CSchoel
CSchoel / bar_chart.pde
Created January 27, 2015 13:17
Bar chart with modification and sorting
//Autor: Christopher Schölzel
class Bar {
int value;
boolean marked;
Bar(int value) {
this.value = value;
marked = false;
}
//Zeichnet den balken an position (x,y) mit der Breite b und
//dem Streckungsfaktor hFac für die Balkenhöhe.
@CSchoel
CSchoel / cannon_game.pde
Created January 27, 2015 13:16
A cannon game with realistic ballistics including wind and a moving target
//Autor: Christopher Schölzel
//Klasse für die Kanonenkugel
class CannonBall {
float x,y; //Position der Kugel
float vx,vy; //Geschwindigkeit auf der x- bzw. y-Achse
float d; //Durchmesser der Kugel
float dragCoefficient = 0.001; //Luftwiderstand
Environment env;
CannonBall(float x, float y, float vx, float vy, float d, Environment env) {