Skip to content

Instantly share code, notes, and snippets.

@darkwave
darkwave / MovingAlongPathAgent.pde
Created January 4, 2015 11:50
Move along path Agent.
Agent player;
void setup() {
size(640, 480);
player = new Agent(new PVector(width / 2, height / 2));
ArrayList<PVector> newPath = new ArrayList<PVector>();
newPath.add(new PVector(100, 100));
newPath.add(new PVector(80, 200));
newPath.add(new PVector(150, 300));
player.newPath = newPath;
}
@darkwave
darkwave / AnimatedCharacter.pde
Created January 3, 2015 21:30
Simple Animated sprite
PAnimation front, up, side;
void setup() {
//size(640, 480);
front = new PAnimation("front.png", 37, 90, 100);
up = new PAnimation("up.png", 40, 90, 100);
side = new PAnimation("side.png", 53, 90, 100);
}
void draw() {
@darkwave
darkwave / Agent.pde
Last active August 29, 2015 14:12
Simple Path Finding using NavMesh for Point and Click Adventure Games for Processing. It depends on AI for Games library by Peter Lager and it uses Polygon class by Roman Kushnarenko. SVG file mesh.svg included as source for the navmesh (add it to the /data folder).
class Agent {
PVector pos, currentTarget;
ArrayList<PVector> path = new ArrayList<PVector>();
ArrayList<PVector> newPath;
int pathIndex = 0;
Agent(PVector _pos) {
pos = _pos;
currentTarget = pos;
newPath = path;
@darkwave
darkwave / AnotherExample.pde
Last active August 29, 2015 14:11
Simple UI
/*
Using it with some proportional changes on buttons according to screen-size
*/
UI ui;
PImage bg;
void setup() {
size(800, 800);
ui = new UI(this);
@darkwave
darkwave / Funzioni.pde
Created December 4, 2014 20:38
Esempi funzioni
void setup() {
size(600, 600);
}
void draw() {
if (isInside(mouseX, mouseY, 300, 300, 50))
fill(#ff0000);
else
fill(#00ff00);
@darkwave
darkwave / Orologio.pde
Last active August 29, 2015 14:10
Esempio orologio versione 1
/**
Un orologio in Processing
Immagini di riferimento:
http://tinyurl.com/fusi004a
http://tinyurl.com/fusi004b
**/
PImage quadrante = null;
PImage lancetta = null;
@darkwave
darkwave / QRCodeAndroidTest.pde
Created November 25, 2014 10:55
QRCode reader using ZXing with Processing under Android (Ketai)
import com.google.zxing.*;
import java.io.ByteArrayInputStream;
import javax.imageio.ImageIO;
import com.google.zxing.common.*;
import com.google.zxing.client.j2se.*;
import android.graphics.Bitmap;
import ketai.camera.*;
KetaiCamera cam;
boolean globalHistogram = false;
@darkwave
darkwave / QRCodeTest.pde
Created November 24, 2014 18:56
QRCode reader using ZXing with Processing 3.0a5
import processing.video.*;
import com.google.zxing.*;
import java.io.ByteArrayInputStream;
import javax.imageio.ImageIO;
import com.google.zxing.common.*;
import com.google.zxing.client.j2se.*;
import java.awt.image.BufferedImage;
Capture cam; //Set up the camera
@darkwave
darkwave / AndroidDataReceiver.pde
Last active April 7, 2023 12:03
How to receive Android Intent data from another App using Processing
/*
For more information visit Android developer portal http://developer.android.com/training/sharing/receive.html
*/
import android.graphics.BitmapFactory;
import android.graphics.Bitmap;
import java.io.InputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import android.content.Intent;
@darkwave
darkwave / EsempioVariabili.pde
Created November 20, 2014 21:45
Snippet Lezione 3 al Fusolab 2.0
int numero;
int numeroB = 2;
float numeroCasuale = random(10);
numero = 10 + numeroB;
char lettera = 'a';
String testo = "qualcosa di esempio";
float numeroDecimale = 0.1;
int diametro = 20;
ellipse(50, 50, diametro, diametro);