dirty initial commit
This commit is contained in:
commit
2351c93677
24 changed files with 2203 additions and 0 deletions
27
game/Point.js
Normal file
27
game/Point.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
export default class Point {
|
||||
constructor(x,y) {
|
||||
this.x = x
|
||||
this.y = y
|
||||
}
|
||||
move(x, y) {
|
||||
this.x += x
|
||||
this.y += y
|
||||
}
|
||||
add(other) {
|
||||
return new Point(
|
||||
this.x + other.x,
|
||||
this.y + other.y
|
||||
)
|
||||
}
|
||||
sub(other) {
|
||||
return new Point(
|
||||
this.x - other.x,
|
||||
this.y - other.y
|
||||
)
|
||||
}
|
||||
distance(other) {
|
||||
const diffX = this.x - other.x
|
||||
const diffY = this.y - other.y
|
||||
return Math.sqrt(diffX * diffX + diffY * diffY)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue