Mercurial > hg > Members > tatsuki > Alice
view src/alice/test/topology/aquarium/SendLocation.java @ 138:87f1a30a8c82 working
change range automatic
author | sugi |
---|---|
date | Tue, 18 Sep 2012 11:46:38 +0900 |
parents | 53aff28cde6b |
children | e58794b067f5 |
line wrap: on
line source
package alice.test.topology.aquarium; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class SendLocation extends CodeSegment { private Receiver position = ids.create(CommandType.PEEK); float x; float y; float max = 3.3f; float min = -1.3f; public SendLocation(float x,float y){ this.x = x; this.y = y; position.setKey("local", "fish"); } @Override public void run() { FishPoint fp = this.position.asClass(FishPoint.class); fp.setXY(fp.getX()+this.x, fp.getY()+this.y); /* if (fp.getX()+this.x>max){ fp.setXY(-1.0f, fp.getY()+this.y); } else if (fp.getX()+this.x< min){ fp.setXY(max, fp.getY()+this.y); } else { fp.setXY(fp.getX()+this.x, fp.getY()+this.y); } */ ods.update("local", "fish", fp); } }