Guest User

Untitled

a guest
Nov 21st, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. text = ""
  2. x = 0
  3. y = 0
  4. local angle = 0
  5.  
  6.  
  7. function love.load()
  8.  
  9. gfx = love.graphics
  10. player = {
  11. x = 25,
  12. y = 25
  13. }
  14.  
  15. player2 = {
  16. x = 400,
  17. y = 300
  18. }
  19. love.graphics.setBackgroundColor( 150, 150, 150)
  20. soldier = gfx.newImage("soldier.png")
  21. Cursor = gfx.newImage("crosshair.png")--Wczytuje celownik
  22. moon = gfx.newImage("moon.png")
  23. love.mouse.setVisible(false) --Ukrywa myszke
  24. medium = gfx.newFont(45)
  25.  
  26. end
  27.  
  28.  
  29. function love.draw()
  30. --love.graphics.translate(-player.x + 400, -player.y + 300)
  31.  
  32.  
  33.  
  34. x = love.mouse.getX()
  35. y = love.mouse.getY()
  36. love.graphics.line(400 - 0, 300 -0, x, y)
  37. local kat = math.atan2(y - (player2.y), x - (player2.x))
  38. gfx.draw(soldier,player2.x, player2.y, kat+math.pi/2, 1, 1, 20, 20, 0, 0)
  39. gfx.draw(Cursor,love.mouse.getX(),love.mouse.getY(),0, 1, 1, 12, 12) --Celownik
  40. gfx.draw(moon, player.x, player.y)
  41. gfx.setFont(medium)
  42. gfx.print(text, player.x, player.y)
  43. gfx.print(kat, 0,0)
  44.  
  45. end
  46.  
  47. function love.update(dt)
  48.  
  49. if love.keyboard.isDown("w") then
  50. player.y = player.y + 2
  51. end
  52. if love.keyboard.isDown("s") then
  53. player.y = player.y - 2
  54. end
  55. if love.keyboard.isDown("a") then
  56. player.x = player.x + 2
  57. end
  58. if love.keyboard.isDown("d") then
  59. player.x = player.x - 2
  60. end
  61.  
  62. if love.keyboard.isDown("lshift") and love.keyboard.isDown("s") then
  63. player.y = player.y - 2.5
  64. end
  65. if love.keyboard.isDown("lshift") and love.keyboard.isDown("w") then
  66. player.y = player.y + 2.5
  67. end
  68. if love.keyboard.isDown("lshift") and love.keyboard.isDown("d") then
  69. player.x = player.x - 2.5
  70. end
  71. if love.keyboard.isDown("lshift") and love.keyboard.isDown("a") then
  72. player.x = player.x + 2.5
  73. end
  74.  
  75.  
  76.  
  77. function love.keypressed(key)
  78. if key == "escape" then
  79. love.event.push("quit")
  80. end
  81. end
  82. end
Add Comment
Please, Sign In to add comment