We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm making a game like a squash and I want to put a photo into Ellipse which moves constantly but i don't know how.
void setup(){
size(800,600);
}
int x = 50;
int y = 50;
int Z = 5;
int A = 0;
int B = 0;
int C = 0;
int D = y + 50;
int C1 = 255;
int C2 = 0;
int F1 = 0;
int F2 = 0;
int scr = 0;
int Y1 = 0;
int Y2 = 0;
int M;
int N;
void draw() {
if (N == 0) {
background(200);
fill(155);
textSize(70);
text("Click and Play!",220,100);
fill(50);
textSize(20);
text("djkdsfhiasdhd",100,300);
textSize(20);
ellipse (50,50,100,100);
rect(200,490,130,30);
}
if (N == 0 && M == 1) {N = 1;}
if (N == 1) {
background(C1);
fill(C2);
ellipse(x,y,100,100);
colorx();
rectMode(CENTER);
rect(mouseX-4,490,130,30);
Z = Z + (1/2);
bounce();
score();
}
if (N == 2) {
textSize(17);
text("Click to try again",350,225);
}
if (N == 2 && M == 1) {
N = 1;
x = 50;
y = 50;
Z = 1;
scr = 0;
}
}
void bounce() {
if (x <= 50){
A = 1;
}
if (x >= 750) {
A = 2;
}
if (A == 1) {
x = x+Z ;
}
if (A == 2) {
x = x-Z;
}
if (y <= 50){
B = 1;
}
if (B == 1) {
y = y+Z;
}
if (B == 2) {
y = y-Z;
}
if (B == 3) {
y = y+Z;
}
if (y >= 430 && y <= 480 && C == 1) {
B = 2;
}
else if (y >= 430 && y <= 480 && C == 2) {
B = 3;
}
if (x > mouseX-120 && x < mouseX+90) {
C = 1;
}
if (x < mouseX-120 || x > mouseX+90) {
C = 2;
}
}
void colorx(){
if (C1 == 250) {
F1 = 1;
}
else if (C2 == 255) {
F2 = 1;
}
if (C1 == 40) {
F1 = 2;
}
else if (C2 == 0) {
F2 = 2;
}
if (F1 == 1) {
C1--;
}
else if (F1 == 2) {
C1++;
}
if (F2 == 1) {
C2--;
}
else if (F2 == 2) {
C2++;
}
}
void mousePressed() {
M++;
}
Answers
One approach is to use mask() to copy a region of your source image into a new image, like a cut-out. Here is a working example: