Retro Game Library Documentation
retrogamelib.dialog
This module has some useful NES/GameBoy style GUI, such as a menu and dialog box.
dialog.Menu(object) The Menu is an object that lets you create menus with selectable options.
__init__(font, options)
Create a new menu object. font
should be a Font object. options
should be a list of options. e.g. ["New Game", "Options", "Exit Game"]
draw(surface, pos, background=None, border=None)
Draws the menu to a surface. surface
should be a pygame.Surface object. pos
should be the position of the menu to be drawn at (e.g. (x, y)
). background
can be an RGB tuple for the background of the menu. border
can be an RGB tuple for the border of the menu.
move_cursor(dir)
Move the menu cursor. dir
is the direction the cursor will move in, 1 being down, -1 being up.
get_option() -> return int, str
Returns the current option the menu cursor is on. e.g. will return 0 if the menu is on the first option, 1 if the menu is on the second option, etc. It also returns the text that the menu is on.
dialog.DialogBox(object) The DialogBox is a box which displays text. It supports text scrolling and multiple pages.
__init__(size, background_color, border_color, font)
Create a new DialogBox object. size
should be an (x, y) tuple the size of the box in pixels. background_color
should be an RGB tuple for the background of the box. border_color
should be an RGB tuple for the color of the border. font
should be a Font object.
set_scrolldelay(delay)
Change the delay of the text scrolling. delay
should be an integer, where 0 is the lowest delay.
set_dialog(dialog)
Set the dialog to display in the box. dialog
should be a list of dialog, e.g. ["This is page 1.", "This is page 2."]
progress()
This will trigger the next "event" of the box. e.g, if the text is scrolling, it will finish the scrolling. If the text is finished scrolling, it will progress to the next page.
draw(surface, pos)
Draw the box to a surface. surface
should be a pygame.Surface object. pos
should be an (x, y) tuple for the box be drawn at.
over() -> return bool
Returns true/false if the dialog box has finished drawing text. (e.g. has progressed past the last page)
close()
Close/finish the box immediately.
Copyright © 2009, pymike and saluk