Guest User

Untitled

a guest
Apr 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. function love.load()
  2.    c = 0
  3.    posix = 0
  4.    posiy = 0
  5.    posfx = 0
  6.    posfy = 0
  7.    rotation = 0
  8.    objects = {}
  9.    objects.wall = {}
  10.    love.graphics.setColor(0,0,0)
  11.    love.graphics.setBackgroundColor(255,250,250)
  12.  
  13.    world = love.physics.newWorld(0, 0, 650, 650) --create a world for the bodies to exist in with width and height of 650
  14.    world:setGravity(0, 700) --the x component of the gravity will be 0, and the y component of the gravity will be 700
  15.    world:setMeter(64) --the height of a meter in this world will be 64px
  16.  
  17.    width = 100
  18. end
  19.  
  20. function love.update(dt)
  21. world:update(dt)
  22.  
  23. end
  24.  
  25. function love.mousereleased(x, y, button)
  26.    if button == 'l' then
  27.         posix, posiy = x, y
  28.         c = 2
  29.  
  30.    end
  31. end
  32.  
  33. function love.draw()
  34.     if(c == 2) then
  35.         --line = love.graphics.line(posix, posiy, posfx, posfy)
  36.         objects.wall.body7 = love.physics.newBody(world, posix, posiy, 0, 0)
  37.         objects.wall.shape7 = love.physics.newRectangleShape(objects.wall.body7, 25, 25, 50, 50, rotation)
  38.         objects.wall.shape7:setFriction(0)
  39.         c = 3
  40.  
  41.  
  42.     end
  43.  
  44.     if(c == 3) then
  45.         love.graphics.polygon("line", objects.wall.shape7:getPoints())
  46.     end
  47.  
  48.     love.graphics.rectangle("fill", love.mouse.getX(), love.mouse.getY(), width, 10)
  49.     love.graphics.print("Rotacao " .. rotation, 50, 50)
  50. end
  51.  
  52.  
  53. function love.keyreleased(key)
  54.     if key == "up" then
  55.         rotation = rotation + 10
  56.     elseif key == "down" then
  57.         rotation = rotation - 10
  58.     end
  59.  
  60.     if key == "p" then
  61.         width = width + 10
  62.     elseif key == "m" then
  63.         width = width - 10
  64.     end
  65.  
  66.         if key == "r" then
  67.         love.filesystem.load("main.lua")()
  68.         love.load()
  69.     end
  70.  
  71. end
Add Comment
Please, Sign In to add comment