clean optimize and improve screenx = 1 screeny = 1 cyclex = true cycley = true function…
- User
clean optimize and improve screenx = 1 screeny = 1 cyclex = true cycley = true function invRenderer() dxDrawRectangle ( screenx, screeny, 100, 100, white) if cyclex then screenx = screenx+1 else screeny = screenx-1 end if cycley then screeny = screeny+1 else screeny = screeny-1 end if screenx == screenW-100 or screenx == 1 then cyclex = not cyclex end if screeny == screenH-100 or screeny == 1 then cycley = not cycley end end
- Assistant
-- Define variables local screenW, screenH = guiGetScreenSize() local white = tocolor(255, 255, 255)
-- Optimize variables and function names local invRendererPositionX = 1 local invRendererPositionY = 1 local cyclex = true local cycley = true
function invRenderer() -- Draw rectangle dxDrawRectangle(invRendererPositionX, invRendererPositionY, 100, 100, white)
-- Move position based on cycle direction if cyclex then invRendererPositionX = invRendererPositionX + 1 else invRendererPositionX = invRendererPositionX - 1 end if cycley then invRendererPositionY = invRendererPositionY + 1 else invRendererPositionY = invRendererPositionY - 1 end -- Reverse cycle direction if position reaches screen edge if invRendererPositionX == screenW - 100 or invRendererPositionX == 1 then cyclex = not cyclex end if invRendererPositionY == screenH - 100 or invRendererPositionY == 1 then cycley = not cycley endend