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
...
int x = 160; int y = 20; int oldx = x; int oldy = y; double laserx1 = x; double lasery1 = y; double laserx2 = x; double lasery2 = y; boolean laserattack = false; int laserdistance = 1; int countl = 0; boolean jumping = false; int jumpvalue = 0; int maxjump = 20; int live = 250; boolean nodo = false; double badds_x = random(319); double badds_y = random(319); boolean living = true; int pc = 10; void draw() { oldx = x; oldy = y; background(0, 255, 255); fill(255, 0, 255); if (mousePressed) { x = mouseX; y = mouseY; } else { x = oldx; y = oldy; } if (living) { triangle(badds_x, badds_y, badds_x+15, badds_y-30, badds_x+30, badds_y); strokeWeight(5); point(badds_x, badds_y); strokeWeight(1); } fill(255, 126, 0); rect(0, 240, 50, 10); rect(0, 140, 50, 10); rect(269, 240, 50, 10); rect(269, 140, 50, 10); rect(135, 80, 50, 10); if (x >= badds_x && x <= badds_x+30) { if (y >= badds_y-30 && y <= badds_y) { live = 0; } } if (laserx1 == badds_x) { if (lasery1 == badds_y) { living = false; } } if (laserx2 == badds_x) { if (lasery2 == badds_y) { living = false; } } if (x >= 135 && x <= 185) { if (y >= 80 && y <= 90) { y -= 4; } } if (x >= 269 && x <= 319) { if (y >= 140 && y <= 150) { y -= 4; } } if (x >= 269 && x <= 319) { if (y >= 240 && y <= 250) { y -= 4; } } if (x >= 0 && x <= 50) { if (y >= 140 && y <= 150) { y -= 4; } } if (x >= 0 && x <= 50) { if (y >= 240 && y <= 250) { y -= 4; } } if (laserattack) { laserx1 = x; laserx2 = x; lasery1 = y; lasery2 = y; line(laserx1, lasery1, laserx1+pc, lasery1); line(laserx2, lasery2, laserx2-pc, lasery2); pc += 2; if (pc == 60) { pc -= 4; } if (countl == laserdistance) { laserattack = false; } else { countl += 1; } } else { pc = 10; } if (live > 0) { if (keyPressed) { if (key == "s") { countl = 0; laserattack = true; } if (key == "m") { live = 0; } if (key == "d") { if (x >= 319) { live -= 10; x = 299; } else { x += 2; } } if (key == "a") { if (x <= 0) { live -= 10; x = 20; } else { x -= 2; } } if (key == "w") { jumping = true; } } } if (jumping == false) { if (live > 0) { if (y < 299) { y += 4; } } else { y += 24; } } else { y -= 6; jumpvalue += 1; if (jumpvalue == maxjump) { jumping = false; jumpvalue = 0; } } int sx = x; int sy = y-70; fill(live, live, live); if (live > 0) { ellipse(x, y, 40, 40); fill(255, 255, 255-live); ellipse(x, y, 15, 15); } else { if (nodo == false) { y = 0; x = 160; println("Has muerto"); } nodo = true; fill(255, 0, 0); noStroke(); ellipse(sx-20, sy, 40, 40); ellipse(sx+40, sy, 40, 40); rect(sx-20, sy-20, 60, 40); rect(sx-10, sy, 40, 70); fill(0, 0, 0); ellipse(sx+10, sy+50, 35, 30); stroke(0); strokeWeight(5); point(sx-20, sy); point(sx+40, sy); strokeWeight(1); } } void main() { println("_____________Controles___________"); println("| |"); println("| W -> Saltar |"); println("| Izquierda <- A D -> Derecha |"); println("| Disparar <-S |"); println("|_______________________________|"); println(" "); println("______________Mision_____________"); println("| |"); println("| - Destruir el triangulo lila |"); println("| atacandole justamente en el |"); println("| punto negro. |"); println("|_______________________________|"); println(" "); animate(draw); }
Canvas not supported.
Programado por
segfaultdev
2 votos
346 descargas
104 usos