Random walking

edited March 2018 in Questions about Code

Hi! I want to make a very simple random walking program. Could anyone tell me why the code below doesn't work? thanks in advance `void setup(){ size(700,700); background(#E2DCE3); }

void draw(){

int x,y; x=100; y=200;

int r = (int)random(0,4);

if(r==0){ x++; }else if(r==1){ y++; }else if(r==2){ x--; }else{ y--; }

point(x,y); }`

Tagged:

Answers

Sign In or Register to comment.