Fixed the map issue (read more)
The map generation was being written to a trigger function instead of a glue method. Fixed, map is being drawn correctly now.
This commit is contained in:
@@ -71,7 +71,8 @@ InWorld::InWorld(
|
|||||||
|
|
||||||
//load the tilesheet
|
//load the tilesheet
|
||||||
//TODO: add the tilesheet to the map system?
|
//TODO: add the tilesheet to the map system?
|
||||||
tileSheet.Load(config["dir.tilesets"] + "terrain.bmp", 12, 15);
|
//TODO: Tile size and tile sheet should be loaded elsewhere
|
||||||
|
tileSheet.Load(config["dir.tilesets"] + "terrain.bmp", 32, 32);
|
||||||
|
|
||||||
//request a sync
|
//request a sync
|
||||||
RequestSynchronize();
|
RequestSynchronize();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
void ConfigUtility::Load(std::string fname) {
|
void ConfigUtility::Load(std::string fname) {
|
||||||
|
//TODO: recursive rerouting?
|
||||||
std::ifstream is(fname);
|
std::ifstream is(fname);
|
||||||
|
|
||||||
if (!is.is_open()) {
|
if (!is.is_open()) {
|
||||||
|
|||||||
@@ -1,38 +1,39 @@
|
|||||||
print("Lua script check")
|
print("Lua script check")
|
||||||
|
|
||||||
--uber lazy declarations
|
--uber lazy declarations
|
||||||
function square(x) return x*x end
|
function math.sqr(x) return x*x end
|
||||||
function distance(x, y, i, j) return math.sqrt(square(x - i) + square(y - j)) end
|
function math.dist(x, y, i, j) return math.sqrt(math.sqr(x - i) + math.sqr(y - j)) end
|
||||||
|
|
||||||
--tile macros, mapped to the tilesheet
|
--tile macros, mapped to the tilesheet
|
||||||
local base = 14
|
local base = 14
|
||||||
local shift = 36
|
local shift = 36
|
||||||
plains = base + shift * 0
|
tiles = {
|
||||||
grass = base + shift * 1
|
plains = base + shift * 0,
|
||||||
dirt = base + shift * 2
|
grass = base + shift * 1,
|
||||||
sand = base + shift * 3
|
dirt = base + shift * 2,
|
||||||
|
sand = base + shift * 3,
|
||||||
water = base + shift * 4
|
water = base + shift * 4
|
||||||
|
}
|
||||||
|
|
||||||
--Overwrite the original OnCreate with my own version
|
--could set custom generation systems here, that differ from the global generators, etc.
|
||||||
Region.hcOnCreate = Region.OnCreate
|
function Region.Create(region)
|
||||||
Region.OnCreate = function(region)
|
|
||||||
local ret = Region.hcOnCreate(region) --best practices
|
|
||||||
for i = 1, Region.GetWidth() do
|
for i = 1, Region.GetWidth() do
|
||||||
for j = 1, Region.GetHeight() do
|
for j = 1, Region.GetHeight() do
|
||||||
local dist = distance(0, 0, i + Region.GetX(region) -1, j + Region.GetY(region) -1)
|
local dist = math.dist(0, 0, i + Region.GetX(region) -1, j + Region.GetY(region) -1)
|
||||||
if dist < 10 then
|
if dist < 10 then
|
||||||
Region.SetTile(region, i, j, 1, plains)
|
Region.SetTile(region, i, j, 1, tiles.plains)
|
||||||
elseif dist < 12 then
|
elseif dist < 12 then
|
||||||
Region.SetTile(region, i, j, 1, sand)
|
Region.SetTile(region, i, j, 1, tiles.sand)
|
||||||
else
|
else
|
||||||
Region.SetTile(region, i, j, 1, water)
|
Region.SetTile(region, i, j, 1, tiles.water)
|
||||||
|
Region.SetSolid(region, i, j, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--Get some regions
|
--Get some regions
|
||||||
|
--BUG: The server fails without this
|
||||||
newRoom = RoomMgr.CreateRoom("overworld")
|
newRoom = RoomMgr.CreateRoom("overworld")
|
||||||
pager = Room.GetPager(newRoom)
|
pager = Room.GetPager(newRoom)
|
||||||
regionTable = {
|
regionTable = {
|
||||||
|
|||||||
Reference in New Issue
Block a user