]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
Started extremely basic world generation
authorAndy Belle-Isle <drumsetmonkey@gmail.com>
Sat, 7 Sep 2019 07:14:26 +0000 (03:14 -0400)
committerAndy Belle-Isle <drumsetmonkey@gmail.com>
Sat, 7 Sep 2019 07:14:59 +0000 (03:14 -0400)
Scripts/init.lua
Scripts/world.lua [new file with mode: 0644]

index 1292ba128a2c848efc2b1cf3bb1d549bac748f77..f177462021b5eb2a0464f61f693a8e0f8e1ce80a 100644 (file)
@@ -156,6 +156,8 @@ game.spawn({
     end
 });
 
+dofile("Scripts/world.lua")
+
 -------------------
 --  SERIALIZING  --
 -------------------
@@ -183,9 +185,3 @@ f2("shite")
 local testPut = string.dump(animalSpawn.TestMe)
 testRun = (loadstring or load)(testPut)
 testRun(animalSpawn)
-
---blah = load(serial(hello))
---blah()
-
---draw = loadstring("\027\076\074\001\000\009\064\109\097\105\110\046\108\117\097\084\000\000\004\000\004\000\008\009\002\002\052\000\000\000\055\000\001\000\055\000\002\000\037\001\003\000\039\002\010\000\039\003\010\000\062\000\004\001\071\000\001\000\017\104\101\108\108\111\044\032\119\111\114\108\100\010\112\114\105\110\116\013\103\114\097\112\104\105\099\115\009\108\111\118\101\001\001\001\001\001\001\001\002\000\000")
---draw()
diff --git a/Scripts/world.lua b/Scripts/world.lua
new file mode 100644 (file)
index 0000000..db0dc70
--- /dev/null
@@ -0,0 +1,35 @@
+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,
+    Generate = function(self)
+        self.data = {}
+        for Z = 0,2 do
+            self.data[Z] = {}
+            for X = 0,250 do
+                self.data[Z][X] = {}
+                YGen = math.floor(6*math.sin(X/20) + Z) + 64
+                for Y = 0,128 do
+                    if Y == YGen then
+                        self.data[Z][X][Y] = 1
+                    elseif Y < YGen then
+                        self.data[Z][X][Y] = 2
+                    end
+                end
+            end
+        end
+    end
+}
+
+world:Generate()