menu.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Menu = class()
  2. function Menu:init()
  3. self.sound = Sound()
  4. self.menuSounds = self.sound:loop({sound = 'menu'})
  5. self.bg = love.graphics.newImage('media/graphics/main-menu.png')
  6. self.font = love.graphics.newFont('media/fonts/pixel.ttf', 8)
  7. self.creditsAlpha = 0
  8. love.mouse.setCursor(love.mouse.newCursor('media/graphics/cursor.png'))
  9. end
  10. function Menu:update()
  11. self.creditsAlpha = timer.rot(self.creditsAlpha)
  12. end
  13. function Menu:draw()
  14. love.graphics.setColor(255, 255, 255)
  15. love.graphics.draw(self.bg)
  16. love.graphics.setFont(self.font)
  17. love.graphics.setColor(255, 255, 255, math.min(self.creditsAlpha * 255, 255))
  18. love.graphics.print('We do not mind who gets the credit.', 2, 0)
  19. end
  20. function Menu:keypressed(key)
  21. end
  22. function Menu:keyreleased(key)
  23. end
  24. function Menu:mousepressed(x, y, b)
  25. if math.inside(x, y, 435, 220, 190, 90) then
  26. self.menuSounds:stop()
  27. Context:remove(ctx)
  28. Context:add(Game)
  29. elseif math.inside(x, y, 425, 335, 210, 90) then
  30. print('Harry Truman bitch!')
  31. self.creditsAlpha = 2
  32. elseif math.inside(x, y, 455, 445, 160, 90) then
  33. love.event.quit()
  34. end
  35. end
  36. function Menu:mousereleased(x, y, b)
  37. end