Hi,guy:
I wrote the project for the test of the ball following,
I don't know how can to make the ball effect like falling star
thanks.~:)
boolean flagball=true; // playing ball game?
float ballpx=320; // position x
float ballpy=240; // position y
float ballvx=0.0; // velocity x
float ballvy=0.0; // velocity y
float ballgy=0.05; // gravitation
float ballsz=30.0; // size
float ballfv=1.0; // rebound factor
// x and y positions
// Declare two arrays with 50 elements.
int[] xpos = new int[30];
int[] ypos = new int[30];
void setup(){
size(640, 480, P2D);
smooth();
for (int i = 0; i < xpos.length; i ++ ) {
xpos[i] = 0;
ypos[i] = 0;
}
}
void draw(){
background(0);
// ball movement : not essential for optical flow
// Shift array values
for (int i = 0; i < xpos.length-1; i ++ ) {
// Shift all elements down one spot.
// xpos[0] = xpos[1], xpos[1] = xpos = [2], and so on. Stop at the second to last element.
xpos[i] = xpos[i+1];
ypos[i] = ypos[i+1];
}
Hi guy
i have a question to ask you, anybody can help me to reply?
In fact, i made a test playing now.
I made some video with the transparent background by After effect.
I want the ball that it can to pass before one video of head, it's not passed behind the video.
But i don't know why the ball passed behind the video, i tried to modify the order code, but,it's not good.
So,i hope you can help me by one idea ,it can pass before the video?
The other question is how can i import the video of sans transparence to processing?
Thank u.
//Define a variable of position float x=30; float xpos,ypos; float xspeed= 3.0; float yspeed= 2.0;
float xdirection= 1; float ydirection= 1;
float radius= 15.0;
import processing.video.*;
Movie myMovie; Movie myMovie1; Movie myMovie2; Movie myMovie3;
void setup() { size(640, 480, P2D); background(0); smooth(); noStroke(); // Load and play the video in a loop myMovie = new Movie(this, "2d.avi");//Load this video myMovie.loop();//Makes draw() run loop myMovie1 = new Movie(this, "Murdoc.avi"); myMovie1.loop(); myMovie2 = new Movie(this, "Noodle.avi"); myMovie2.loop(); myMovie3 = new Movie(this, "Russel.avi"); myMovie3.loop(); }
// tint(255, 20); // image(myMovie, myMovie.width/2, myMovie.height/2); //////// Displays the image at point (100, 0) at half of its size image(myMovie, 0, 0,width/6,height/6); image(myMovie1,130, 0,width/6,height/6); image(myMovie2,260, 0,width/6,height/6); image(myMovie3,390, 0,width/6,height/6); }
Did anyone made the video by Opencv in p5?
I want to make the test that it detect and control the your action by the face or hand's project with opencv.
This is the demo code,I don't know How can do it?
Process for animation.
First, when run this programme, there is a animation in the screen.
And then, the camera can detect your movement when you shake by your hand's or face.
Then, the ball will come out by your hand's or face's action in the screen.
The ball can automatic to move and rebound when it touch around.
At last, when the ball random to hit the animation, the animation to be changed to the other animation.
Thx.
Code:
//Define a variable of position
float x=30;
float xpos,ypos;
float xspeed= 3.0;
float yspeed= 2.0;
float xdirection= 1;
float ydirection= 1;
float radius= 15.0;
import processing.video.*;
Movie myMovie;
Movie myMovie1;
Movie myMovie2;
Movie myMovie3;
void setup() {
size(640, 480, P2D);
background(0);
smooth();
noStroke();
// Load and play the video in a loop
myMovie = new Movie(this, "2d.avi");//Load this video
myMovie.loop();//Makes draw() run loop
myMovie1 = new Movie(this, "Murdoc.avi");
myMovie1.loop();
myMovie2 = new Movie(this, "Noodle.avi");
myMovie2.loop();
myMovie3 = new Movie(this, "Russel.avi");
myMovie3.loop();
}
// tint(255, 20);
// image(myMovie, myMovie.width/2, myMovie.height/2);
//////// Displays the image at point (100, 0) at half of its size
image(myMovie, 0, 0,width/6,height/6);
image(myMovie1,130, 0,width/6,height/6);
image(myMovie2,260, 0,width/6,height/6);
image(myMovie3,390, 0,width/6,height/6);
}