Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / ScreenGraphExample.pde
Created January 11, 2015 21:35
Example ScreenGraph
Game game;
Element e;
void setup() {
size(640, 480, P3D);
noStroke();
e = new MouseMoved();
//e.transformation.scale(10);
//e.transformation.rotate(PI / 4);
e.addChild(new Circle(30, 10)).transformation.scale(10);;
@darkwave
darkwave / ArenaWars.pde
Created January 17, 2015 10:15
Movimento con tastiera
PImage sfondo;
PImage player1;
PImage player2;
PImage gem;
int x1 = 100;
int y1 = 300;
int x2 = 500;
int y2 = 300;
@darkwave
darkwave / MyIPAddress.pde
Created January 19, 2015 01:32
Get IP Address using native Java in Processing
import java.util.*;
import java.net.*;
void setup() {
try {
Enumeration e = NetworkInterface.getNetworkInterfaces();
while (e.hasMoreElements ())
{
NetworkInterface n = (NetworkInterface) e.nextElement();
@darkwave
darkwave / Timer.pde
Last active August 29, 2015 14:14
Efficent timer (maybe)
int lastTime; //variabile
boolean stopTime = false;
int currentTime = 0;
int delay = 1000; //millis
final int INIT = -1;
final int RESTING = 0;
final int SHOWING = 1;
int state = INIT;
boolean debug = true;
@darkwave
darkwave / OpenBrowserExample.pde
Created March 12, 2015 21:34
Open a browser to a specific Url using Processing with Android Intent
import android.net.Uri;
import android.content.Intent;
void setup() {
}
void draw() {
}
void mousePressed() {