/*
2D TEXT follow sample
lang: Lite-C 1.70?
move "PL" TEXT with arrows
"AI" TEXT follows
2009.09.30a
*/
TEXT* ai_t = {
pos_x = 10;
pos_y = 10;
string("AI");
layer = 100;
flags = VISIBLE;
}
TEXT* pl_t = {
pos_x = 50;
pos_y = 70;
string("PL");
layer = 100;
flags = VISIBLE;
}
/******************************
textf_follow
call once from main
*******************************/
function textf_follow() {
var dist; dist = 0;
while(1) {
pl_t.pos_x += (key_cur - key_cul) * 2.5 * time_step;
pl_t.pos_y += (key_cud - key_cuu) * 2.5 * time_step;
dist = sqrt(pow(pl_t.pos_x - ai_t.pos_x, 2) + pow(pl_t.pos_y - ai_t.pos_y, 2));
if (dist > 5) {
ai_t.pos_x += sign(pl_t.pos_x - ai_t.pos_x) * 2.5 * time_step;
ai_t.pos_y += sign(pl_t.pos_y - ai_t.pos_y) * 2.5 * time_step;
}
wait(1);
}
}