diff --git a/.gitignore b/.gitignore index 32858aa..a031ac2 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +/bin/ diff --git a/src/ch/bfh/sevennotseven/Field.java b/src/ch/bfh/sevennotseven/Field.java new file mode 100644 index 0000000..0d718e6 --- /dev/null +++ b/src/ch/bfh/sevennotseven/Field.java @@ -0,0 +1,55 @@ +package ch.bfh.sevennotseven; + +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Graphics; + +public class Field extends Canvas { + + private int size; + private int[][] field; + + static final Color[] colors = {Color.red,Color.green, Color.blue, Color.yellow,Color.magenta}; + + public void setSize(int s) { + this.size = s; + } + + public void setField(int[][] field){ + this.field = field; + + } + + + public void paint(Graphics g) { + g.setColor(Color.lightGray); + + int total = this.getHeight(); + int space = total/size; + + g.setClip(0, 0, total,total); + g.fillRect(0, 0, total,total); + + g.setColor(Color.white); + + for(int i=0; i<=size; i++) { + g.drawLine(0,i*space,total,i*space); + g.drawLine(i*space,0,i*space,total); + } + + if(field==null) return; + + for(int x=0; x