新人求助一个简单问题,很着急,帮帮忙吧大神们
processing吧
全部回复
仅看楼主
level 2
ly2305033 楼主
class Mover {
PVector location;
PVector velocity;
// Acceleration is the key!
PVector acceleration;
// The variable topspeed will limit the magnitude of velocity.
float topspeed;
Mover() {
location = new PVector(width/2,height/2);
velocity = new PVector(0,0);
acceleration = new PVector(-0.001,0.01);
topspeed = 10;
}
void update() {
//[full] Velocity changes by acceleration and is limited by topspeed.
velocity.add(acceleration);
velocity.limit(topspeed);
//[end]
location.add(velocity);
}
// display() is the same.
void display() {}
// checkEdges() is the same.
void checkEdges() {}
}
想用加速度做一个小汽车的模型,按键盘向上箭头的时候车加速行驶,按向下箭头的时候刹车
跪求大神帮忙 ,小车模型什么样的都可以
2015年07月28日 07点07分 1
level 2
ly2305033 楼主
跪求
2015年07月28日 07点07分 2
level 2
ly2305033 楼主
快来人啊跪求了
2015年07月28日 08点07分 3
level 6
再写一个向量,用键盘控制就好了
2015年09月20日 05点09分 4
level 3
float ax=1,dx=0.1;//ax 初始位置,dx初始速度
void setup(){
size(1000,500); //分辨率1000*500
}
void draw(){
background(0); //背景色为黑色
translate(ax,height/2);//确定当前车所在的位置
ellipse(0,0,10,5); //圆圈子就当是那辆车了
ax+=dx; //比上一个车的位置再前进dx距离
if(ax>=width) //如果车跑到屏幕外面了
ax=0; //就回到屏幕左边
}
void keyPressed() { //如果有键盘按下
if (keyCode==UP) //并且按下的是向上箭头键
dx+=0.5; //车速增加0.5
else
if(keyCode==DOWN) //如果是按的向下箭头
dx=0.1; //车速回到0.1
}
大概是这个思路吧,"车"的外观要自己做
2015年09月24日 06点09分 5
1