-
Notifications
You must be signed in to change notification settings - Fork 1
/
p5.js
93 lines (70 loc) · 2.2 KB
/
p5.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//MAPA DE BLOCOS
function preload() {
img = loadImage('tiles/tiles.png');
}
class ElementoMapa{
constructor(posx,posy,cor,tam){
this.x =posx;
this.y = posy;
this.cor = cor;
this.tam = tam;
this.draw = function(){
//fill(this.cor);
//noFill();
Image(img,0,0);
//square(this.x,this.y,this.tam);
rect(0,0,this.tam,this.tam);
}
}
}
class BlocoAzul extends ElementoMapa{
constructor(posx,posy){
super(posx,posy,'blue',50);
}
}
class BlocoVermelho extends ElementoMapa{
constructor(posx,posy){
super(posx,posy,'red',50);
}
}
class BlocoAmarelo extends ElementoMapa{
constructor(posx,posy){
super(posx,posy,'yellow',50);
}
}
class BlocoPreto extends ElementoMapa{
constructor(posx,posy){
super(posx,posy,'black',50);
}
}
var maps = [
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,1],
[1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,1],
[1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1],
[1,1,1,1,1,0,1,0,0,1,1,1,2,1,1,1,0,0,0,0,1,1,1,1,1],
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
[1,1,1,1,1,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1],
[1,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1],
[1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
];
var Elementos = [];
function setup(){
const blocos = [BlocoPreto, BlocoAzul, BlocoAmarelo, BlocoVermelho];
createCanvas(800, 800);
for (let i = 0; i < maps.length; i++) {
for(let j=0;j< maps[i].length;j++) {
Elementos.push(new blocos[maps[i][j]](j*50,i*50));
}
}
}
function draw(){
for (let i = 0; i < Elementos.length; i++) {
Elementos[i].draw();
}
}