I have almost come to end. This is my final questions, i have tried to solve those questions on my own for like 4-5 hours (with some research from google) and i have figured out most of them.
However, theres still a few that i cant figure them out.
1) in my setup tab, i cant really setup for the player to both eat smaller fishes, and bounce away from the bigger fishes, i can either do one of them. (either eat all of them, or bounce off all of them)
2) when my fish size goes bigger, a werid small fish (i believe parent fish) is inside the fish...very werid, and when it gets BIG, the big fish doesnt rotate according to the keys.
3) my fish starts swimming when it begins, any ways to stop him doing that? stick in one position so i can move him?
4) keyboard pressed is not response that nicely, any way to fix?
These are my final questions, hope someone can give me some tips so i can move forward again tomorrow!! Thanks
see attached files!
FISH CLASS :
class Fish {
float fishX,fishY,velX,velY,fSize;
float sharkX,sharkY;
PVector acc,vel,pos;
boolean fishAlive;
color c;
Fish() {
fishX = random(width);
fishY = random(height);
sharkX = 1000;
sharkY = 500;
pos = new PVector( random(width), random(height) );
vel = new PVector( 0,0 );
acc = new PVector( 0, 0);
velX = random(0.5, 1);//determine random speed
velY = random(0.5, 1);
fSize = random(0.1,0.5);
fishAlive = true;
c = color(random(255), random(255), random(255));
}
void caught(){
velX = 0;
velY = 0;
fishY = -1000;
fishAlive = false;
}
void update() {
vel.add(acc); //instant forces that need to be include in vel
pos.add(vel); //always do this to move particle
acc.set(0, 0, 0);
}
boolean fishDetections(Fish otherFish) //detect other fish method, being called on top
{
if ( abs(fishX - otherFish.fishX) < 50*(fSize + otherFish.fSize)
&& abs(fishY - otherFish.fishY) < 30*(fSize + otherFish.fSize))//detects other fish and turn around