Changeset 584


Ignore:
Timestamp:
08/18/16 21:37:53 (8 years ago)
Author:
oriona
Message:

Positions of foraminifera, reticulopodia and nutrients corrected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • experiments/frams/foraminifera/data/scripts/foraminifera.expdef

    r583 r584  
    563563}
    564564
    565 function fence(pos, zone) //TODO consider sizes (bboxes) of creatures and nutrients consistently throughout this expdef
    566 {
    567         return Math.min(Math.max(0,pos),World.wrldsiz);
     565function 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
    568568}
    569569
     
    571571{
    572572        //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)
    583574
    584575        //are there any nutrients in zone 1 or 2?
     
    590581                        return;
    591582                }
     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);
    592594        }
    593595
     
    786788                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");
    787789                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.28284271
     790                nut.moveAbs(cr.pos_x-nutsize, cr.pos_y-nutsize, -nutsize);
    789791        }
    790792}
Note: See TracChangeset for help on using the changeset viewer.