Move point tests

This commit is contained in:
2019-10-13 12:35:54 +03:00
parent 0aaab2e131
commit bccff5461d
4 changed files with 28 additions and 15 deletions

View File

@ -1,19 +1,4 @@
module Game
struct Point
property x : Int32
property y : Int32
def initialize(@x : Int32, @y : Int32)
end
getter x
getter y
def distance(other) : Int32
return (other.x - @x).abs + (other.y - @y).abs
end
end
class Map
alias TileRow = Array(Tile)
alias DataArray = Array(TileRow)

14
src/game/point.cr Normal file
View File

@ -0,0 +1,14 @@
struct Game::Point
property x : Int32
property y : Int32
def initialize(@x : Int32, @y : Int32)
end
getter x
getter y
def distance(other) : Int32
return (other.x - @x).abs + (other.y - @y).abs
end
end