From 3a8d4e6e18bdf0990dbb02759c794e79afa69b62 Mon Sep 17 00:00:00 2001 From: smallkedo <111902705+smallkedo@users.noreply.github.com> Date: Mon, 24 Oct 2022 09:57:07 -0700 Subject: [PATCH] Update Chemotaxis.pde --- Chemotaxis.pde | 59 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/Chemotaxis.pde b/Chemotaxis.pde index f4f07940..8be7b183 100644 --- a/Chemotaxis.pde +++ b/Chemotaxis.pde @@ -1,13 +1,46 @@ - //declare bacteria variables here - void setup() - { - //initialize bacteria variables here - } - void draw() - { - //move and show the bacteria - } - class Bacteria - { - //lots of java! - } \ No newline at end of file +class Bacteria{ +int myX, myY; +int a, b, c; +Bacteria() +{ + myX = 500; + myY = 500; + } +void walk() +{ + if(mouseX > myX){ + myX = myX + (int)(Math.random()*200)-5; + } + else{ + myX = myX - (int)(Math.random()*200)-5; + } + if(mouseY > myY){ + myY = myY + (int)(Math.random()*200)-5; + } + else{ + myY = myY - (int)(Math.random()*200); + } +} +void show() +{ + fill((int)(Math.random()*360),(int)(Math.random()*360),(int)(Math.random()*360)); + ellipse(myX,myY,50,50); + } +} + +Bacteria [] scatter; +void setup() +{ + size(1000,1000); + scatter = new Bacteria[7]; + for(int i = 0; i < scatter.length; i++){ + scatter [i] = new Bacteria(); + } +} +void draw(){ + for(int i = 0; i < scatter.length; i++){ + scatter[i].show(); + scatter[i].walk(); + + } +}