all repos — Legends-RPG @ 88d77458a8099a4f68eaee9b37e58a836efe89bc

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, name):
10        super(Menu, self).__init__(name)
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
21
22    def update(self, surface, keys, current_time):
23        self.current_time = current_time
24        surface.fill(c.WHITE)
25        surface.blit(self.rendered_text, self.text_rect)
26
27    def get_event(self, event):
28        if event.type == pg.KEYDOWN:
29            self.game_data['last state'] = self.name
30            self.done = True