Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var vel = 2;
- var vel2 = 4;
- var vel3 = 4;
- var velBici = 3;
- var altura = 20;
- var largura = 30;
- function setup() {
- createCanvas(400, 700);
- robot1 = 0 + int((((width / 2) - largura) - 0 + 1) * random());
- robot2 = 0 + int((((width / 2) - largura) - 0 + 1) * random());
- robot3 = 0 + int((((width / 2) - largura) - 0 + 1) * random());
- }
- function draw() {
- background(220);
- desenharRobot(robot1, (350), largura, altura);
- desenharRobot(robot2, (460), largura, altura);
- desenharRobot(robot3, (570), largura, altura);
- vel = vel * baterParede(robot1, largura, vel);
- vel2 = vel2 * baterParede(robot2, largura, vel2);
- vel3 = vel3 * baterParede(robot3, largura, vel3);
- robot1 = robot1 + vel;
- robot3 = robot3 + vel3;
- }
- function desenharRobot(x, y, largura, altura) {
- if (largura > altura)
- raio = altura / 5;
- else
- raio = largura / 5;
- rect(x, y - 25, largura, altura); //cabeça
- line(x + 15, y, x + 15, y - 5); //pescoço
- line(x + 55, y, x - 30, y); //tronco linha
- line(x + 55, y, x + 55, y + 30); //mao direita
- line(x - 30, y, x - 30, y + 30); //mao esquerda
- rect(x, y, largura, altura * 2); // tronco retangulo
- line(x, y, x, y + 80); //perna esqueda
- line(x + 30, y, x + 30, y + 80); //perna direita
- ellipse(x, y + 80, 2 * raio, 2 * raio); // perna bola esquerda
- ellipse(x + 30, y + 80, 2 * raio, 2 * raio); // perna bola direita
- }
- function baterParede(xrobot, largura) {
- if (xrobot > width - largura) {
- return -1;
- } else if (xrobot < 0) {
- return -1;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement