Skip to content
Snippets Groups Projects
Commit 87c62d0a authored by dg's avatar dg
Browse files

fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@179 51575b47-30f0-44d4-a5cc-537603b46e54
parent 5af34360
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ function _M:init(keyhandler)
end
function _M:loaded()
self.w, self.h = core.display.size()
self.dialogs = {}
self.key = engine.Key.current
self.mouse = engine.Mouse.new()
......
......@@ -363,6 +363,11 @@ function _M:checkMapViewBounded()
if self.my < 0 then self.my = 0 self.changed = true end
if self.mx > self.w - self.viewport.mwidth then self.mx = self.w - self.viewport.mwidth self.changed = true end
if self.my > self.h - self.viewport.mheight then self.my = self.h - self.viewport.mheight self.changed = true end
-- Center if smaller than map viewport
if self.w < self.viewport.mwidth then self.mx = (self.w - self.viewport.mwidth) / 2 end
if self.h < self.viewport.mheight then self.my = (self.h - self.viewport.mheight) / 2 end
self._map:setScroll(self.mx, self.my)
end
......
......@@ -41,7 +41,7 @@ function _M:generate()
end
end
if self.level.level <= self.zone.max_level then return end
if self.level.level < self.zone.max_level then return end
if self.guardian then
local m = self.zone:makeEntityByName(self.level, "actor", self.guardian)
......
......@@ -63,7 +63,9 @@ function _M:generate(lev, old_lev)
local ux, uy = 1, 1
local dx, dy = math.floor(self.map.w/2)*2-1-2*(1-math.mod(self.map.w,2)), math.floor(self.map.h/2)*2-1-2*(1-math.mod(self.map.h,2))
self.map(ux, uy, Map.TERRAIN, self.up)
self.map(dx, dy, Map.TERRAIN, self.down)
if lev < self.zone.max_level then
self.map(dx, dy, Map.TERRAIN, self.down)
end
if lev > old_lev then
return ux, uy
else
......
......@@ -235,12 +235,14 @@ function _M:generate(lev, old_lev)
end
-- Put down stairs
local dx, dy
while true do
dx, dy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
if not self.map:checkEntity(dx, dy, Map.TERRAIN, "block_move") and not self.room_map[dx][dy].special then
self.map(dx, dy, Map.TERRAIN, self.grid_list[self:resolve("down")])
break
if lev < self.zone.max_level then
local dx, dy
while true do
dx, dy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
if not self.map:checkEntity(dx, dy, Map.TERRAIN, "block_move") and not self.room_map[dx][dy].special then
self.map(dx, dy, Map.TERRAIN, self.grid_list[self:resolve("down")])
break
end
end
end
......
......@@ -41,7 +41,7 @@ function _M:doRooms(room, no, tab)
end
end
function _M:generate()
function _M:generate(lev, old_lev)
for i = 0, self.map.w - 1 do for j = 0, self.map.h - 1 do
if j == 0 or j == self.map.h - 1 or i == 0 or i == self.map.w - 1 then
self.map(i, j, Map.TERRAIN, self.wall)
......@@ -57,6 +57,8 @@ function _M:generate()
local up_spot = table.remove(self.spots, rng.range(1, #self.spots))
local down_spot = self.spots[rng.range(1, #self.spots)]
self.map(up_spot.x, up_spot.y, Map.TERRAIN, self.up)
self.map(down_spot.x, down_spot.y, Map.TERRAIN, self.down)
if lev < self.zone.max_level then
self.map(down_spot.x, down_spot.y, Map.TERRAIN, self.down)
end
return up_spot.x, up_spot.y, self.spots
end
......@@ -88,10 +88,10 @@ function _M:newGame()
end
function _M:loaded()
engine.GameTurnBased.loaded(self)
Zone:setup{npc_class="mod.class.NPC", grid_class="mod.class.Grid", object_class="mod.class.Object"}
Map:setViewerActor(self.player)
Map:setViewPort(self.w * 0.2, 0, self.w * 0.8, math.floor(self.h * 0.80), 16, 16)
engine.GameTurnBased.loaded(self)
self.key = engine.KeyCommand.new()
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment