Hi, I started Processing recently, and I’m trying to make a project for school, but I’m stuck.
(Before start to explain, I’m sorry for the possible mistakes I could make, I’m not english)
Well, I assume you know what “Taiko” is, it’s a OSU mode, here you can see what it look like : https://www.youtube.com/watch?v=f_uSO2ESCRI
I’m trying to make something similar to it, but with the 4 arrow on the keyboard
The balls will be coming from the right, and will go horizontaly to the left, until they go too far, or if the right arrow is pressed when the ball will be in the zone.
What I want to do and I’m stuck with, is the fact that I can only have one ball on the screen, I don’t know how I can put two balls, (or more) on the screen, and make them move at the same speed. I also want the balls to come every second, and that the ball will be a random ball between the 4 type of ball available (One for each arrow)
Here is my current code :
int Start =1400, vit=2, a=0, diff =120;
Boule ball = new Boule();
void setup() {
int i;
background(255);
size(1250, 800);
for (i=0; i<=5; i++) {
line(380, 530+i, 1400, 530+i);
line(380, 650+i, 1400, 650+i);
line(380-i, 0, 380-i, 800);
line(560+i/2, 530, 560+i/2, 650);
line(660+i/2, 530, 660+i/2, 650);
}
ellipse(611, 592, 99, 99);
frameRate(120);
}
void draw() {
ball.update();
ball.display();
}
// ---------------Verification-----------------
void keyPressed() {
if (key == CODED) {
if (keyCode==UP) {
println(ball.collision(1));
}
if (keyCode==DOWN) {
println(ball.collision(2));
}
if (keyCode==LEFT) {
println(ball.collision(3));
}
if (keyCode==RIGHT) {
println(ball.collision(4));
}
}
}
And the second part for the class :
class Boule {
int Start =1400;
int vit=2, pos, type;
Boule() {
pos=Start;
type=1+int(random(4));
}
void update() {
int i;
noStroke();
fill(255);
rect(490, 536, 1000, 113);
pos -= vit;
for (i=0; i<=5; i++) {
stroke(1);
fill(0);
line(560+i/2, 530, 560+i/2, 650);
line(660+i/2, 530, 660+i/2, 650);
}
fill(255);
ellipse(611, 592, 99, 99);
stroke(1);
fill(255);
if (pos<=522) {
println("Too late !");
pos=Start;
noStroke();
fill(255);
ellipse(522, 592, 72, 72);
}
}
boolean collision(int touche)
{
boolean ret=false;
if ((pos<=660)&&(pos>=560)) {
if (type==touche) {
ret=true;
}
}
return ret;
}
void display() {
switch(type)
{
case 1 :
stroke(1);
fill(255, 0, 255);
ellipse(pos, 592, 64, 64);
fill(0);
rect(pos-4, 590, 10, 25);
triangle(pos-14, 590, pos+1, 570, pos+16, 590);
break;
case 2 :
stroke(1);
fill(255, 255, 0);
ellipse(pos, 592, 64, 64);
fill(0);
rect(pos-5, 570, 10, 25);
triangle(pos-15, 595, pos, 615, pos+15, 595);
break;
case 3 :
stroke(1);
fill(0, 255, 255);
ellipse(pos, 592, 64, 64);
fill(0);
rect(pos-18, 587, 25, 11);
triangle(pos+7, 610, pos+7, 575, pos+25, 592);
break;
case 4 :
stroke(1);
fill(50, 255, 70);
ellipse(pos, 592, 64, 64);
fill(0);
rect(pos-6, 587, 25, 11);
triangle(pos-6, 610, pos-6, 575, pos-22, 592);
break;
}
}
}
I searched for hours and hours with the processing reference, but I’m still stuck with this. Thank you for your help :x