diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2019-09-17 13:55:22 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2019-09-17 13:55:22 -0400 |
commit | ceda39e4bd2e3a7794f0cb4f96df1de6ebee47d2 (patch) | |
tree | ba5451b6dcade324114d145d526e7c5b5465689a /Scripts | |
parent | dbb26902ed54ce308fdcec4697616e152f2894fd (diff) | |
parent | 0236eb7f6391c9d925dcaaddb8cb01ecfb7d5e55 (diff) |
update with master; using VBOs for fonts
Diffstat (limited to 'Scripts')
-rw-r--r-- | Scripts/init.lua | 5 | ||||
-rw-r--r-- | Scripts/world.lua | 101 |
2 files changed, 82 insertions, 24 deletions
diff --git a/Scripts/init.lua b/Scripts/init.lua index 2eeee18..65513ec 100644 --- a/Scripts/init.lua +++ b/Scripts/init.lua @@ -131,6 +131,9 @@ wall = { } } +-- Create the world +dofile("Scripts/world.lua") + birdSpawn = game.spawn(bird); dogSpawn = game.spawn(cat); @@ -158,8 +161,6 @@ game.spawn({ end }); -dofile("Scripts/world.lua") - ------------------- -- SERIALIZING -- ------------------- diff --git a/Scripts/world.lua b/Scripts/world.lua index db0dc70..8fb3136 100644 --- a/Scripts/world.lua +++ b/Scripts/world.lua @@ -1,35 +1,92 @@ world = { - Registry = { - dirt = { - id = "world0:dirt", - texture = "Assets/dirt.png", - normal = "Assets/dirt_normal.png" - }, - stone = { - id = "world0:stone", - texture = "Assets/stone.png", - normal = "Assets/dirt_normal.png" - } - }, Seed = 5345345, - Layers = 3, + 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 = 8, y = 8 } + }, + normal = { + file = "Assets/world_normal.png", + offset = { x = 0, y = 0 }, + size = { x = 8, y = 8 } + } + }); + self:registerMaterial("dirt", { + texture = { + file = "Assets/world.png", + offset = { x = 8, y = 0 }, + size = { x = 8, y = 8 } + }, + normal = { + file = "Assets/world_normal.png", + offset = { x = 8, y = 0 }, + size = { x = 8, y = 8 } + } + }); + self:registerMaterial("stone", { + texture = { + file = "Assets/world.png", + offset = { x = 16, y = 0 }, + size = { x = 8, y = 8 } + }, + normal = { + file = "Assets/world_normal.png", + offset = { x = 16, y = 0 }, + size = { x = 8, y = 8 } + } + }); + self:registerMaterial("flower", { + texture = { + file = "Assets/world.png", + offset = { x = 24, y = 0 }, + size = { x = 8, y = 8 } + }, + normal = { + file = "Assets/world_normal.png", + offset = { x = 24, y = 0 }, + size = { x = 8, y = 8 } + }, + passable = true + }); + end, + Generate = function(self) - self.data = {} - for Z = 0,2 do - self.data[Z] = {} - for X = 0,250 do - self.data[Z][X] = {} + math.randomseed(self.Seed) + xsize, ysize, zsize = self:setSize(250, 128, 3) + --self.data = {} + for Z = 0,zsize-1 do + --self.data[Z] = {} + for X = 0,xsize-1 do + --self.data[Z][X] = {} YGen = math.floor(6*math.sin(X/20) + Z) + 64 - for Y = 0,128 do + YDepth = math.random(2,5) + for Y = 0,ysize-1 do if Y == YGen then - self.data[Z][X][Y] = 1 + 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.data[Z][X][Y] = 2 + --self:setData(X, Y, Z, "stone"); + self:setData(X, Y, Z, "grass"); 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() +--world:Generate() +game.worldRegister(world) |