Максимально сократи и оптимизируй мой код "screenx = 1 screeny = 1 cyclex = true cycley…
- User
Максимально сократи и оптимизируй мой код "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
screen = {x = 1, y = 1} direction = {x = 1, y = 1}
function invRenderer() dxDrawRectangle(screen.x, screen.y, 100, 100, white) if screen.x == screenW-100 or screen.x == 1 then direction.x = -direction.x end if screen.y == screenH-100 or screen.y == 1 then direction.y = -direction.y end screen.x = screen.x + direction.x screen.y = screen.y + direction.y end