Changeset 584
- Timestamp:
- 08/18/16 21:37:53 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experiments/frams/foraminifera/data/scripts/foraminifera.expdef
r583 r584 563 563 } 564 564 565 function fence( pos, zone) //TODO consider sizes (bboxes) of creatures and nutrients consistently throughout this expdef566 { 567 return Math.min(Math.max(0 ,pos),World.wrldsiz);565 function fence(center, zone) 566 { 567 return Math.min(Math.max(0+zone,center),World.wrldsiz-zone); //add and subtract zone from the world size to prevent reticulopodia from crossing the fence 568 568 } 569 569 … … 571 571 { 572 572 //adjustment in z axis 573 var change_direction = 0; 574 var new_x = fence(cr.pos_x, getZoneRange(cr, 1)); 575 var new_y = fence(cr.pos_y, getZoneRange(cr, 1)); 576 577 if ((new_x != cr.pos_x) || (new_y != cr.pos_y) || (cr.data->lifeparams->dir_counter >= int(secToSimSteps(ExpProperties.dir_change_sec)))) 578 { 579 change_direction = 1; 580 } 581 582 cr.moveAbs(new_x, new_y, -cr.getPart(cr.numparts-1).sx); //place slightly under the bottom surface ("z" value depends on the size of the last=largest chamber) 573 cr.moveAbs(cr.pos_x, cr.pos_y, -cr.getPart(cr.numparts-1).sx); //place slightly under the bottom surface ("z" value depends on the size of the last=largest chamber) 583 574 584 575 //are there any nutrients in zone 1 or 2? … … 590 581 return; 591 582 } 583 } 584 585 //Prevents forams from crossing the world border. In the case of touching the border with the reticulopodia direction of the movement should be changed. 586 var change_direction = 0; 587 var new_x = fence(cr.center_x, getZoneRange(cr, 1)); 588 var new_y = fence(cr.center_y, getZoneRange(cr, 1)); 589 590 if ((new_x != cr.center_x) || (new_y != cr.center_y) || (cr.data->lifeparams->dir_counter >= int(secToSimSteps(ExpProperties.dir_change_sec)))) 591 { 592 change_direction = 1; 593 cr.moveAbs(new_x-cr.size_x/2, new_y-cr.size_y/2, -cr.getPart(cr.numparts-1).sx); 592 594 } 593 595 … … 786 788 var nut = Populations[2].add("//0\nm:Vstyle=nutrient_visual\np:sh=2,sx="+nutsize+",sy="+nutsize+",sz="+nutsize+",ry=1.5,vr=0.0,1.0,0.0"); 787 789 cr.data->reticulopodiacreature = nut; 788 nut.moveAbs(cr.pos_x- 1.5*nutsize, cr.pos_y-1.5*nutsize, -nutsize); //TODO replace -1.5 with the properly calculated value, now nutsize=1, cr.size=0.28284271790 nut.moveAbs(cr.pos_x-nutsize, cr.pos_y-nutsize, -nutsize); 789 791 } 790 792 }
Note: See TracChangeset
for help on using the changeset viewer.