Aula 04 – Parcial Pong

24 março, 2009 (18:11) | games | Por: admin

Gerado na aula de 25/3/2009 - Turma B
float xB,yB,vBx,vBy; //define variavel
int pontos;
void setup() {
  size(400,300);
  noCursor();
  xB=width/2; // inicializar variavel
  yB=height/2;
  vBx=1; // 1 pixel / frame
  vBy=1; // 1 pixel / frame
}
void draw() {
  xB = xB + vBx;
  yB = yB + vBy;
  if(yB>height) {
    vBy = -1;
  }
  if(xB>width) {
    vBx = -1;
  }
  if(yB<0) {
    vBy = 1;
  }
  // Verifica se a bola rebate!
  if( xB>10 && xB < 20 && yB > mouseY && yB < mouseY+40) {
    vBx = 1;
  }
  if(xB<0) {
    xB = width/2;
    yB = height/2;
  }
  background(0);
  rect(10,mouseY,10,40);
  ellipse(xB,yB,5,5);
}

Comentários

Pingback de Introdução à Programação 1 e 2 (2009) » Exercício P03 – Tudo até agora
Data: 31 de março de 2009 Hora: 18:18

[...] Baseado no código do Pong, crie um novo jogo. Use sua criatividade e aplique tudo que você aprendeu até agora! Algumas [...]

Escreva um comentário