commit 7cdd4ea1074f37d4e7ef44deceaa2f3bdc2abbb4 Author: Aviortheking <2bazert@gmail.com> Date: Thu Feb 1 00:30:17 2018 +0100 Initial commit diff --git a/index.html b/index.html new file mode 100644 index 0000000..d69c955 --- /dev/null +++ b/index.html @@ -0,0 +1,26 @@ + + + + + + + + +
+
+ + + \ No newline at end of file diff --git a/prgm.js b/prgm.js new file mode 100644 index 0000000..2c959a2 --- /dev/null +++ b/prgm.js @@ -0,0 +1,48 @@ +var AntElement = "table-0"; + +var Prgm = { + init: function(element, width) { + table = ""; + for (t = 0; t < width; t++) { + table += ""; + for (i = 0; i < width; i++) { + table += ''; + } + table += ""; + } + element.innerHTML += table; + }, + Ant: { + prepos: [0,0], + pos: [0,0], + setAt: function(line, col) { + col--; + line--; + //window.alert(col + ", " + line + ", " + AntElement); + document.getElementById(AntElement).childNodes[0].childNodes[col].childNodes[line].classList.add("ant"); + + }, + move: function() { + pos = document.getElementsByClassName("ant")[0]; + this.pos = [pos.getAttribute("line"), pos.getAttribute("col")]; + if(this.prepos[0] == 0 && this.prepos[1] == 0) { + this.force(1, 0); + } else if(pos.classList.contains("black")) { + window.alert(this.prepos[0]+this.pos[0]+", "+this.prepos[1]+this.pos[1]); + window.alert(this.prepos); + //this.force(); + } else { + window.alert(parseInt(this.prepos[0])+parseInt(this.pos[0])+", "+(parseInt(this.prepos[1])+parseInt(this.pos[1]))); + window.alert(this.prepos); + } + //window.alert(this.pos); + }, + force: function(line, col) { + //window.alert(line+", "+col); + //window.alert((line+parseInt(this.pos[0]))+", "+(col+parseInt(this.pos[1]))); + pos = document.getElementsByClassName("ant")[0].classList.remove("ant"); + document.getElementById(AntElement).childNodes[0].childNodes[line+parseInt(this.pos[0])].childNodes[col+parseInt(this.pos[1])].classList.add("ant"); + this.prepos = this.pos; + }, + } +} \ No newline at end of file