Community Curator/Source/TSWRes DrawObjects

-- Draw Objects --

function Draw.MaterialObject(CorTab, X, Y, Size, RotRad, Mat, k, Abs) if CorTab == "Square" then ObjRes.Square(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "Circle" then ObjRes.Circle(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "Triangle" then ObjRes.Triangle(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "Pentagon" then ObjRes.Pentagon(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "Hexagon" then ObjRes.Hexagon(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "Octagon" then ObjRes.Octagon(CorTab, X, Y, Size, RotRad, Mat, k)     return end end

function Draw.Object(CorTab, X, Y, Size, RotRad, Mat, k, Abs) local Line = draw.line local Rect = draw.rect if not Abs then X, Y, Size = ((X*Zoom) - CamX*(Zoom)), ((Y*Zoom) + CamY*(Zoom)), Size*Zoom end --if CorTab ~= "LevelEdge" then     draw.fillrect(X-Size, Y-Size, X+Size, Y+Size, draw.blue)   end if (CorTab == "Square") or (CorTab == "Circle") or (CorTab == "Triangle") or (CorTab == "Pentagon") or (CorTab == "Hexagon") or (CorTab == "Octagon") then Draw.MaterialObject(CorTab, X, Y, Size, RotRad, Mat, k, Abs) elseif CorTab == "LevelEdge" then draw.fillrect(X, Y, (1*Size)+X, (1*Size)+Y, Col255(180,120,100)) Rect(X, Y, (1*Size)+X, (1*Size)+Y, Col255(200,140,120)) return elseif CorTab == "Sackboy" then ObjRes.Sackboy(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "Entrance" then ObjRes.Entrance(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "Checkpoint" then ObjRes.Checkpoint(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "StartGate" then ObjRes.StartGate(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "FinishGate" then ObjRes.FinishGate(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "ScoreBubble" then ObjRes.ScoreBubble(CorTab, X, Y, Size, RotRad, Mat, k)     return elseif CorTab == "Scoreboard" then ObjRes.Scoreboard(CorTab, X, Y, Size, RotRad, Mat, k)  elseif CorTab == "CorEdi" then Draw.CornerEditIco(X, Y, Size) elseif CorTab == "MatCha" then Draw.MaterialChangerIco(X, Y, Size) elseif CorTab == "StickerEditor" then Draw.StickerEditIco(X, Y, Size) elseif type(CorTab) == "table" then ObjRes.Custom(CorTab, X, Y, Size, RotRad, Mat, k)     return else --print("Warning: Unknown Object") end end

function Draw.ObjectsInLevel(ObjTab) local Object = Draw.Object local TRec = TRec local CamX, CamY = CamX, CamY for k,v in ipairs(ObjTab) do     local Size = v["Size"] local X, Y = (v["X"] - CamX), (v["Y"] + CamY) if TRec(-20*(Size), -20*(Size), SizeX+(20*(Size)), SizeY+(20*(Size)), X, Y) then Object(v["CorTab"], v["X"], v["Y"], v["Size"], v["RotRad"], v["Mat"], k)        --Draw.AttachOnObj(v) if v["Stickers"] then Draw.StickersOnObj(v) end if v["CreTab"] then local CreTab = v["CreTab"] ObjRes.CreatureBrain(X + CreTab["X"], Y + CreTab["Y"]) end end end end

-- Draw Attachments function Draw.Attach(AttTab, X, Y, Size, RotRad, Oth, k, Abs) if not Abs then X, Y = X - CamX, Y + CamY end if AttTab[1] == "Bolt" then ObjRes.Bolt(AttTab, X, Y, Size, RotRad, Oth, k)

else --print("Unknown Attachment") end end

function Draw.AttachOnObj(ObjTab) for k, v in ipairs(ObjTab["Attach"]) do     Draw.Attach(v["AttTab"], v["X"], v["Y"], v["Size"], v["RotRad"], v["Oth"], k)   end end

function Draw.StickersOnObj(ObjTab) for k, v in ipairs(ObjTab["Stickers"]) do     local StiFun = Stickers[v["Sticker"]] local X, Y, Size = ((((ObjTab["X"]*Zoom) + (v["X"]*Zoom))) - (CamX*Zoom)), ((((ObjTab["Y"]*Zoom) - (v["Y"]*Zoom))) + (CamY*Zoom)), v["Size"]*Zoom StiFun(X, Y, Size) end end

function Draw.Water local Y = tonumber(LevelTab["WaterLevel"]) or -1000 if Y > CamY then draw.fillrect(-20, -20, SizeX+20, SizeY+20, Col255(75, 40, 255, 200)) elseif (Y+500) > CamY-SizeY then local DrawY = ((Y*Zoom) + CamY*(Zoom)) draw.fillrect(-20, DrawY, SizeX+20, SizeY, Col255(75, 40, 255, 200)) draw.line(-20, DrawY, SizeX+20, DrawY, Col255(0, 0, 0, 200)) end end

function Draw.Level Draw.ObjectsInLevel(ObjTab) Draw.Water end

return