This site requires JavaScript, please enable it in your browser!
Greenfoot back
steven0784
steven0784 wrote ...

2012/3/3

how to make ai check for more than one piece of cover?

steven0784 steven0784

2012/3/3

#
i have a move method but i think i don;t know how to make it so that the soliders will check if there is more than one cover on screen private void move() { List b=getWorld().getObjects(NaziCover.class); int Distx, Disty; double angle; if(b.size()>0) { NaziCover B=(NaziCover)b.get(0); if (B.getUnderCover() <= 2) { Distx=getX()-B.getX(); Disty=getY()-B.getY(); angle=Math.toDegrees(Math.atan2(Disty,Distx))+180; //The next part of the code make the zombie move forward depending of his speed and direction angle = Math.toRadians( (int)angle ); int x = (int) Math.round(getX() + Math.cos(angle) * Speed); int y = (int) Math.round(getY() + Math.sin(angle) * Speed); setLocation(x, y); if(u == 1) { B.UnderCover(); h = 1; u--; } else { } } else { if( h ==1) { Distx=getX()-B.getX(); Disty=getY()-B.getY(); angle=Math.toDegrees(Math.atan2(Disty,Distx))+180; //The next part of the code make the zombie move forward depending of his speed and direction angle = Math.toRadians( (int)angle ); int x = (int) Math.round(getX() + Math.cos(angle) * Speed); int y = (int) Math.round(getY() + Math.sin(angle) * Speed); setLocation(x, y); } else { setLocation(getX() - 5, getY()); } } } } so how do i make it so they check for more than one piece of cover so that if one is full the other one will check if there is more cover instead of just moving left.
You need to login to post a reply.