For the key stuff, the best idea is to have a boolean storing the state, e.g.
Code:boolean keyUP=false;
void keyPressed()
{
if(keyCode==UP)
keyUP=true;
}
void keyReleased()
{
if(keyCode==UP)
keyUP=false;
}
So keyUP will be true whilst the key is held down.
As for the intersect, I think you may be better only having one class for guys, with variables for all the difference between them.
e.g.
Code:class guy
{
int posx,posy;
int boxWidth,boxHeight;
PImage[] frames;
guy(int px, int py, int bw, int bh, PImage[] a, PImage[] b)
{
posx=ps;
posy=py;
boxWidth=bw;
bohHeight=bh;
for(int i=0;i<a.length;i++)
{
a[i].mask(b[i]);
}
}
// a function to give the boxWidth
int getBoxWidth()
{
return boxWidth;
}
}
The reason for this is that if you have different classes, even though they have the same functions it's very hard to use them in the same way without having lots and lots and lots of code doing the same thing over and over, instead of just looping through an array of guys.