aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Scripts')
-rw-r--r--Scripts/init.lua27
-rw-r--r--Scripts/world.lua121
2 files changed, 36 insertions, 112 deletions
diff --git a/Scripts/init.lua b/Scripts/init.lua
index ec9e350..da2517f 100644
--- a/Scripts/init.lua
+++ b/Scripts/init.lua
@@ -28,20 +28,30 @@ player = {
end
},
Position = {
- x = 15,
- y = 75
+ 15.0, 10.0
},
Velocity = {
x = 0.0,
y = 0.0
},
- Physics = 0,
+ Physics = {
+ hitbox = {
+ ll = {x = -0.5, y = -0.8},
+ lr = {x = 0.5, y = -0.8},
+ ul = {x = -0.5, y = 0.8},
+ ur = {x = 0.5, y = 0.8},
+ }
+ },
Name = "bord",
- hellotrue = true,
- hellofalse = false,
Render = {
texture = "Assets/player.png",
- visible = true
+ visible = true,
+ offset = {
+ ll = {x = -0.5, y = -0.8},
+ lr = {x = 0.5, y = -0.8},
+ ul = {x = -0.5, y = 0.8},
+ ur = {x = 0.5, y = 0.8},
+ }
},
Light = {
r = 1.0,
@@ -50,11 +60,6 @@ player = {
strength = 1.0
},
Idle = function(self)
- --if (self.visibleTick >= 20) then
- -- self.Render.visible = not self.Render.visible
- -- self.visibleTick = 0
- --end
- --self.visibleTick = self.visibleTick + 1
end,
visibleTick = 0
}
diff --git a/Scripts/world.lua b/Scripts/world.lua
index bb6c61e..1fb74d2 100644
--- a/Scripts/world.lua
+++ b/Scripts/world.lua
@@ -1,112 +1,31 @@
-world = {
- Seed = 5345345,
- Layers = 2,
-
- -- This is run when the world is registered and not after,
- -- although it is possible to register materials later
+newWorld = {
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.unitSize = 8;
+ self:createLayer(0, {
+ texture = { file = "Assets/world/world1/layers/0/texture.png" },
+ normal = { file = "Assets/world/world1/layers/0/normal.png" },
+ hitbox = "Assets/world/world1/layers/0/hitbox.png"
});
- 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:createLayer(1, {
+ texture = { file = "Assets/world/world1/layers/1/texture.png" },
+ normal = { file = "Assets/world/world1/layers/1/normal.png" },
+ hitbox = "Assets/world/world1/layers/1/hitbox.png"
});
- 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:createDecoLayer(7, {
+ texture = { file = "Assets/world/world1/layers/deco/forestTileBack.png" },
+ normal = { file = "Assets/world/world1/layers/deco/normal.png" },
});
- 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:createDecoLayer(5.5, {
+ texture = { file = "Assets/world/world1/layers/deco/forestTileMid.png" },
+ normal = { file = "Assets/world/world1/layers/deco/normal.png" },
});
- 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 }
- }
+ self:createDecoLayer(4, {
+ texture = { file = "Assets/world/world1/layers/deco/forestTileFront.png" },
+ normal = { file = "Assets/world/world1/layers/deco/normal.png" },
});
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)
+game.worldRegister(newWorld);