0
//this is ender's game
float r = 100;
float g = 150;
float b = 200;
float a = 200;
float f = 100;
float diam = 20;
float dim = 70;
float x = 100;
float y = 100;
float z = 20;
int t = 100;
int s = 100;
int w = 60;
int h = 60;
int eyeSize = 16;
int speed = 1;
void setup() {
size(480, 270);
background(239, 172, 238);
}
void draw() {
// Draw player's head
fill(255);
ellipse(t,s-h/2,w,h);
// Draw player's eyes
fill(0);
ellipse(x-w/3+1,y-h/2,eyeSize,eyeSize*2);
ellipse(x+w/3-1,y-h/2,eyeSize,eyeSize*2);
// draw the rocks and wall
stroke(0);
//person
fill(r, f, b, a);
rect(x+(1.5*x), (y-(.05*z)), dim, diam);
// draw ellipses
fill(r, f, b, a);
ellipse(x, y+(x/2), diam, diam);
fill(r, g, f, a);
ellipse(x+(3*x), y+(.5*x), diam, diam);
fill (f, g, b, a);
ellipse(x+(2*x), y+y, diam, diam);
fill(r,f, f, f);
ellipse(x+y, y+y, diam, diam);
}
我需要能夠給玩家頭上的屏幕,鼠標點擊任意位置移動到。我還需要確保玩家在碰到岩石或牆壁時停下來。我需要能夠給玩家的磁頭移動到任何地方在屏幕上點擊鼠標時
我只是混淆瞭如何使用mousePressed或我應該使用哪種功能來實現這種情況?
無恥的自我推銷:我已經編寫了一個關於獲取用戶輸入的教程,可在[可在此處]獲得(http://happycoding.io/tutorials/processing/input)。另見喬治偉大的答案! –