viernes, 4 de noviembre de 2011

taller

En los siguientes trabajos me fue imposible subir los códigos a openprocessing y desconozco el motivo, sin embargo al abrirlos en el programa (processing) tanto en Mac como en Pc, funcionan perfectamente.

Imagen con movimiento y audio:
import ddf.minim.*;
AudioPlayer player;
Minim minim;
PImage pez;
PImage estanque;
int size = 0;
float xpos, ypos;
float xspeed = 0.8;
float yspeed = 0.2;
int xdirection = 1;
int ydirection = 1;

void setup()
{size(400,300);
noStroke();
frameRate(600);
smooth();
minim = new Minim(this);
xpos = width/2;
ypos = height/2;
estanque = loadImage ("estanque.jpg");
pez = loadImage ("pez.gif");
player = minim.loadFile("bosques.mp3", 2500);
player.play();
}

void draw()
{
background(estanque);
xpos = xpos + ( xspeed * xdirection );
ypos = ypos + ( yspeed * ydirection );

if (xpos > width-size || xpos < 0) {
xdirection *= -1;
}

if (ypos > height-size || ypos < 0) {
ydirection *= -1;
}

image (pez,xpos+size/1, ypos+size/1);
}
Imagen con movimiento, audio y mouse:
import ddf.minim.*;
AudioPlayer player;
Minim minim;
PImage pez;
PImage estanque;
PImage koi;
int size = 50;
float xpos, ypos;
float xspeed = 0.1;
float yspeed = 0.1;
int xdirection = -10;
int ydirection = -9;

void setup()
{size(400,300);
noStroke();
frameRate(500);
smooth();
minim = new Minim(this);
xpos = width/3;
ypos = height/3;
estanque = loadImage ("estanque.jpg");
pez = loadImage ("pez.gif");
koi = loadImage ("koi.gif");
player = minim.loadFile("bosques.mp3", 2500);
player.play();
}


void draw()
{ if(keyPressed) {
if (key == 'c' || key == 'B') {
background(estanque);
xpos = xpos + ( xspeed * xdirection );
ypos = ypos + ( yspeed * ydirection );
if (xpos > width-size || xpos < 0) {
xdirection *= 2;
}

if (ypos > height-size || ypos < 0) {
ydirection *= -6;
}
translate (mouseY,mouseX);
image (pez,xpos+size/3, ypos+size/3);
image (koi, 100, 150);
}}}

taller: imagen con movimiento