main.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. local suit = require "/lib/suit-master"
  2. local state = require "lib/stateswitcher"
  3. local moonstate = require "/lib/lovelyMoon"
  4. local unitID = "16";
  5. local testString = "flosama\n{\"Position\":{\"target\":{\"Selected\":["..unitID.."]}}}";
  6. local thread;
  7. local info;
  8. local val = 1;
  9. local gravY = 200;
  10. local gravX = 0;
  11. local sleep = true;
  12. local button1 = "Press me UwU";
  13. local sliderRadius = {value= 25, max = 50};
  14. function love.load()
  15. world = love.physics.newWorld(gravX,gravY,sleep);
  16. thread = love.thread.newThread("thread.lua");
  17. print("loading")
  18. thread:start(unitID);
  19. info = love.thread.getChannel( 'info' ):demand()
  20. ball = {}
  21. ball.b = love.physics.newBody(world,400,200,"dynamic");
  22. ball.b:setMass(40);
  23. ball.s = love.physics.newCircleShape(sliderRadius.value);
  24. ball.f = love.physics.newFixture(ball.b,ball.s);
  25. ball.f:setRestitution(0.4);
  26. ball.f:setUserData("Ball");
  27. static = {}
  28. static.b = love.physics.newBody(world,400,400,"static");
  29. static.s = love.physics.newRectangleShape(200,50);
  30. static.f = love.physics.newFixture(static.b, static.s);
  31. static.f:setUserData("Floor");
  32. end
  33. function pushObject()
  34. if love.keyboard.isDown("d") then
  35. ball.b:applyForce(1000, 0)
  36. elseif love.keyboard.isDown("a") then
  37. ball.b:applyForce(-1000, 0)
  38. end
  39. if love.keyboard.isDown("w") then
  40. ball.b:applyForce(0, -5000)
  41. elseif love.keyboard.isDown("s") then
  42. ball.b:applyForce(0, 1000)
  43. end
  44. end
  45. function love.update(dt)
  46. world:update(dt)
  47. pushObject();
  48. suit.layout:reset(200,200);
  49. if suit.Button(button1,100,100, 100,30).hit then
  50. button1 = "I <3 relat";
  51. state.switch("titlescreen");
  52. love.thread.getChannel('kill'):push(val);
  53. end
  54. suit.Slider(sliderRadius,100,150,100,30);
  55. ball.s = love.physics.newCircleShape(sliderRadius.value);
  56. suit.Label(tostring(sliderRadius.value).." circle size",{align = "left"}, 210,150,100,30);
  57. local temp_inf = love.thread.getChannel( 'info' ):pop();
  58. if (temp_inf ~= nil) then
  59. info = temp_inf;
  60. end
  61. end
  62. function love.draw()
  63. suit.draw();
  64. --love.graphics.print(info,100,200);
  65. love.graphics.circle("line",ball.b:getX(),ball.b:getY(),ball.s:getRadius(),20);
  66. love.graphics.polygon("fill",static.b:getWorldPoints(static.s:getPoints()));
  67. end