Snippets

Snippets
These are useful snippets for every day life.

Not all topics have been filled yet.

Please feel free to add more items to the list or fill iut a topic below underneath the list.


 * 1) a box with parameters
 * 2) a sphere with parameters
 * 3) a msgbox with OK
 * 4) a msgbox that let's you ask yes / no / cancel or OK / cancel etc.
 * 5) Inputbox that let's you enter text (or only numbers)
 * 6) a good 3D cam as in SketchUp (without using peasycam)
 * 7) a state class
 * 8) a multiple choice quiz template
 * 9) a simple rotating camera
 * 10) a 2D cloud for a sky
 * 11) a 3D cloud for a sky
 * 12) a sky sphere
 * 13) a ground class
 * 14) a 3D cam that can follow a 3D player (like Lara Croft)
 * 15) a collection of textures for sky, walls, grass, tree, rock, way, street, forest...
 * 16) a collection of sounds like xylophone, laser, hit, crash, door slam, die, scream
 * 17) a collection of sprites like on http://www.openprocessing.org
 * 18) a simple 3D HUD with hint(DISABLE_DEPTH_TEST); etc.
 * 19) a simple class to save and load any HashMap or Table to and from Hard drive
 * 20) a box class (to make an ArrayList of)
 * 20) a sphere / ball class (to make an ArrayList of)
 * 21) Rotated image at x,y with angle

more more more.... but the idea is to make something that others can reuse in their sketches (like a template or a lib).

I know, a lot is already around, but still...

We all come across stuff like this we need every day (or produce every day on the side).

AD 9) Rotating camera
void cameraManagement { camX= camRadius * cos ( radians(camAngle) ) +330 ; camZ= camRadius * sin ( radians(camAngle) ) +0 ; camera(camX, camY, camZ,   330.0, 331.0, 0.0,    0.0, 1.0, 0.0); // camera if (!keyPressed) { // rotate camAngle+=.6; if (camAngle>360) camAngle=0; } // if }

AD 16) Sounds
use this site http://www.freesound.org/ and then use Audacity to edit them (by quarks).

AD 21) Rotated image at x,y with angle
code for put out a image with rotation by quarks PImage big [] = new PImage [1]; void setup {   size(800, 600); big[0] = loadImage("big.jpg"); } void draw { imageParams(  big[0], random (width), random(height),   random(0, TWO_PI)); imageParams(  big[0], random (width), random(height),   random(0, TWO_PI)); imageParams(  big[0], random (width), random(height),   random(0, TWO_PI)); noLoop; } void imageParams (PImage pimage,  float x, float y,  float angle) { pushMatrix; imageMode(CENTER); translate(x, y); rotate(angle); image(pimage, 0, 0); popMatrix; } //