選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

52 行
1.7 KiB

  1. menu = Class{}
  2. local M = {}
  3. menuLoaded = false
  4. function menu.update(dt)
  5. if not menuLoaded then
  6. firstShip.x = -100
  7. menuLoaded = true
  8. planets = {}
  9. 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")))
  10. if (planets[1].y < WINDOW_HEIGHT/2) then
  11. firstShip.y = planets[1].y + love.math.random(300, 500)
  12. else
  13. firstShip.y = planets[1].y - love.math.random(300, 500)
  14. end
  15. end
  16. for i in ipairs(planets) do
  17. planets[i]:update(dt)
  18. end
  19. if animationSecsLeft > 0 then
  20. animationSecsLeft = animationSecsLeft - dt
  21. end
  22. firstShip:update(dt)
  23. if shipIsHit then
  24. shipIsHit = false
  25. firstShip:reset()
  26. firstShip.x = -100
  27. if (planets[1].y < WINDOW_HEIGHT/2) then
  28. firstShip.y = love.math.random(WINDOW_HEIGHT/2, WINDOW_HEIGHT)
  29. else
  30. firstShip.y = love.math.random(0, WINDOW_HEIGHT/2)
  31. end
  32. --print("ship is hit")
  33. end
  34. end
  35. function menu.draw(dt)
  36. firstShip:draw()
  37. for i in ipairs(planets) do
  38. planets[i]:draw(dt)
  39. end
  40. if animationSecsLeft > 0 then
  41. love.graphics.setColor(1,1,1,1-1/(animationSecsLeft+0.000001))
  42. love.graphics.draw(logo, 0,0)
  43. else
  44. love.graphics.setFont(titlefont)
  45. love.graphics.printf("NuclearGravity", 0, 20, WINDOW_WIDTH, "center")
  46. menu:butt(buttons, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3)
  47. love.keyboard.mouseisReleased = false
  48. end
  49. end
  50. return menu