Multiple grids?

Hi guys,

   I’m trying to dev a game using the Jumper path finding module (it uses A*, JPS, and others). I have it doing what I need on the entire screen, but I can’t figure out how to expand the grid beyond the screen to generate a much larger map. Do I need to use some form of tile mapping and assign a different grid to each section? Please share some knowledge with this new guy. Thanks

Can you share your code? This would help so we can see how you’re operating.

Panc, here you go:

–==============================================================

– Jumper setup

–==============================================================

local Grid = require (“jumper.grid”)

local Pathfinder = require (“jumper.pathfinder”)

local Node = require (“jumper.core.node”)

local physics = require(“physics”)

physics.start()

physics.setGravity( 0, 0 )

local map = {

   

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   

}

local grid = Grid(map)

local DEMOHOUSE = display.newImage (“Landscape images/DEMO HOUSE.png”, 480, 320)

–==============================================================

– variables and forward references

–==============================================================

– most commonly used screen coordinates

– thanks to crawlSpaceLib for initial set

local centerX = display.contentCenterX

local centerY = display.contentCenterY

local screenLeft = display.screenOriginX

local screenWidth = display.contentWidth - screenLeft * 2

local screenRight = screenLeft + screenWidth

local screenTop = display.screenOriginY

local screenHeight = display.contentHeight - screenTop * 2

local screenBottom = screenTop + screenHeight

local drawer

local mapStartPos = {}

local mapEndPos = {}

local tankPresent = false

local mode = “ORTHOGONAL”

local numSquaresChosen = {}

–==============================================================

– utilty functions

–==============================================================

– pass in pixel coords and get back the grid coords

– as a table: {x=n, y=n}

local function gridXYFromPixelXY(x,y)

   local pos = {}

   pos.x = math.floor((x)/32) + 1

   if pos.x < 1 then pos.x = 1 end

   pos.y = math.floor((y)/32) + 1

   if pos.y < 1 then pos.y = 1 end

   --print(“pos.x/y”, pos.x, pos.y, x, y)

   return pos

end

– pass in grid coords and get back pixel pos for 

– center of that square as a table: {x=n, y=n}

local function pixelXYFromGridXY(x,y)

   local pos = {}

   pos.x = math.floor((x)*32) -16

   pos.y = math.floor((y)*32) -16

   return pos

end

–==============================================================

– move the PLR from point to point, following the

– path returned from jumper.

–==============================================================

local function followPath()

   PLR.idx = 2

   PLR.myPath = {}

   for node, count in PLR.pathNodes do

       local xPos, yPos = node:getPos()

       print((‘Step: %d - x: %d, y: %d’):format(count, xPos, yPos))

       PLR.myPath[#PLR.myPath+1] = {x=xPos, y=yPos}

   end

   

   

   

   

   if #PLR.myPath > 1 then

   

       local function nextStep(obj)

       

           if PLR.idx < #PLR.myPath+1 then

               local pos = pixelXYFromGridXY(PLR.myPath[PLR.idx].x,PLR.myPath[PLR.idx].y)

               transition.to(PLR, {time=400, x=pos.x, y=pos.y, onComplete=nextStep})

               if pos.x > PLR.x then

               print(“moving right”)

               character:setSequence(“walkright”)

               character:play()

               elseif

               pos.x < PLR.x then

               print(“moving left”)

               elseif

               pos.y > PLR.y then

               print(“moving down”)

               character:setSequence(“walkdown”)

               character:play()

               elseif 

               pos.y < PLR.y then

               print(“moving up”)

               end–>>v

               mapStartPos = PLR.myPath[PLR.idx]–this is vital for current location being the start position

               

           end

           PLR.idx = PLR.idx + 1

       end

       nextStep()

   end

end

   

   

–==============================================================

– the jumper code that finds the best path from 

– startPos to endPos.

–==============================================================

local function goMapping(startPos, endPos)

   local sx,sy = startPos.x, startPos.y

   local ex,ey = endPos.x, endPos.y

   local walkable = 0

   local pather = Pathfinder(grid, ‘JPS’, walkable) – “DIJKSTRA”,“JPS”,“THETASTAR”,“BFS”,“DFS”,“ASTAR”

   pather:setMode(mode) – ‘ORTHOGONAL’  ‘DIAGONAL’

   

   local path = pather:getPath(sx,sy, ex,ey)

   if path then

       if mode == “DIAGONAL” then

           path:fill()

       end

       PLR.pathNodes = path:nodes()

       followPath()

       print((‘Path found! Length: %.2f’):format(path:getLength()))

   else

       print((‘Path from [%d,%d] to [%d,%d] was : not found!’):format(sx,sy,ex,ey))

   end  

end

–==============================================================

– make the tile squares. add tap event to

– each so we can see the grid coords for

– that square.

–==============================================================

   local function grassTouched(event)

       local gridSquare = event.target

       mapEndPos = gridXYFromPixelXY(event.target.x, event.target.y)

       if tankPresent then

           goMapping(mapStartPos, mapEndPos)

       end

       print("{x=" … gridSquare.gridPos.x … “, y=” … gridSquare.gridPos.y … “}”)

   end

   

   

