summaryrefslogtreecommitdiff
path: root/src/sliceitoff/mainmenu
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/mainmenu')
-rw-r--r--src/sliceitoff/mainmenu/mainmenu.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sliceitoff/mainmenu/mainmenu.py b/src/sliceitoff/mainmenu/mainmenu.py
index e0466a5..551e7b5 100644
--- a/src/sliceitoff/mainmenu/mainmenu.py
+++ b/src/sliceitoff/mainmenu/mainmenu.py
@@ -3,9 +3,12 @@ from enum import IntEnum
import pygame
from screens import mainmenu_screen
+from display import Scaling
from game.anykey import anykey
+MOUSE_TRESHOLD = 100
+
class MenuItems(IntEnum):
""" Items in the menu. Should match mainmenu_screen """
NEWGAME = 0
@@ -22,6 +25,7 @@ class Mainmenu(pygame.sprite.Group):
self.active = True
self.fadeout = 1_000
self.selection = 0
+ self.mousey = 0
def update(self, dt = 0):
""" Does it all. Reads keyboard and updates screen """
@@ -45,6 +49,9 @@ class Mainmenu(pygame.sprite.Group):
self.selection = MenuItems.QUIT
self.explode = True
break
+ if event.type == pygame.MOUSEBUTTONDOWN and event.button <= 3:
+ self.explode = True
+ break
if event.type == pygame.KEYDOWN:
match event.key:
case pygame.K_KP_ENTER | pygame.K_RETURN | pygame.K_RIGHT:
@@ -60,5 +67,12 @@ class Mainmenu(pygame.sprite.Group):
case pygame.K_DOWN:
self.selection += 1
self.selection %= len(MenuItems)
+ elif event.type == pygame.MOUSEMOTION:
+ self.mousey += pygame.mouse.get_rel()[1]
+ pygame.mouse.set_pos(Scaling.center)
+ if abs(self.mousey) > MOUSE_TRESHOLD:
+ self.selection += 1 if self.mousey > 0 else -1
+ self.selection %= len(MenuItems)
+ self.mousey = 0
self.empty()
self.add(mainmenu_screen(self.selection))