
// 计算 t 秒后的速度
double v=v0-g*t;
// 作为下次移动初始速度
speed =v;
// 计算垂直位移
s=v0*t-0.5*g*t*t;
// 让鸟移动位移
y=y-(int)s;
// 鸟飞行的时候给他一个角度
alpha=Math.atan(s/20);
//x 显示鸟飞行时的动画
index ++;
img = imgs[(index/10)%8];
}
public void flappy() {
// TODO Auto-generated method stub
speed=20;
}
// 是否撞击了竹子
public boolean hit(Colum c1) {
// TODO Auto-generated method stub
int x1=c1.x-c1.width/2-size/2;
int x2=c1.x+c1.width/2+size/2;
int y1=c1.y-c1.gap/2+size/2;
int y2=c1.y+c1.gap/2-size/2;
if(x>x1&&x<x2){
if(y>y1&&y<y2){
return false;
}
return true;
}
return false;
}
// 是否撞击了地面
public boolean hit(Ground ground) {
// TODO Auto-generated method stub
return (y+height/2)>ground.y;
}
}