Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What object is this cross in a circle?
#9
The "f" is used to express a literal float value in C++, it doesn't exist in CBOT.
Code:
// orientation is the direction the object is facing. 0-360
// 0 and 360 == east
// 90 == north and 180 == west

// To calculate a point 5 meters behind an object

float dist = -5.0; // <------change this to 5.0 to go in front of the object
point pos = item.position;
float ori = item.orientation;

// calculate the difference
float dx = dist * cos(ori);  // cos() is used for x
float dy = dist * sin(ori);  // sin() is used for y

// add that to object position
pos.x += dx;
pos.y += dy;

goto(pos);
turn( direction(item.position) );


Messages In This Thread
RE: What object is this cross in a circle? - by melex750 - 03-19-2016, 07:20 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)