-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTablero.java
70 lines (56 loc) · 1.86 KB
/
Tablero.java
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
package com.mygdx.dots;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
/**
* Created by LozanoBethke1 on 11-01-2017.
*/
public class Tablero {
private Casilla matriz[][];
public int nfilas=6;
public int ncolumnas=6;
public int i=0,j=0;
private float z,w;
int aux,contador=0,contseleccionadas=0;
public int color;
public int rectlinecolor;
public Tablero() {
this.matriz = new Casilla[nfilas][ncolumnas];
}
public void LlenarMatriz(){
for (int x=0; x < matriz.length; x++) {
for (int y=0; y < matriz[x].length; y++) {
matriz[x][y]= new Casilla();
}
}
}
//w/9 z/15
public void draw(SpriteBatch batch, MyDotsGame game){
// w=MyDotsGame.Worldsize/6;
w=0;
//Coordenadas para pintar , pq ya estan usadas X y Y
for (int x=0; x < matriz.length; x++) {
// z=MyDotsGame.Worldsize/6; //seria el primero de abajo
z=0;
for (int y=0; y < matriz[x].length; y++)
{ //Pinta la primera columna
Texture texture = game.getImage(matriz[x][y].getColor());
batch.draw(texture,w,z,45,45);
z+=MyDotsGame.Worldsize/6;
}
w+=MyDotsGame.Worldsize/6; //pasa a la 2da columna
}
}
public void RectLineColor(int x,int y){
w=MyDotsGame.Worldsize/6;z=MyDotsGame.Worldsize/6;
int contadorcolumna=0, contadorfila=0;
while(x<w){
w+=MyDotsGame.Worldsize/6;
contadorcolumna++;
}
while(y<z){
z+=MyDotsGame.Worldsize/6;
contadorfila++;
}
this.rectlinecolor = matriz[contadorfila][contadorcolumna].getColor();
}
}