– create a rounded rectangle on the screen.

local function doSquare(x,y,c,s)

   local sz = s or 32

   local radius = 8

   if sz == 32 then radius = 1 end

   local square = display.newRoundedRect(0, 0, sz, sz, radius)

   square.strokeWidth = 1

   square:setStrokeColor(172, 172, 172)

   square:setFillColor(c[1], c[2], c[3])

   square.alpha = .50

   square.x = (x * 32) - 16

   square.y = (y * 32) - 16

   square.gridPos = {x=col, y=row}

   square.xyPos = {x=square.x, y=square.y}

   square:addEventListener(“tap”, grassTouched)

   return square

end

local function drawMap()

   

   local colors = {  {0, 0, 0}, {0, 5, 0} }

   for x = 1, #map[1] do

       for y = 1, #map do

           local color = colors[map[y][x]+1] or {67, 149, 0}

           gridSquare = doSquare(x,y,color, 32)

           gridSquare.gridPos = {x=x, y=y}

           

           

       end

   end

end

local function makeDrawer()

   

               local sheetData = { width=23, height=38, numFrames=6, sheetContentWidth=69, sheetContentHeight=78 }

               local mySheet = graphics.newImageSheet( “Characters/Sam_walking_dwn-right.png”, sheetData )

               local sequenceData = {

               { name = “walkdown”, start=1, count=3, loopCount = 1, time=900 },

               { name = “walkright”, start=4, count=6, loopCount = 1, time=900 }

               }

character = display.newSprite( mySheet, sequenceData )

character:setSequence(“walkdown”)

PLR = character

               local pos = gridXYFromPixelXY(PLR.x, PLR.y)

               local pixX = pos.x * 32 - 16

               local pixY = pos.y * 32 - 16

               PLR.x = pixX 

               PLR.y = pixY

               PLR.gridPos = pos – save the grid X/Y location

               mapStartPos = pos

               tankPresent = true

               map[pos.y][pos.x] = 1

               return true

               end

               

drawMap() 

makeDrawer()

So the thing about this is, it feels like deja vu. I started out my Corona/Lua life trying to develop a PGC roguelike, beginning with doing some surgery on the A* code because it creating a grid with what seemed like obstacles. Memories…

Simple answer: mess with the values in your “jumper.grid” file that handle the size of the cell that is created, and the bounds to which they are locked, along with expanding the “map” grid values (the 0’s and 1’s). Long answer: you could potentially create a larger grid that would go off of the screen real estate, but first you would need to develop some logic that would automatically scroll the “map” so that you can see the parts that are off the screen originally. So I say all that to say, there’s a bit of work that comes before you can get to the point where you have large maps you can scroll. Maybe this already exists in the Jumper module, as I am unfamiliar with it, so if you investigate, this might be handled already.

Here’s my tutorial on sprite movement (shameless plug). Within it, there is logic to lock the screen bounds to keep the player in the center, unless the bounds of the “level” are met. This doesn’t incorporate the Jumper code, but I think it would be pretty simple to implement.

Kind of a long answer, but hopefully it answers your question. As a matter of fact, maybe that will be my next tutorial. Let us know how you get on.

Panc,

   I appreciate your help. I will look into what you mentioned and check out your tutorial. I don’t need the screen to center on the player, since I want to implement several characters that move on a click-touch basis, with the camera being set to where I last moved it via scroll or zoom  (this is an overhead game). Like in the game Star Command.

   If my map were to be very large, containing several images, would it be best to use tile mapping, set them as “.isVisible=false” while off screen, or something else to save memory?

I don’t want to get known as the shameless plug guy, but Caleb and Dyson122 are working on really great tile creation engines (Dusk and Million Tile Engine, respectively) that both say they manage memory very well. I’ve never used either, so I can’t support one over the other.

To be fair, there are more simple ways to accomplish memory management for large games, if all you’re looking for is memory usage and not other features like Tiled tmx integration. People say that Corona does a good job of handling tile/object culling and freeing memory, but I have to say, I haven’t seen a ton of evidence to support this. isVisible is one way to accomplish this, or you could just create and delete the parts of the map when your “view” gets closer or farther.

Lots of options. I’m not familiar with the game Star Command, but I watched some youtube videos and it seems pretty cool. I’ll defer to the more intelligent of our community to give you some more tips on tile map memory management, because I am definitely not the expert there.

