?? velocity.java
字號:
package game.entities;
//汽車的物理系統類(速度控制)
public class Velocity {
float speed = 0;
float bottom = 0.05f;
public Velocity() {
}
public float accelerate(){
if (speed == 0.0f)
speed = bottom;
else
speed = speed + ((top - speed) / 40);
if (speed > top)
speed = top;
return speed;
}
public float brake(){
speed = speed - ((top-speed) / 10);
if (speed < bottom) speed = 0;
return speed;
}
public float brake( int drag ){
speed = speed - ((top-speed) / drag);
if (speed < bottom) speed = 0;
return speed;
}
static float top = 0.5f; // m/s
public float getSpeed()
{
return speed;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -