Пример #1
0
void ofTurtle::draw(int _x, int _y)
{
  int ppi=pixPerInch;
  ofPoint wheel(.25*ppi,(2+3/8)*ppi);
  ofPoint rWheel(1.125*ppi,1.875*ppi);
  ofRectangle body(-3.25*ppi/2,-wheel.y/2,ppi*3.25,ppi*4.5);
  //int body=w-whlWid*2;
  //int leng=h;
  ofEnableSmoothing();
  for (unsigned int i=0; i<lines.size()-1&&lines.size()>1; i++) {
    ofSetLineWidth(2);
    ofLine(lines[i].x, lines[i].y, lines[i+1].x, lines[i+1].y);
  }
  ofDisableSmoothing();
  ofPushMatrix();
  ofTranslate(pos.x, pos.y, 0);
  ofRotate(360-bearing.absoluteAngle());
  
  ofEnableSmoothing();
  ofSetColor(black.opacity(128));
  ofRect(body.x,body.y,body.width,body.height);
  ofSetColor(white);
  ofNoFill();
  ofRect(body.x,body.y,body.width,body.height);
  ofFill();
  ofSetColor(black);
  ofRect(body.x-ppi*3/8, body.y, wheel.x, wheel.y);
  ofRect(body.x+body.width+ppi*3/32, body.y, wheel.x, wheel.y);
  /*ofSetColor(white*.8);
  ofRect(body.x+(body.width-ppi*1.375)/2, body.y+body.height, 1.375*ppi, .25*ppi);
  ofRect(body.x+(body.width-ppi*1.375)/2+1.125*ppi, body.y+body.height, .25*ppi,1.375*ppi);
  ofSetColor(white*.5);
  ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+.5*ppi, .875*ppi, 1.5*ppi);
  ofSetColor(orange);
  ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+.50625*ppi, .375*ppi, .4375*ppi);
  ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+(2.-.4375)*ppi, .375*ppi, .4375*ppi);
  ofRect(body.x+(body.width-ppi*1.375)/2+(1-.375)*ppi, body.y+body.height+(.5+(1.5-.4375)/2)*ppi, .375*ppi, .4375*ppi);*/
  ofPopMatrix();
  ofDisableSmoothing();
  
  if(!frontIsClear(frontCheckDist)) ofSetColor(255, 0, 0);
  else ofSetColor(0, 255, 0);
  ofPoint ps = pointAlongBearing(frontCheckDist+wheel.y/2);
  ofCircle(ps.x, ps.y, 5);
  
  if(!leftIsClear(leftCheckDist)) ofSetColor(255, 0, 0);
  else ofSetColor(0, 255, 0);
  ps = pos+bearing.ortho().unit()*w/2-bearing.unit()*w/2+bearing.unit().rotate(270)*leftCheckDist;
  ofCircle(ps.x, ps.y, 5);
  
  for (unsigned int i=0; i<bdy.size(); i++) {
    ofSetColor(yellow);
    ofVector t=bdy[i];
    ofLine(pos, pos+t.rotate(360-bearing.absoluteAngle()));
  }
}
Пример #2
0
/**
 * @brief Funkcia zistuje ci je na lavo od karla stena alebo koniec sveta.
 * @return Vracia TRUE ak je na  lavo od karla prekazka alebo koniec sveta. FALSE ak je na lavo od karla prazdno alebo znacka.
 */
int leftIsBlocked(void) {
    return !leftIsClear();
}
Пример #3
0
bool ofTurtle::leftIsClear(int distance)
{
  return leftIsClear(distance,map);
}