-
-
Save Jordach/e7c7d070fc009a179686 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window_set = "no" --Control Variables | |
world_finished = "no" | |
tempy = 0 | |
PlayerMapX = 25 --These are where the player should spawn. | |
PlayerMapY = 20 --see last comment | |
World = {} --Mapdata needs to be global...other than that, it's somewhat done. | |
--height is sorted as 1 = lowest layer. | |
--mapdata is also rendered as vertical lines... | |
function set_window() | |
if window_set == "no" then | |
love.graphics.setMode(800, 640, false, true, 0) | |
love.graphics.setCaption("LoveTest") | |
window_set = "yes" | |
end | |
end | |
function FlatPlains() | |
for x=1,50 do | |
for y=2,stone_height do | |
World[x][y] = 19 | |
end | |
for y2=stone_height+1,(stone_height+1+dirt_height) do | |
World[x][y2] = 2 | |
tempy = y2 | |
end | |
for y3 = stone_height+1+dirt_height, 1+stone_height+dirt_height do | |
World[x][y3] = 3 | |
end | |
end | |
world_finished = "yes" | |
end | |
-- our tiles | |
tile = {} | |
for i=1,19 do -- tile loader. | |
tile[i] = love.graphics.newImage( "tile"..i..".png" ) | |
end | |
function generate_world() | |
if world_finished == "no" then | |
stone_height = math.random(15,20) | |
dirt_height = math.random(2,5) | |
biome = math.random(1,10) --see biome.txt to see biome defs. | |
for i=1,50 do | |
World[i] = {} --World is now treated as World[i][<new>] 512 is the entire map height | |
end | |
for x=1,50 do | |
xr = x | |
for y=1,40 do | |
yr = y | |
if y == 1 then | |
World[xr][yr] = 4 -- Generate bedrock | |
else | |
World[xr][yr] = 1 -- Generate air | |
end | |
end | |
end | |
FlatPlains() | |
end | |
end | |
function render_world() | |
love.graphics.setBackgroundColor(0,181,255) | |
for x=1,50 do | |
for y=1,40 do | |
if y == 1 and x == 1 then | |
love.graphics.draw(tile[World[x][y]], (x-1)*16, 640-16) | |
else | |
love.graphics.draw(tile[World[x][y]], (x-1)*16, 640-16*y) | |
end | |
end | |
end | |
end | |
function love.draw() | |
set_window() | |
generate_world() | |
render_world() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment