本文整理汇总了PHP中Track::lane_length方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::lane_length方法的具体用法?PHP Track::lane_length怎么用?PHP Track::lane_length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Track
的用法示例。
在下文中一共展示了Track::lane_length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cos
$old_direction = $horse_detail->get_direction();
$heading_x = $old_pos_x + cos($old_direction) * 20;
$heading_y = $old_pos_y - sin($old_direction) * 20;
// find the angle between the heading and the target
$angle = $track->find_angle($heading_x, $heading_y, $old_pos_x, $old_pos_y, $target_pt[0], $target_pt[1]);
// Calculate new heading (old direction adjusted by the angle between heading and target
$new_direction = $old_direction - $angle / 20;
// optional debug information
/*if ($horseid == 1) {
print "TS: $ts pos=($old_pos_x, $old_pos_y) tar=(${target_pt[0]}, ${target_pt[1]}) head=($heading_x, $heading_y) lane=(${lane_pt[0]},${lane_pt[1]}) [$old_lane] dir=$new_direction $ angle = $angle\n";
}*/
// TODO: adjust current speed
// check collision with horse ahead and slow down if needed
$distance_to_my_nose = $track->distance_along_lane($old_lane, $lane_pt[0], $lane_pt[1]);
// adjust for number of laps around
$distance_to_my_nose += $track->lane_length($old_lane) * $horse_detail->get_lap_counter();
foreach ($horses as $h) {
/** @var horse_details $hd */
$hd = $game_state->get_details($h->get_id());
if ($h->get_id() == $horseid) {
continue;
}
if ($hd->get_lane() != $old_lane) {
continue;
}
$distance_to_their_nose = $track->distance_along_lane($hd->get_lane(), $hd->get_position_x(), $hd->get_position_y());
// adjust for number of laps around
$distance_to_their_nose += $track->lane_length($hd->get_lane()) * $hd->get_lap_counter();
if ($distance_to_their_nose < $distance_to_my_nose) {
continue;
}