ID:2800809
 


Code:
mob/proc/Render(map/map)
set background = TRUE
var fov = round(FOV / 2)
var tick = world.tick_lag * 1.5
var grid = map.layout
var height = map.height
var width = map.width
var vis = client.screen[1].vis_contents
var rx,ry,rxp,ryp,tile,steps,obj/slice/slice,shade,ray_angle,obj/slice/over = new
var list/tile_density = list("1","r","e","w","b","z","f","c"), t, v
var list/slices = GenerateSlices(), tv
var ts
over.appearance_flags = RESET_COLOR | RESET_TRANSFORM
for()
sleep(tick);. = 0; world.name = "CPU: [round(world.cpu)]% --- ([xpos],[ypos]) , TS: [ts]"; ts = 0
if(!update){continue}
update = FALSE
for(ray_angle = (angle-fov) to (angle+fov) step 0.25)
.++
rx = sin(ray_angle) / 16; rxp = xpos
ry = cos(ray_angle) / 16; ryp = ypos
//
steps = 0; slice = vis[.]
slice.overlays = new
tv = cos(angle-ray_angle)
for()
rxp += rx; ryp += ry; steps ++
t = height * round(ryp) + rxp - width
tile = grid[t]
if(tile in tile_density)
shade = 255 - (steps * 0.085) * ICON_SIZE
if(42 > shade) shade = 42
v = round(((rxp + ryp) * ICON_SIZE) % ICON_SIZE)
slice.color = rgb(shade,shade,shade)
animate(slice,transform=transform.Scale(1,(512/(steps*tv))),icon=slices[tile][++v])
break


Problem description:
So right now all the rays are taking 90,000 steps each time the screen updates and I can't get DDA or whatever it's called to work. I've tried for months and can't comprehend on how to incorporate it so I have come to ask for help.

I understanding finding the size of x and y of the step and compare and step off those values and take the x and y side into consideration, just ZERO clue how to turn that into code that fits with what I have (no clue if that's even possible :D)
Something something Cunningham's Law


Would be amazing if someone were to create a raycaster with "stages" to demonstrate how to do such in dm correctly.
Map System

map
var width, height, list/layout
level_001
width = 32
height = 32
New()
var r = "r"
var e = "e"
var w = "w"
var b = "b"
var z = "z"
var f = "f"
var c = "c"
var s = "s"
var o = "0"
var O = "O"
layout = list(
z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,z,
z,o,o,o,o,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L_SCALE
New(X){pixel_x=X;layer=X}

var icoslice = icon('slice.dmi')
var obj/slicecontainer/slicecontainer = new

obj/slicecontainer
New(){GenerateSlices()}

proc/GenerateSlices()
var list/l = new, turf/t
var list/L = (typesof(/turf)-/turf)
for(var/path in L){t = new path(locate(1,1,1));l[t.id] = Splice(t.icon,t.icon_state);t.alpha=0}
return l

proc/Splice(ICON,STATE)
var icon/i = icon(ICON,STATE), list/l = list(),icon/u, icon/r = icoslice
var w = i.Width(), x, h = i.Height(), y
for(x = 1 to w)
u = icon(r)
for(y = 1 to h){u.DrawBox(i.GetPixel(x,y),1,y)}
l += u
return l

turf/var/tmp/id

turf
icon = 'obj8.dmi'
wall
id = "1"
icon_state = "wood wall"
grass
id = "0"
icon_state = "grass"
stone_wall
id = "r"
icon_state = "stone wall"
eee
id = "e"
icon_state = "eevee"
wall2
id = "w"
icon_state = "wood wall 2"
bookcase
id = "b"
icon_state = "bookcase"
brickwall
id = "z"
icon_state = "brick wall"
furnace
id = "f"
icon_state = "furnace"
chest
id = "c"
icon_state = "chest"
stone_floor
id = "s"
icon_state = "stone floor"

Login to reply.