Skip to content

Instantly share code, notes, and snippets.

View CSchoel's full-sized avatar

Christopher Schölzel CSchoel

View GitHub Profile
@CSchoel
CSchoel / catch_the_circle.pde
Created January 27, 2015 13:06
Use the mouse to catch the circle.
//Musterlösung zu OOP Aufgabenblatt 1, Aufgabe 3 (WS 14/15)
//Autor: Christopher Schölzel
float x,y; //position
float r; //radius
void setup() {
size(300,300);
background(0);
x = width/2;
y = height/2;
r = 30;
@CSchoel
CSchoel / thm_logo.pde
Created January 27, 2015 13:09
Generates the THM logo by faculty and location numbers.
//Autor: Christopher Schölzel
color THMGreen = color(128,186,36);
color THMGray = color(74,92,102);
float boxHeight = 15; //größe einer einzelnen Box im Fenster
int fachbereich = 6; //Fachbereichsnummer
int standort = 1; //Standortnummer
void setup() {
size(500,200);
noLoop();
background(255);
@CSchoel
CSchoel / pong.pde
Created January 27, 2015 13:10
Simple single-player Pong
//Autor: Christopher Schölzel
float x,y;
float vx,vy;
float radius;
float stickX,stickY;
float stickW,stickH;
boolean gameOver;
int hits;
int maxHits;
@CSchoel
CSchoel / lines.pde
Created January 27, 2015 13:12
Demonstration of for-loop with moving lines
//Autor: Christopher Schölzel
float x1,y1; //erster Punkt für unteres Linienende
float x2,y2; //zweiter Punkt für unteres Linienende
void setup() {
size(400,400);
x1 = 0;
y1 = height;
x2 = width;
y2 = height;
@CSchoel
CSchoel / bingo.pde
Created January 27, 2015 13:13
A simple bingo game
//Autor: Christopher Schölzel
int bingoWidth = 5; //Anzahl der Felder in x-/y-Richtung
int fieldWidth = 50;//Feldbreite in pixeln
int[] bingo = new int[bingoWidth*bingoWidth]; //Feldinhalte
boolean[] marked = new boolean[bingo.length]; //Markierungen der Felder
int numberIndex = 0; //Index der gerade gezogenen Zahl
int[] numberSequence;//(gemischte) Sequenz von gezogenen Zahlen
int numberTimeout = 10000; //Timeout nach dem eine neue Zahl gezogen wird
int lastNumberTime = 0; //Zeitpunkt zu dem die letzte Zahl gezogen wurde
@CSchoel
CSchoel / stickfigure.pde
Created January 27, 2015 13:14
A walking stick figure
//Autor: Christopher Schölzel
class StickFigure {
float v; //Bewegungsgeschwindigkeit
float x; //x-Koordinate
public StickFigure(float x, float v) {
this.x = x;
this.v = v;
}
void walk() {
if (x > width-100) v = -1;
@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) {
@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 / 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 / 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;