Integrating field rendering with game
This commit is contained in:
@@ -4,7 +4,7 @@ import java.awt.Canvas;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
|
||||||
public class Field extends Canvas {
|
public class FieldCanvas extends Canvas {
|
||||||
|
|
||||||
private int size;
|
private int size;
|
||||||
private int[][] field;
|
private int[][] field;
|
||||||
@@ -47,7 +47,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int[][] getField(){
|
public int[][] getField(){
|
||||||
return null;
|
return field;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,10 +115,11 @@ public class Game {
|
|||||||
field[x][y] = nextBlocks.remove(0); // fill with the first element of nextBlocks
|
field[x][y] = nextBlocks.remove(0); // fill with the first element of nextBlocks
|
||||||
}
|
}
|
||||||
|
|
||||||
// add n new colors to nextBlocks according to the level number.
|
}
|
||||||
for(int i = 0; i < (level * 3); i++){
|
|
||||||
nextBlocks.add(rand.nextInt(numberOfColors));
|
// add n new colors to nextBlocks according to the level number.
|
||||||
}
|
for(int i = 0; i < (level * 3); i++){
|
||||||
|
nextBlocks.add(rand.nextInt(numberOfColors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.awt.event.WindowEvent;
|
|||||||
public class Window extends Frame {
|
public class Window extends Frame {
|
||||||
|
|
||||||
private Game game;
|
private Game game;
|
||||||
private Field field;
|
private FieldCanvas field;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param title
|
* @param title
|
||||||
@@ -33,7 +33,7 @@ public class Window extends Frame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
field = new Field();
|
field = new FieldCanvas();
|
||||||
field.setSize(7);
|
field.setSize(7);
|
||||||
game = new Game();
|
game = new Game();
|
||||||
|
|
||||||
@@ -42,11 +42,7 @@ public class Window extends Frame {
|
|||||||
this.setSize(400,400);
|
this.setSize(400,400);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
|
|
||||||
|
field.setField(game.getField());
|
||||||
int [][] testfield = new int[7][7];
|
|
||||||
testfield[0][0] = 2;
|
|
||||||
testfield[1][3] = 4;
|
|
||||||
field.setField(testfield);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user