Panc,

   You have defiantly helped me out. I’ve looked into MTE for the past couple days, and wanted to avoid using it if Corona alone could do what I needed. I’ll play around with the " you could just create and delete the parts of the map when your “view” gets closer or farther" idea and see if I can figure it out. Thanks man.

Can you share your code? This would help so we can see how you’re operating.

Panc, here you go:

–==============================================================

– Jumper setup

–==============================================================

local Grid = require (“jumper.grid”)

local Pathfinder = require (“jumper.pathfinder”)

local Node = require (“jumper.core.node”)

local physics = require(“physics”)

physics.start()

physics.setGravity( 0, 0 )

local map = {

   

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0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,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

   

}

local grid = Grid(map)

local DEMOHOUSE = display.newImage (“Landscape images/DEMO HOUSE.png”, 480, 320)

–==============================================================

– variables and forward references

–==============================================================

– most commonly used screen coordinates

– thanks to crawlSpaceLib for initial set

local centerX = display.contentCenterX

local centerY = display.contentCenterY

local screenLeft = display.screenOriginX

local screenWidth = display.contentWidth - screenLeft * 2

local screenRight = screenLeft + screenWidth

local screenTop = display.screenOriginY

local screenHeight = display.contentHeight - screenTop * 2

local screenBottom = screenTop + screenHeight

local drawer

local mapStartPos = {}

local mapEndPos = {}

local tankPresent = false

local mode = “ORTHOGONAL”

local numSquaresChosen = {}

–==============================================================

– utilty functions

–==============================================================

– pass in pixel coords and get back the grid coords

– as a table: {x=n, y=n}

local function gridXYFromPixelXY(x,y)

   local pos = {}

   pos.x = math.floor((x)/32) + 1

   if pos.x < 1 then pos.x = 1 end

   pos.y = math.floor((y)/32) + 1

   if pos.y < 1 then pos.y = 1 end

   --print(“pos.x/y”, pos.x, pos.y, x, y)

   return pos

end

– pass in grid coords and get back pixel pos for 

– center of that square as a table: {x=n, y=n}

local function pixelXYFromGridXY(x,y)

   local pos = {}

   pos.x = math.floor((x)*32) -16

   pos.y = math.floor((y)*32) -16

   return pos

end

–==============================================================

– move the PLR from point to point, following the

– path returned from jumper.

–==============================================================

local function followPath()

   PLR.idx = 2

   PLR.myPath = {}

   for node, count in PLR.pathNodes do

       local xPos, yPos = node:getPos()

       print((‘Step: %d - x: %d, y: %d’):format(count, xPos, yPos))

       PLR.myPath[#PLR.myPath+1] = {x=xPos, y=yPos}

   end

   

   

   

   

   if #PLR.myPath > 1 then

   

       local function nextStep(obj)

       

           if PLR.idx < #PLR.myPath+1 then

               local pos = pixelXYFromGridXY(PLR.myPath[PLR.idx].x,PLR.myPath[PLR.idx].y)

               transition.to(PLR, {time=400, x=pos.x, y=pos.y, onComplete=nextStep})

               if pos.x > PLR.x then

               print(“moving right”)

               character:setSequence(“walkright”)

               character:play()

               elseif

               pos.x < PLR.x then

               print(“moving left”)

               elseif

               pos.y > PLR.y then

               print(“moving down”)

               character:setSequence(“walkdown”)

               character:play()

               elseif 

               pos.y < PLR.y then

               print(“moving up”)

               end–>>v

               mapStartPos = PLR.myPath[PLR.idx]–this is vital for current location being the start position

               

           end

           PLR.idx = PLR.idx + 1

       end

       nextStep()

   end

end

   

   

–==============================================================

– the jumper code that finds the best path from 

– startPos to endPos.

–==============================================================

local function goMapping(startPos, endPos)

   local sx,sy = startPos.x, startPos.y

   local ex,ey = endPos.x, endPos.y

   local walkable = 0

   local pather = Pathfinder(grid, ‘JPS’, walkable) – “DIJKSTRA”,“JPS”,“THETASTAR”,“BFS”,“DFS”,“ASTAR”

   pather:setMode(mode) – ‘ORTHOGONAL’  ‘DIAGONAL’

   

   local path = pather:getPath(sx,sy, ex,ey)

   if path then

       if mode == “DIAGONAL” then

           path:fill()

       end

       PLR.pathNodes = path:nodes()

       followPath()

       print((‘Path found! Length: %.2f’):format(path:getLength()))

   else

       print((‘Path from [%d,%d] to [%d,%d] was : not found!’):format(sx,sy,ex,ey))

   end  

end

–==============================================================

– make the tile squares. add tap event to

– each so we can see the grid coords for

– that square.

–==============================================================

   local function grassTouched(event)

       local gridSquare = event.target

       mapEndPos = gridXYFromPixelXY(event.target.x, event.target.y)

       if tankPresent then

           goMapping(mapStartPos, mapEndPos)

       end

       print("{x=" … gridSquare.gridPos.x … “, y=” … gridSquare.gridPos.y … “}”)

   end

   

   

