void setup() { size (700,350); background (255); } void draw () { } void mousePressed() { background((random(250)),(random(20)),(random(10))); strokeWeight (10); smooth (); fill (20, 128, random (256)); rectMode (CENTER); rect (mouseX,mouseY,70,50); } void keyPressed () { background((random(50)),150,(random(100))); }
int xspeed,yspeed; int xpos,ypos,wdth,ht; void setup() { size(700,700); background(100,255,255); xspeed=2; yspeed=4; wdth=80; ht=90; noStroke(); xpos=width/4; ypos=height/4; frameRate(50); } void draw(){ smooth(); fill((random(20)),(random(255)),(random(240)),20); ellipse(xpos,ypos,wdth,ht); smooth(); fill((random(20)),(random(255)),(random(240))); ellipse(xpos,ypos,wdth,ht); xpos+=xspeed; ypos+=yspeed; if(xpos>=width-wdth/6 || xpos<=wdth/6){ xspeed*=-5; } if(ypos>=height-ht/6 || ypos<=ht/6){ yspeed*=-1; } }
No hay comentarios:
Publicar un comentario