【发布时间】:2021-05-24 06:33:39
【问题描述】:
谁能帮帮我?
所以,我应该有一个水平移动的球,这样每次我按下鼠标时,一个球就会垂直射出,然后由于摩擦而减速。垂直球将保持在旧位置,但球员会重置。
如何在不使用类的情况下做到这一点?
到目前为止,这是我的代码:
boolean circleupdatetostop = true;
float x = 100;
float yshot = 880;
float speedshot = random(4,10);
float speedx = 6;
void setup() {
size(1280,960);
}
void draw() {
background(255);
stroke(0);
fill(0);
circle(x,880,80);
if (x > width || x < 0 ) {
speedx = speedx * -1;
}
if (circleupdatetostop) {
x = x + speedx;
}
if (circleupdatetostop == false) {
float locationx = x;
stroke(0);
fill(255,0,255);
circle(locationx,yshot,30);
yshot = yshot - speedshot;
}
}
void mousePressed () {
circleupdatetostop = !circleupdatetostop;
}
【问题讨论】:
标签: processing