码迷,mamicode.com
首页 > 其他好文 > 详细

dead reckoning variation

时间:2015-01-05 18:05:08      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

Targeting

A target is a structure of information that describes the state, and change of state, of an object that exists in a remote person‘s instance of a game.

When you fire your laser, you send a packet of data to the server saying that

  1. You shot the laser,
  2. It was shot at some position in space (ox,oy) and
  3. that it‘s moving straight up.

 

for each frame {

  target.x_velocity = target.x_velocity + target.x_acceleration;

  target.y_velocity = target.y_velocity + target.y_acceleration;

  target.z_velocity = target.z_velocity + target.z_acceleration;

 

  target.x_position = target.x_position + target.x_velocity;

  target.y_position = target.y_position + target.y_velocity;

  target.z_position = target.z_position + target.z_velocity;

    smooth();

 

}

smooth(){

  laser.x = (laser.x + target.x_position) / 2;

  laser.y = (laser.y + target.y_position) / 2;

  laser.z = (laser.z + target.z_position) / 2;

}

 

smooth2(){

  laser.x = (laser.x * 99 + target.x_position) / 100;

  laser.y = (laser.y * 99 + target.y_position) / 100;

  laser.z = (laser.z * 99 + target.z_position) / 100;

}

dead reckoning variation

标签:

原文地址:http://www.cnblogs.com/lightlfyan/p/4203885.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!