diff options
Diffstat (limited to 'Scripts/world.lua')
-rw-r--r-- | Scripts/world.lua | 233 |
1 files changed, 118 insertions, 115 deletions
diff --git a/Scripts/world.lua b/Scripts/world.lua index 40d7218..f1d2b66 100644 --- a/Scripts/world.lua +++ b/Scripts/world.lua @@ -1,133 +1,136 @@ -world = { - Seed = 5345345, - Layers = 2, - - -- This is run when the world is registered and not after, - -- although it is possible to register materials later - Register = function(self) - - -- TODO make world have global textures to speed up rendering - self:registerMaterial("grass", { - -- TODO combine both of these into 1 - texture = { - file = "Assets/world.png", - offset = { x = 0, y = 0 }, - size = { x = 64, y = 64 } - }, - normal = { - file = "Assets/world_normal.png", - offset = { x = 0, y = 0 }, - size = { x = 64, y = 64 } - } - }); - self:registerMaterial("dirt", { - texture = { - file = "Assets/world.png", - offset = { x = 64, y = 0 }, - size = { x = 64, y = 64 } - }, - normal = { - file = "Assets/world_normal.png", - offset = { x = 64, y = 0 }, - size = { x = 64, y = 64 } - } - }); - self:registerMaterial("stone", { - texture = { - file = "Assets/world.png", - offset = { x = 128, y = 0 }, - size = { x = 64, y = 64 } - }, - normal = { - file = "Assets/world_normal.png", - offset = { x = 128, y = 0 }, - size = { x = 64, y = 64 } - } - }); - self:registerMaterial("flower", { - texture = { - file = "Assets/world.png", - offset = { x = 192, y = 0 }, - size = { x = 64, y = 64 } - }, - normal = { - file = "Assets/world_normal.png", - offset = { x = 192, y = 0 }, - size = { x = 64, y = 64 } - }, - passable = true - }); - self:registerMaterial("trunk", { - texture = { - file = "Assets/world.png", - offset = { x = 256, y = 0 }, - size = { x = 64, y = 64 } - }, - normal = { - file = "Assets/world_normal.png", - offset = { x = 256, y = 0 }, - size = { x = 64, y = 64 } - } - }); - end, - - Generate = function(self) - math.randomseed(self.Seed) - xsize, ysize, zsize = self:setSize(250, 128, 3) - for Z = 0,zsize-1 do - for X = 0,xsize-1 do - if Z == 0 then - YGen = math.floor(6*math.sin(X/20)) + 64 - elseif Z == 1 then - YGen = math.floor(9*math.sin(X/20)) + 64 - else - YGen = math.floor(15*math.sin(X/20)) + 64 - end - YDepth = math.random(3,5) - for Y = 0,ysize-1 do - if Y == YGen then - self:setData(X, Y, Z, "grass"); - elseif Y < YGen and Y > (YGen - YDepth) then - self:setData(X, Y, Z, "dirt"); - elseif Y < YGen then - self:setData(X, Y, Z, "stone"); - elseif Y == YGen + 1 then - if math.random(0, 100) == 53 then - self:setData(X, Y, Z, "flower"); - elseif math.random(0, 100) == 45 then - self:setData(X, Y, Z, "trunk"); - end - end - --print(X..","..Y..","..Z); - end - end - end - self:setData(1000, 1345, 5, "grass"); -- Test error checking - print("Done with world gen"); - end -} - ---world:Generate() -game.worldRegister(world) - newWorld = { Register = function(self) self.unitSize = 8; self:createLayer(0, { texture = { file = "Assets/world/world1/layers/0/texture.png" }, normal = { file = "Assets/world/world1/layers/0/normal.png" }, - hitbox = { file = "Assets/world/world1/layers/0/hitbox.png" } + hitbox = "Assets/world/world1/layers/0/hitbox.png" }); self:createLayer(1, { texture = { file = "Assets/world/world1/layers/1/texture.png" }, normal = { file = "Assets/world/world1/layers/1/normal.png" }, - hitbox = { file = "Assets/world/world1/layers/1/hitbox.png" } + hitbox = "Assets/world/world1/layers/1/hitbox.png" }); self:createDecoLayer(10, { texture = { file = "Assets/world/world1/layers/deco/texture.png" }, normal = { file = "Assets/world/world1/layers/deco/normal.png" }, }); end, - Generate = function(self) end + Generate = function(self) + print("Generating"); + end } + game.worldRegister(newWorld); + +--world = { +-- Seed = 5345345, +-- Layers = 2, +-- +-- -- This is run when the world is registered and not after, +-- -- although it is possible to register materials later +-- Register = function(self) +-- +-- -- TODO make world have global textures to speed up rendering +-- self:registerMaterial("grass", { +-- -- TODO combine both of these into 1 +-- texture = { +-- file = "Assets/world.png", +-- offset = { x = 0, y = 0 }, +-- size = { x = 64, y = 64 } +-- }, +-- normal = { +-- file = "Assets/world_normal.png", +-- offset = { x = 0, y = 0 }, +-- size = { x = 64, y = 64 } +-- } +-- }); +-- self:registerMaterial("dirt", { +-- texture = { +-- file = "Assets/world.png", +-- offset = { x = 64, y = 0 }, +-- size = { x = 64, y = 64 } +-- }, +-- normal = { +-- file = "Assets/world_normal.png", +-- offset = { x = 64, y = 0 }, +-- size = { x = 64, y = 64 } +-- } +-- }); +-- self:registerMaterial("stone", { +-- texture = { +-- file = "Assets/world.png", +-- offset = { x = 128, y = 0 }, +-- size = { x = 64, y = 64 } +-- }, +-- normal = { +-- file = "Assets/world_normal.png", +-- offset = { x = 128, y = 0 }, +-- size = { x = 64, y = 64 } +-- } +-- }); +-- self:registerMaterial("flower", { +-- texture = { +-- file = "Assets/world.png", +-- offset = { x = 192, y = 0 }, +-- size = { x = 64, y = 64 } +-- }, +-- normal = { +-- file = "Assets/world_normal.png", +-- offset = { x = 192, y = 0 }, +-- size = { x = 64, y = 64 } +-- }, +-- passable = true +-- }); +-- self:registerMaterial("trunk", { +-- texture = { +-- file = "Assets/world.png", +-- offset = { x = 256, y = 0 }, +-- size = { x = 64, y = 64 } +-- }, +-- normal = { +-- file = "Assets/world_normal.png", +-- offset = { x = 256, y = 0 }, +-- size = { x = 64, y = 64 } +-- } +-- }); +-- end, +-- +-- Generate = function(self) +-- math.randomseed(self.Seed) +-- xsize, ysize, zsize = self:setSize(250, 128, 3) +-- for Z = 0,zsize-1 do +-- for X = 0,xsize-1 do +-- if Z == 0 then +-- YGen = math.floor(6*math.sin(X/20)) + 64 +-- elseif Z == 1 then +-- YGen = math.floor(9*math.sin(X/20)) + 64 +-- else +-- YGen = math.floor(15*math.sin(X/20)) + 64 +-- end +-- YDepth = math.random(3,5) +-- for Y = 0,ysize-1 do +-- if Y == YGen then +-- self:setData(X, Y, Z, "grass"); +-- elseif Y < YGen and Y > (YGen - YDepth) then +-- self:setData(X, Y, Z, "dirt"); +-- elseif Y < YGen then +-- self:setData(X, Y, Z, "stone"); +-- elseif Y == YGen + 1 then +-- if math.random(0, 100) == 53 then +-- self:setData(X, Y, Z, "flower"); +-- elseif math.random(0, 100) == 45 then +-- self:setData(X, Y, Z, "trunk"); +-- end +-- end +-- --print(X..","..Y..","..Z); +-- end +-- end +-- end +-- self:setData(1000, 1345, 5, "grass"); -- Test error checking +-- print("Done with world gen"); +-- end +--} + +--world:Generate() +--game.worldRegister(world) |