
Anyhow, it's been updated.
PS: I want to rewrite the example, it's quite sloppy right now.
Code: Select all
Macro DebugB(_var_) : Debug _var_ & $FF : EndMacro
Define.b var = 231
Debug var
DebugB(var)
Yes of course, you can technically use it in any environment, I meant that there's no support for the Z axis. Although, adding the third axis in the form of 2d 'layers' or 'floors' should be fairly trivial. I'll probably end up adding that in the future since the game I've been making with this will need it eventually.Inner wrote:It could work in 3d you'd just lose your Z axis, which you could fake by having the object detect ground level on the Z axis, or am I over reaching here?Heathen wrote:This engine is 2d only.inner wrote: how would this work in 3D?
Code: Select all
InitSprite()
XIncludeFile "pathfinding.pbi"
#tilesize = 20: #width = 35: #height = 30
Global Dim blocked.c(#width-1,#height-1): For i=1 To 200: blocked(Random(#width-1),Random(#height-1))=1: Next
pathfind.pathfinding_structure
pathfind\Width = #width: pathfind\height = #height: pathfind\blocked = @blocked()
mnstrX=0: mnstrY=0: blocked(mnstrX,mnstrY)=0
plrX=20: plrY=15: blocked(plrX,plrY)=0
path=get_path(mnstrX,mnstrY,plrX,plrY,pathfind): pathsize = path_get_size(path)
OpenWindow(0,0,0,640,480,"Example",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0),0,0,0)
Repeat: StartDrawing(ScreenOutput()): DrawingMode(4)
For i=0 To #height-1: For j=0 To #width-1: If blocked(j,i)=1: col=#White: Else: col=#Gray: EndIf
Box(j*#tilesize,i*#tilesize,#tilesize,#tilesize,col): Next: Next
For i=0 To pathsize-1: Box(path_get_x(path,i)*#tilesize,path_get_y(path,i)*#tilesize,#tilesize,#tilesize,#Red): Next
Box(mnstrX*#tilesize,mnstrY*#tilesize,#tilesize,#tilesize,#Yellow): Box(plrX*#tilesize,plrY*#tilesize,#tilesize,#tilesize,#Green)
StopDrawing()
FlipBuffers()
event = WaitWindowEvent(1)
Until event = #PB_Event_CloseWindow