– create a rounded rectangle on the screen.

local function doSquare(x,y,c,s)

   local sz = s or 32

   local radius = 8

   if sz == 32 then radius = 1 end

   local square = display.newRoundedRect(0, 0, sz, sz, radius)

   square.strokeWidth = 1

   square:setStrokeColor(172, 172, 172)

   square:setFillColor(c[1], c[2], c[3])

   square.alpha = .50

   square.x = (x * 32) - 16

   square.y = (y * 32) - 16

   square.gridPos = {x=col, y=row}

   square.xyPos = {x=square.x, y=square.y}

   square:addEventListener(“tap”, grassTouched)

   return square

end

local function drawMap()

   

   local colors = {  {0, 0, 0}, {0, 5, 0} }

   for x = 1, #map[1] do

       for y = 1, #map do

           local color = colors[map[y][x]+1] or {67, 149, 0}

           gridSquare = doSquare(x,y,color, 32)

           gridSquare.gridPos = {x=x, y=y}

           

           

       end

   end

end

local function makeDrawer()

   

               local sheetData = { width=23, height=38, numFrames=6, sheetContentWidth=69, sheetContentHeight=78 }

               local mySheet = graphics.newImageSheet( “Characters/Sam_walking_dwn-right.png”, sheetData )

               local sequenceData = {

               { name = “walkdown”, start=1, count=3, loopCount = 1, time=900 },

               { name = “walkright”, start=4, count=6, loopCount = 1, time=900 }

               }

character = display.newSprite( mySheet, sequenceData )

character:setSequence(“walkdown”)

PLR = character

               local pos = gridXYFromPixelXY(PLR.x, PLR.y)

               local pixX = pos.x * 32 - 16

               local pixY = pos.y * 32 - 16

               PLR.x = pixX 

               PLR.y = pixY

               PLR.gridPos = pos – save the grid X/Y location

               mapStartPos = pos

               tankPresent = true

               map[pos.y][pos.x] = 1

               return true

               end

               

drawMap() 

makeDrawer()

So the thing about this is, it feels like deja vu. I started out my Corona/Lua life trying to develop a PGC roguelike, beginning with doing some surgery on the A* code because it creating a grid with what seemed like obstacles. Memories…

Simple answer: mess with the values in your “jumper.grid” file that handle the size of the cell that is created, and the bounds to which they are locked, along with expanding the “map” grid values (the 0’s and 1’s). Long answer: you could potentially create a larger grid that would go off of the screen real estate, but first you would need to develop some logic that would automatically scroll the “map” so that you can see the parts that are off the screen originally. So I say all that to say, there’s a bit of work that comes before you can get to the point where you have large maps you can scroll. Maybe this already exists in the Jumper module, as I am unfamiliar with it, so if you investigate, this might be handled already.

Here’s my tutorial on sprite movement (shameless plug). Within it, there is logic to lock the screen bounds to keep the player in the center, unless the bounds of the “level” are met. This doesn’t incorporate the Jumper code, but I think it would be pretty simple to implement.

Kind of a long answer, but hopefully it answers your question. As a matter of fact, maybe that will be my next tutorial. Let us know how you get on.

Panc,

   I appreciate your help. I will look into what you mentioned and check out your tutorial. I don’t need the screen to center on the player, since I want to implement several characters that move on a click-touch basis, with the camera being set to where I last moved it via scroll or zoom  (this is an overhead game). Like in the game Star Command.

   If my map were to be very large, containing several images, would it be best to use tile mapping, set them as “.isVisible=false” while off screen, or something else to save memory?

I don’t want to get known as the shameless plug guy, but Caleb and Dyson122 are working on really great tile creation engines (Dusk and Million Tile Engine, respectively) that both say they manage memory very well. I’ve never used either, so I can’t support one over the other.

To be fair, there are more simple ways to accomplish memory management for large games, if all you’re looking for is memory usage and not other features like Tiled tmx integration. People say that Corona does a good job of handling tile/object culling and freeing memory, but I have to say, I haven’t seen a ton of evidence to support this. isVisible is one way to accomplish this, or you could just create and delete the parts of the map when your “view” gets closer or farther.

Lots of options. I’m not familiar with the game Star Command, but I watched some youtube videos and it seems pretty cool. I’ll defer to the more intelligent of our community to give you some more tips on tile map memory management, because I am definitely not the expert there.

Panc,

   You have defiantly helped me out. I’ve looked into MTE for the past couple days, and wanted to avoid using it if Corona alone could do what I needed. I’ll play around with the " you could just create and delete the parts of the map when your “view” gets closer or farther" idea and see if I can figure it out. Thanks man.