funckja getDistane

This commit is contained in:
Wojciech Łukasik 2020-04-28 13:49:03 +02:00
parent c471a54cb7
commit bed895d67d
2 changed files with 12 additions and 6 deletions

View File

@ -14,6 +14,5 @@
</div> </div>
</div> </div>
<script type="module" src="./js/main.js"></script>
</body> </body>
</html> </html>

View File

@ -64,7 +64,6 @@ class Agent{
} }
showAgent(){ showAgent(){
console.log(this.turn)
if(this.turn === "Up"){ if(this.turn === "Up"){
document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Up.png')"; document.getElementById(this.positionX + "-" + this.positionY).style.backgroundImage = "url('img/Up.png')";
} }
@ -228,16 +227,24 @@ function showBoard(board){
} }
} }
function getDistance(x1,y1,x2,y2){
var a = x1 - x2;
var b = y1 - y2;
var c = Math.sqrt(a*a + b*b);
return c
}
let board = createBoard(10,10); let board = createBoard(10,10);
board = createShelf(board); board = createShelf(board);
let agent = new Agent(0,0, 'Right'); let agent = new Agent(0,0, 'Right');
function start(){ function start(){
let board = createBoard(10,10);
let agent = new Agent(0,0, 'Right');
showBoard(board); showBoard(board);
agent.showAgent() agent.showAgent();
console.log(getDistance(2,1,0,3))
} }