all repos — Legends-RPG @ 20eb9ef9856bba8c568c465383ea6ca2fa495a77

A fantasy mini-RPG built with Python and Pygame.

data/states/main_menu/main_menu.py (view raw)

 1__author__ = 'justinarmstrong'
 2
 3import pygame as pg
 4from ... import setup, tools
 5from ... import constants as c
 6
 7
 8class Menu(tools._State):
 9    def __init__(self):
10        super(Menu, self).__init__()
11        self.next = c.TOWN
12        self.surface = setup.SCREEN
13        self.rect = self.surface.get_rect()
14        text = 'Main Menu placeholder'
15        self.font = pg.font.Font(setup.FONTS['Fixedsys500c'], 15)
16        self.rendered_text = self.font.render(text, 1, c.BLACK)
17        self.text_rect = self.rendered_text.get_rect()
18        self.text_rect.center = self.rect.center
19        self.game_data = tools.create_game_data_dict()
20        self.name = c.MAIN_MENU
21
22
23    def update(self, surface, keys, current_time):
24        self.current_time = current_time
25        surface.fill(c.WHITE)
26        surface.blit(self.rendered_text, self.text_rect)
27
28    def get_event(self, event):
29        if event.type == pg.KEYDOWN:
30            self.game_data['last state'] = self.name
31            self.done = True