0
Help me with Bresenham's line algorithm
https://code.sololearn.com/WXEUnTz1GmmY/?ref=app I'm making a game and I bumped into a strange problem. So, I've found a JS code for drawing a line via Bresenham's algorithm, without plot() function (maybe I write it wrong) and all this stuff works weird: 1) Start x,y and end x,y for line drawing is reversed for some reason 2) Line not drawing in some cases, like in the code below, where I called the function castRay(8,0,4,4) 3) Line not drawing except only one dot in God know where position What am I doing wrong?
2 odpowiedzi
+ 1
try to put console.log(`${x}x${y}`) into plot() function and u will see that it isn't drawing correct line from 4x4 tile into 0x0 tile
0
you are very smart, dude. Now it can draw a correct line