Elisonpp

Blade ball auto parry 2

Dec 9th, 2024
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. -- main.lua
  2.  
  3. -- Configurações iniciais
  4. local ball = {
  5. x = 400,
  6. y = 300,
  7. radius = 20,
  8. speed = 200,
  9. dx = 0,
  10. dy = 0
  11. }
  12.  
  13. -- Função para mover a bola
  14. function moveBall(dt)
  15. ball.x = ball.x + ball.dx * dt
  16. ball.y = ball.y + ball.dy * dt
  17.  
  18. -- Limite da tela (campo)
  19. if ball.x - ball.radius < 0 then
  20. ball.x = ball.radius
  21. elseif ball.x + ball.radius > love.graphics.getWidth() then
  22. ball.x = love.graphics.getWidth() - ball.radius
  23. end
  24.  
  25. if ball.y - ball.radius < 0 then
  26. ball.y = ball.radius
  27. elseif ball.y + ball.radius > love.graphics.getHeight() then
  28. ball.y = love.graphics.getHeight() - ball.radius
  29. end
  30. end
  31.  
  32. -- Função Love2D chamada a cada quadro (frame)
  33. function love.update(dt)
  34. -- Controlando a bola com as teclas de seta ou WASD
  35. if love.keyboard.isDown("right") then
  36. ball.dx = ball.speed
  37. elseif love.keyboard.isDown("left") then
  38. ball.dx = -ball.speed
  39. else
  40. ball.dx = 0
  41. end
  42.  
  43. if love.keyboard.isDown("down") then
  44. ball.dy = ball.speed
  45. elseif love.keyboard.isDown("up") then
  46. ball.dy = -ball.speed
  47. else
  48. ball.dy = 0
  49. end
  50.  
  51. -- Atualizando a posição da bola
  52. moveBall(dt)
  53. end
  54.  
  55. -- Função Love2D para desenhar os objetos na tela
  56. function love.draw()
  57. love.graphics.setColor(1, 0, 0) -- Cor vermelha para a bola
  58. love.graphics.circle("fill", ball.x, ball.y, ball.radius)
  59. end
  60.  
  61. -- Função Love2D chamada no início do jogo
  62. function love.load()
  63. love.window.setTitle("Blade Ball")
  64. love.window.setMode(800, 600) -- Tamanho da janela do jogo
  65. end
Advertisement
Add Comment
Please, Sign In to add comment