Toggle navigation
Explora
(current)
Aprende
Crea
Retos
×
Aspectos básicos
void main() {...}
for ( int i = 0 ; i < N ; i++ ) {...}
while (condición) {...}
do {...} while (condición);
if (condición) {...}
if (condición) {...} else {...}
switch (valor) {...}
Mostrar y pedir datos
print()
println()
readInteger()
readDouble()
readChar()
readString()
Funciones matemáticas
abs(n)
log(n)
sqrt(n)
pow(b,e)
floor(n)
ceil(n)
round(n)
sin(n)
cos(n)
tan(n)
asin(n)
acos(n)
atan(n)
random(n)
Funciones gráficas
point(x,y)
line(x1,y1,x2,y2)
ellipse(x,y,w,h)
rect(x,y,w,h)
triangle(x1,y1,x2,y2,x3,y3)
text(msg,x,y)
textWidth(msg)
textSize(n)
background(r,g,b,a)
strokeWeight(n)
stroke(r,g,b,a)
noStroke()
fill(r,g,b,a)
noFill()
image(url, x,y,w,h)
Nuevo
Ayuda
Probar
...
void main() { dirX = (round(random(0, 1))*2)-1; animate(draw); } int by = 160; double ballX = 160; double ballY = 160; int dirX = 1; int dirY = 1; double speed = 10; void draw() { background(0, 0, 0, 0.5); fill(255); noStroke(); int ay = 319-mouseY; rect(15, ay-30, 15, 60); rect(ballX-7.5, ballY-7.5, 15, 15); ballX += dirX*speed; ballY += dirY*speed; if (ballX >= 15 && ballX <= 30) { if (ballY >= ay-30 && ballY <= ay+30) { dirX = -dirX; ballX = 31; speed *= 1.01; } else { by = 160; ballX = 160; ballY = 160; dirX = (round(random(0, 1))*2)-1; dirY = 1; speed = 10; } } if (ballX >= 320-30) { ballX = 320-31; dirX = -dirX; speed *= 1.01; } rect(320-30, ballY-30, 15, 60); if (ballY >= 313) { ballY = 312; dirY = -dirY; } if (ballY <= 7) { ballY = 8; dirY = -dirY; } }
Canvas not supported.
Programado por
segfaultdev
0 votos
163 descargas
33 usos