25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

menu.lua 1.3 KiB

3 년 전
3 년 전
3 년 전
3 년 전
3 년 전
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. menu = Class{}
  2. local M = {}
  3. menuLoaded = false
  4. function menu.update(dt)
  5. if not menuLoaded then
  6. firstShip.x = -100
  7. firstShip.speed = 10
  8. firstShip.y = love.math.random(0, WINDOW_HEIGHT)
  9. menuLoaded = true
  10. table.insert(planets, planet(love.math.random(100, WINDOW_WIDTH-100), love.math.random(100, WINDOW_HEIGHT-100), 90000000, 0.3, love.graphics.newImage("entities/planet/planet.png")))
  11. end
  12. for i in ipairs(planets) do
  13. planets[i]:update(dt)
  14. end
  15. if animationSecsLeft > 0 then
  16. animationSecsLeft = animationSecsLeft - dt
  17. end
  18. firstShip:update(dt)
  19. if shipIsHit then
  20. shipIsHit = false
  21. firstShip:reset()
  22. firstShip.x = -100
  23. firstShip.speed = 10
  24. firstShip.y = love.math.random(0, WINDOW_HEIGHT)
  25. print("ship is hit")
  26. end
  27. end
  28. function menu.draw(dt)
  29. firstShip:draw()
  30. for i in ipairs(planets) do
  31. planets[i]:draw(dt)
  32. end
  33. if animationSecsLeft > 0 then
  34. love.graphics.setColor(1,1,1,1-1/(animationSecsLeft+0.000001))
  35. love.graphics.draw(logo, 0,0)
  36. else
  37. love.graphics.setFont(titlefont)
  38. love.graphics.printf("NuclearGravity", 0, 20, WINDOW_WIDTH, "center")
  39. menu:butt(buttons, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3)
  40. end
  41. end
  42. return menu