Hi, I’m new in this “Processing World”. I’m trying to keep the fishes in the pond. I’m using this code by Nicholas Tang --> https://www.openprocessing.org/sketch/20105/.
Please help me!
Hi, I’m new in this “Processing World”. I’m trying to keep the fishes in the pond. I’m using this code by Nicholas Tang --> https://www.openprocessing.org/sketch/20105/.
Please help me!
It’s a 2d sketch so you need to check the x,y position against the wall of the pond and then change the movement add / vector
I haven’t really looked at your code but something like this:
if(x>400)
xadd = xadd * -1;
Hello,
My steps in exploring this code:
Update:
Below is NOT a solution although at first, it appeared to be so!
Initial exploration that seemed to work with my code (see GIF):
if (sqrt((pos1[1]*pos1[1] + pos1[2]*pos1[2])) > 100/5 ) //inside circle
{
f1.setth(f1.getth()+TAU/8); // fish turns
}
I had to fiddle with denominators in above (and fiddle with original code) but will leave that exploration up to you.
Avoiding glass and turning:
It does work with some tweaking:
translate(mul*pos[1] , mul*pos[2]);
translate(width/2+18*pos[1],height/2+18*pos[2]);
I will not be exploring this further anytime soon.
Have fun!
beforehand, sorry for my english. Well, I made some changes … and the fish swims in circles.
In circles…?
That’s a bit boring
Can’t you give them different kind of movement and say swim straight or swim an 8 figure…
Or when they come near a wall make either a left or right turn
Or make a U turn sometimes?
Thanks for bringing this example to us!
I had some fun with it…
There are endless possibilities!
Animated background with bubbles and plants moving would be cool!
The fish is lonely and will add more; I will assume they live in a 3D world with depth and we are only viewing in 2D so will not be concerned about them bumping into each other; that is a challenge for another day.
In the future perhaps…
Don’t be sorry be happy! You can communicate in another language and learning a programming language.
Thanks!
glv
Here it is my progress, now i’m going to improve the layout and then to start the second part : Use the concept of genetic algorithm.
Thanks my dear