Configurable map
This commit is contained in:
parent
c87db2496e
commit
50c7f658e6
@ -6,7 +6,7 @@ class App
|
||||
@ts : Game::TimePoint
|
||||
|
||||
def initialize
|
||||
@map = Game::Generator.make 5, 5
|
||||
@map = Game::Generator.make 6, 8, 10
|
||||
@ts = Time.local.to_unix
|
||||
@world = Game::World.new @map, @ts
|
||||
@buildings = Game::BuildingFactory.new
|
||||
|
@ -62,10 +62,10 @@ module Game
|
||||
end
|
||||
|
||||
class Generator
|
||||
def self.make(rows, cols) : Map
|
||||
def self.make(rows, cols, deposits = 5) : Map
|
||||
rnd = Random.new
|
||||
map = Map.new(rows, cols)
|
||||
5.times do
|
||||
deposits.times do
|
||||
point = Point.new(rnd.rand(0...rows), rnd.rand(0...cols))
|
||||
cap = rnd.rand(2...6)
|
||||
deposit = Deposit.new(Resource::Type::Crystals, cap * 50)
|
||||
|
Loading…
Reference in New Issue
Block a user