Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- map = {{}}
- local tArg = {...}
- map = paintutils.serialize(tArg[1])
- solidmap = {}
- scrollX,scrollY = 0,0
- mapX,mapY = 0,#map
- for y = 1, #map do
- solidmap[#solidmap+1] = {}
- if map[y][x] == 0 then
- solidmap[y][x] = false
- else
- solidmap[y][x] = true
- end
- if #map[y] > mapX then
- mapX = #map[y]
- end
- end
- guy = {
- name = "player",
- sprite = {{2}},
- x = 1,
- y = 1,
- xsize = 1,
- ysize = 1,
- xv = 0,
- yv = 0,
- }
- checkSolid = function(x,y)
- if map[y] then
- return solidmap[y][x]
- else
- return false
- end
- end
- checkCollision = function(p,strdir,dist)
- local dir
- if strdir:lower() == "down" then --I mean actually down, as in, y+.
- dir = 90
- elseif strdir:lower() == "up" then
- dir = 270
- elseif strdir:lower() == "right" then
- dir = 0
- elseif stdfir:lower() == "left" then
- dir = 180
- end
- if dist < 0 then
- dist = math.abs(dist)
- dir = (dir + 180) % 360
- end
- dir = math.rad(dir) --gosh dang flipping radicals
- for d = 1, dist do
- if checkSolid(p.x*dist*math.cos(dir),p.y*dist*math.sin(dir)) then
- return true, d-1, p.x*(d-1)*math.cos(dir), p.y*(d-1)*math.sin(dir)
- end
- end
- return false,dist,p.x*dist*math.cos(dir),p.y*dist*math.sin(dir)
- end
- moveCollide = function(p,strdir,dist)
- local hit,len,newX,newY = checkCollision(p,strdir,dist)
- p.x,p.y = newX,newY
- end
Add Comment
Please, Sign In to add comment