37 lines
984 B
HTML
37 lines
984 B
HTML
<html><pre id="log"></pre><body><script>
|
|
!function(){var n=document.getElementById("log");console.log=function(){for(var i=0;i<arguments.length;i++)"object"==typeof arguments[i]?n.innerHTML+=(JSON&&JSON.stringify?JSON.stringify(arguments[i],void 0,2):arguments[i])+"<br />":n.innerHTML+=arguments[i]+"<br />"}}();
|
|
|
|
class Player {
|
|
constructor(startX, startY) {
|
|
this.x = startX;
|
|
this.y = startY;
|
|
}
|
|
|
|
move(dx, dy) {
|
|
this.x += dx;
|
|
this.y += dy;
|
|
}
|
|
}
|
|
let player1 = new Player(0,0);
|
|
|
|
let player2 = new Player(0,0);
|
|
|
|
console.log(player2.x)
|
|
console.log(player2.y)
|
|
console.log(player2.move(-3,10))
|
|
console.log(player2.x)
|
|
console.log(player2.y)
|
|
console.log(player2.move(4,-7))
|
|
console.log(player2.x)
|
|
console.log(player2.y)
|
|
|
|
console.log(player1.x)
|
|
console.log(player1.y)
|
|
console.log(player1.move(-20,4))
|
|
console.log(player1.x)
|
|
console.log(player1.y)
|
|
console.log(player1.move(16,-9))
|
|
console.log(player1.x)
|
|
console.log(player1.y)
|
|
|
|
</script></body></html> |