forked from s444420/AL-2020
funckja getDistane
This commit is contained in:
parent
c471a54cb7
commit
bed895d67d
@ -14,6 +14,5 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script type="module" src="./js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -64,7 +64,6 @@ class Agent{
|
||||
}
|
||||
|
||||
showAgent(){
|
||||
console.log(this.turn)
|
||||
if(this.turn === "Up"){
|
||||
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);
|
||||
board = createShelf(board);
|
||||
|
||||
let agent = new Agent(0,0, 'Right');
|
||||
|
||||
function start(){
|
||||
let board = createBoard(10,10);
|
||||
let agent = new Agent(0,0, 'Right');
|
||||
showBoard(board);
|
||||
agent.showAgent()
|
||||
agent.showAgent();
|
||||
|
||||
console.log(getDistance(2,1,0,3))
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user