Sketched the MenuState implementation.
This commit is contained in:
22
menu.py
22
menu.py
@@ -18,6 +18,18 @@ class MenuState(BaseState):
|
|||||||
self.rectangle = pygame.Rect(screen_center[0] - 50, screen_center[1] - 50, 100, 100)
|
self.rectangle = pygame.Rect(screen_center[0] - 50, screen_center[1] - 50, 100, 100)
|
||||||
self.next_transition = VALID_STATES['STAY']
|
self.next_transition = VALID_STATES['STAY']
|
||||||
|
|
||||||
|
# Load main menu buttons.
|
||||||
|
|
||||||
|
# Load main menu labels.
|
||||||
|
|
||||||
|
# Load score menu buttons.
|
||||||
|
|
||||||
|
# Load score menu labels.
|
||||||
|
|
||||||
|
# Load story screen sprites.
|
||||||
|
|
||||||
|
# Add sound support.
|
||||||
|
|
||||||
def input(self):
|
def input(self):
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if android:
|
if android:
|
||||||
@@ -30,7 +42,15 @@ class MenuState(BaseState):
|
|||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
self.next_transition = VALID_STATES['QUIT']
|
self.next_transition = VALID_STATES['QUIT']
|
||||||
|
|
||||||
|
# Detect mouse clicks (taps)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
# Check collisions with current buttons.
|
||||||
|
|
||||||
|
# Switch submenu if able.
|
||||||
|
# If switching to score submenu, load scores database.
|
||||||
|
# If switching to story submenu, count time to leave.
|
||||||
|
|
||||||
if self.next_transition != VALID_STATES['QUIT']:
|
if self.next_transition != VALID_STATES['QUIT']:
|
||||||
if self.count < 120:
|
if self.count < 120:
|
||||||
self.count += 1
|
self.count += 1
|
||||||
@@ -41,5 +61,7 @@ class MenuState(BaseState):
|
|||||||
return self.next_transition
|
return self.next_transition
|
||||||
|
|
||||||
def render(self, canvas):
|
def render(self, canvas):
|
||||||
|
# Draw the appropiate submenu.
|
||||||
|
|
||||||
canvas.fill(self.background_color)
|
canvas.fill(self.background_color)
|
||||||
pygame.draw.rect(canvas, (0, 255, 255), self.rectangle)
|
pygame.draw.rect(canvas, (0, 255, 255), self.rectangle)
|
||||||
|
|||||||
Reference in New Issue
Block a user