-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathpingpong.js
More file actions
57 lines (50 loc) · 1.4 KB
/
Copy pathpingpong.js
File metadata and controls
57 lines (50 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//aqui eu vou criar a bolinha
let xBolinha = 300;
let yBolinha = 200;
let tamBolinha = 25;
//config velocidade bolinha
let xvelocidadeBolinha = 6;
let yvelocidadeBolinha = 6;
//configura raquete
let xRaquete = 5;
let yRaquete = 150;
let larguraRaquete = 10;
let alturaRaquete = 90;
function setup(){
//aqui vou criar minha "mesa"
createCanvas(600,400);
}
function draw(){
//função responsável pelo "desenho e animação da mesa"
//aqui vou por a cor da "mesa"
//A cor da mesa é em rgb
background(128,128,0);
//chamando a função cria bolinha para criar a bolinha
criaBolinha(xBolinha, yBolinha, tamBolinha);
//chamando a função mov bolinha
moveBolinha();
//chamando a borda
Borda();
}
//função bolinha
function criaBolinha(xBolinha, yBolinha,tamBolinha){
circle (xBolinha,yBolinha,tamBolinha);
}
//função move bolinha
function moveBolinha(){
xBolinha = xvelocidadeBolinha + xBolinha;
yBolinha = yvelocidadeBolinha + yBolinha;
}
function Borda(){
if (xBolinha > width || xBolinha < 0){
xvelocidadeBolinha *= -1;
}
if (yBolinha > height || yBolinha < 0){
yvelocidadeBolinha *= -1;
}
}
function criaRaquete(xRaquete, yRaquete, larguraRaquete, alturaRaquete){
fill("blue");
rect(xRaquete, yRaquete, larguraRaquete, alturaRaquete);
}
///dasawdassfdSDGASDFgdsGSDA