terça-feira, 9 de setembro de 2014

AULA 6 - MRUV


As mudanças feitas foram a adição de textos que puxam as informações de tragetória horizontal e vertical da bola lançada que são desenhadas de acordo com a equação do MRUV.
Tive que desenhar um retângulo pois estava acontecendo um bug onde o texto ficava ilegível quando apresentado no fundo do programa.


float dv;
int v0v = 30;
float t = 0.05;
int av = -10;
float dh;
int vh = 30;

void setup() {
  size(600, 300);
  frameRate(20);
  background(150);
}

void draw() {
  Retangulo();
  textos();
  Bola();
}

void Bola() {
  dh = vh * t;
  dv = v0v * t + av * t * t / 2;
  ellipse(dh+1, 300- dv, 10, 10);
  t += 0.05;
 
  if(dv<0){
    dv = 0;
    vh = 0;
  }
}
void textos() {
  fill(255);
  textSize (20);
  text("Dist Horizontal: "+dh, 20, 20);
  text("Dist Vertical: "+dv, 20, 40);
    save ("bola.jpg");
}

void Retangulo() {
  noStroke();
  fill(150);
  rect(0, 0, 600, 100);


}

Nenhum comentário:

Postar um comentário