collision help plz
in
Programming Questions
•
5 months ago
TAB 1
int z;
int m;
ArrayList<Snowflake> Snowflake = new ArrayList<Snowflake>();
PFont P;
int xspeed;
int startingTime;
int m;
ArrayList<Snowflake> Snowflake = new ArrayList<Snowflake>();
PFont P;
int xspeed;
int startingTime;
void setup()
{
z = 0;
size(900, 900);
m = 0;
P=loadFont("AngsanaUPC-30.vlw");
textFont(P);
startingTime = millis();
xspeed = 5;
}
void draw()
{
background(0);
fill(255);
int seconds = (millis() - startingTime) / 1000;
int minutes = seconds / 60;
text((minutes) + ":" + (seconds),50,50);
for (int i = 0; i < Snowflake.size(); i++)
{
if(Snowflake.get(i).getY() > height+ 100)
{
Snowflake.remove(i);
}
else
Snowflake.get(i).display();
}
if(z<10000000)
{
Snowflake.add(new Snowflake(random(0,900),0));
z++;
frameRate(25);
}
fill(255,0,0);
rect(mouseX, 850,20,20);
fill(255,0,0);
rect(460,450,35,35);
}
void time() {
background(170);
fill(255);
}
void keyPressed()
{
if(keyCode == RIGHT)
{
m = m +10;
}
if(keyCode == LEFT)
{
m = m - 10;
}
}
void keyPressed()
{
if(keyCode == RIGHT)
{
m = m +10;
}
if(keyCode == LEFT)
{
m = m - 10;
}
}
TAB 2
public class Snowflake
{
private float x;
private float y;
private float h;
private float w;
public float z;
public float l;
public float r;
public float b;
public float g;
{
private float x;
private float y;
private float h;
private float w;
public float z;
public float l;
public float r;
public float b;
public float g;
public Snowflake(float tx, float ty)
{
x = random(-50,10000);
y = 0;
}
{
x = random(-50,10000);
y = 0;
}
public void display()
{
r = (int)random(0,255);
b =(int)random(0,255);
g =(int)random(0,255);
{
r = (int)random(0,255);
b =(int)random(0,255);
g =(int)random(0,255);
fill(r,g,b);
rect(x,y,15,25);
if (x > mouseX && x < mouseX && y > mouseY +20 && y < mouseY+850)
{
}
if (l < 300000)
{
y = y + 5;
l++;
}
rect(x,y,15,25);
if (x > mouseX && x < mouseX && y > mouseY +20 && y < mouseY+850)
{
}
if (l < 300000)
{
y = y + 5;
l++;
}
}
public float getY()
{
return y;
}
public float getX()
{
return x;
}
}
how do u make the block on the bottom disapear when it touches the snow thats falling down? my friend gave me the code for it but it doesnt work, i highlighted and italiced that part that he gave me.
thx in advance
1