error("\069\120\097\109\112\108\101 \110\111\116 \105\109\112\108\101\109\101\110\116\101\100\033")local Q=require("\114\097\121\108\105\098")local z=800 local p=450 Q.SetConfigFlags(Q.FLAG_MSAA_4X_HINT)Q.InitWindow(z,p,"\080\104\121\115\097\099 \091\114\097\121\108\117\097\093 - \080\104\121\115\105\099\115 \100\101\109\111")local U=(z-Q.MeasureText("\080\104\121\115\097\099",30))-10 local j=15 local W=false Q.InitPhysics()local K=Q.CreatePhysicsBodyRectangle({z/2;p},500,100,10)K.enabled=false local m=Q.CreatePhysicsBodyCircle({z/2,p/2},45,10)m.enabled=false Q.SetTargetFPS(60)while not Q.WindowShouldClose()do Q.UpdatePhysics()if W then K=Q.CreatePhysicsBodyRectangle({z/2,p},500,100,10)m=Q.CreatePhysicsBodyCircle({z/2,p/2},45,10)K.enabled=false m.enabled=false W=false end if Q.IsKeyPressed(string.byte("\082"))then Q.ResetPhysics()W=true end if Q.IsMouseButtonPressed(Q.MOUSE_BUTTON_LEFT)then Q.CreatePhysicsBodyPolygon(Q.GetMousePosition(),Q.GetRandomValue(20,80),Q.GetRandomValue(3,8),10)elseif Q.IsMouseButtonPressed(Q.MOUSE_BUTTON_RIGHT)then Q.CreatePhysicsBodyCircle(Q.GetMousePosition(),Q.GetRandomValue(10,45),10)end local h=Q.GetPhysicsBodiesCount()for z=0,h,1 do local U=Q.GetPhysicsBody(z)if U~=nil and U.position.y>p*2 then print("\068\101\115\116\114\111\121\101\100 "..tostring(U))Q.DestroyPhysicsBody(U)end end Q.BeginDrawing()Q.ClearBackground(Q.BLACK)h=Q.GetPhysicsBodiesCount()for z=0,h-1,1 do local p=Q.GetPhysicsBody(z)if p~=nil then local U=Q.GetPhysicsShapeVerticesCount(z)for z=0,U-1,1 do local j=Q.GetPhysicsShapeVertex(p,z)local W=z+1<U and z+1 or 0 local K=Q.GetPhysicsShapeVertex(p,W)Q.DrawLineV(j,K,Q.GREEN)end end end Q.DrawText("\076\101\102\116 \109\111\117\115\101 \098\117\116\116\111\110 \116\111 \099\114\101\097\116\101 \097 \112\111\108\121\103\111\110",10,10,10,Q.WHITE)Q.DrawText("\082\105\103\104\116 \109\111\117\115\101 \098\117\116\116\111\110 \116\111 \099\114\101\097\116\101 \097 \099\105\114\099\108\101",10,25,10,Q.WHITE)Q.DrawText("\080\114\101\115\115 \'\082\' \116\111 \114\101\115\101\116 \101\120\097\109\112\108\101",10,40,10,Q.WHITE)Q.DrawText("\080\104\121\115\097\099",U,j,30,Q.WHITE)Q.DrawText("\080\111\119\101\114\101\100 \098\121",U+50,j-7,10,Q.WHITE)Q.EndDrawing()end Q.ClosePhysics()Q.CloseWindow()
error("Example not implemented!")
local rl = require("raylib")

local screenWidth = 800
local screenHeight = 450

rl.SetConfigFlags(rl.FLAG_MSAA_4X_HINT)

rl.InitWindow(screenWidth, screenHeight, "Physac [raylua] - Physics demo")
local logoX = screenWidth - rl.MeasureText("Physac", 30) - 10
local logoY = 15

local needsReset = false

rl.InitPhysics()

local floor = rl.CreatePhysicsBodyRectangle({ screenWidth / 2, screenHeight }, 500, 100, 10)
floor.enabled = false

local circle = rl.CreatePhysicsBodyCircle({ screenWidth / 2, screenHeight / 2 }, 45, 10)
circle.enabled = false

rl.SetTargetFPS(60)

while not rl.WindowShouldClose() do
  rl.UpdatePhysics()

  if needsReset then
    floor = rl.CreatePhysicsBodyRectangle({ screenWidth / 2, screenHeight }, 500, 100, 10)
    circle = rl.CreatePhysicsBodyCircle({ screenWidth / 2, screenHeight / 2 }, 45, 10)

    floor.enabled = false
    circle.enabled = false

    needsReset = false
  end

  if rl.IsKeyPressed(string.byte("R")) then
    rl.ResetPhysics()
    needsReset = true
  end

  if rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_LEFT) then
    rl.CreatePhysicsBodyPolygon(rl.GetMousePosition(), rl.GetRandomValue(20, 80), rl.GetRandomValue(3, 8), 10)
  elseif rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_RIGHT) then
    rl.CreatePhysicsBodyCircle(rl.GetMousePosition(), rl.GetRandomValue(10, 45), 10)
  end

  local bodiesCount = rl.GetPhysicsBodiesCount()

  for i = 0, bodiesCount do
    local body = rl.GetPhysicsBody(i)

    if body ~= nil and (body.position.y > screenHeight * 2) then
      print("Destroyed " .. tostring(body))
      rl.DestroyPhysicsBody(body)
    end
  end

  rl.BeginDrawing()
  rl.ClearBackground(rl.BLACK)

  bodiesCount = rl.GetPhysicsBodiesCount()
  for i = 0, bodiesCount - 1 do
    local body = rl.GetPhysicsBody(i)

    if body ~= nil then
      local vertexCount = rl.GetPhysicsShapeVerticesCount(i)
      for j = 0, vertexCount - 1 do
        local vertexA = rl.GetPhysicsShapeVertex(body, j)

        local jj = ((j + 1) < vertexCount) and (j + 1) or 0
        local vertexB = rl.GetPhysicsShapeVertex(body, jj)

        rl.DrawLineV(vertexA, vertexB, rl.GREEN)
      end
    end
  end

  rl.DrawText("Left mouse button to create a polygon", 10, 10, 10, rl.WHITE)
  rl.DrawText("Right mouse button to create a circle", 10, 25, 10, rl.WHITE)
  rl.DrawText("Press 'R' to reset example", 10, 40, 10, rl.WHITE)

  rl.DrawText("Physac", logoX, logoY, 30, rl.WHITE)
  rl.DrawText("Powered by", logoX + 50, logoY - 7, 10, rl.WHITE)

  rl.EndDrawing()
end

rl.ClosePhysics()
rl.CloseWindow()
