collision detection and score
in
Programming Questions
•
6 months ago
Someone helped me make some code and I need a little help making the rectangle at the bottom know that it is touching the words in the case being collision detection. So basically when the word hits the rectangle it counts it and produces a score at the top right hand corner of the screen. So basically making a little game and every time the word is hits the rectangle the sped slowly but surely goes up making the game harder:
String word = "estou";
PFont font;
float xpos;
float ypos;
float speed = 4;
void setup(){
size(400,400);
font = createFont("arial",32);
smooth();
fill(0);
background(255);
xpos = random (width);
}
void draw(){
background(255);
rect(mouseX,350,30,10);
ypos +=speed;
text(word, xpos, ypos);
if (ypos > height ){
xpos = random (width);
speed = random(1.8, 5);
ypos = 0;
println("new xpos = " + xpos + " new speed = " + speed);
}
}
1