Mind.Imagination

Classes, methods and functions marked with * aren’t for usual cases, they are made to help to the rest of the library.

Part of library for Main Menu.

Mind.Imagination.ARROWS = [(273, 'up'), (274, 'down'), (276, 'left'), (275, 'right')]

List of keys (arrows) for Menu changing index.

Mind.Imagination.HIT = [(13, 'hit'), (32, 'hit')]

List of keys for Menu selecting option.

Mind.Imagination.RETURN = [(13, 'return')]

List of keys for input option return.

Mind.Imagination.useless(*useless_args)[source]

Function that doesn’t do anything.

Mind.Imagination.ch_image(new_image)[source]

Returns function which changes pusher image.

Parameters:new_image (pygame.Surface) – new image for option
Returns:function
Mind.Imagination.ch_pos(off)[source]

Returns function which changes pusher position.

Parameters:off (tuple of numbers) – x and y change
Returns:function
Mind.Imagination.ch_text(new_text, error=True)[source]

Returns function which changes pusher text (only for text_pushers).

Parameters:
  • new_text (str) – new text for pusher
  • error (bool) – if True raises error if pusher isn’t text_pusher
Returns:

function

Mind.Imagination.ch_color(new_color, error=True)[source]

Returns function which changes pusher color (only for text_pushers).

Parameters:
  • new_color (color-like tuple) – new color for pusher
  • error (bool) – if True raises error if pusher isn’t text_pusher
Returns:

function

Mind.Imagination.ch_font(new_font, error=True)[source]

Returns function which changes pusher font (only for text_pushers).

Parameters:
  • new_font (pygame.font.Font) – font for puhser to be changed
  • error (bool) – if True raises error if pusher isn’t text_pusher
Returns:

function

Mind.Imagination.reset(im=True, pos=True)[source]

Returns function which resets pusher.

Parameters:
  • im (bool) – if True resets image
  • pos (bool) – if True resets position
Returns:

function

Returns function which leads game to onother place.

Parameters:place (PLACE) – place for game current place
Returns:function
Mind.Imagination.Quit(obj, self)[source]

Quits game.

Mind.Imagination.joined(List)[source]

Returns function which executes all function in a given list.

Parameters:List (list) – list of all functions which will be executed
Returns:function
Mind.Imagination.set_printer(printer)[source]

Sets default printer for print.

Parameters:printer – printer which will be default for print()
Mind.Imagination.normalize_print()[source]

Normalize print().

Mind.Imagination.equal(image1, image2)[source]

Test if two images are equal.*

class Mind.Imagination.PLACE(active=False)[source]

Bacis class for states of main menu.

Parameters:active (bool) – place activity
activate()[source]

Activates place.

deactivate()[source]

Deactivates place.

class Mind.Imagination.Game(main_place)[source]

Bacis game class main menu.

Parameters:main_place – first place for game
add_menu(menu)[source]

Adds menu to game.*

blit()[source]

Blits game current menu.

change(new)[source]

Change game current place.

Parameters:new (PLACE) – new place which will be blitted
define(**options)[source]

Defines options parameters for all menues.

Parameters:options – option parameters for all menues (see Main_menu and option)
declare(type_=None, **options)[source]

Defines menues parameters.

Parameters:
  • type (type) – type of all menues in game (None for will be defined later).
  • options – menu parameters (see Main_menu)
get_from(prior=False, **rest)[source]
Returns menu from game combining previously defined and rest
arguments.
Parameters:
  • prior (bool) – if True rest options are prefered otherwise previously defined are prefered.
  • rest – menu parameters which aren’t defined by Game.declare()
Returns:

menu or any other type defined by type argument

set_from(prior=False, **rest)[source]
Like get_from() but this function automatically sets
menu for game menu.
Parameters:
  • prior (bool) – if True rest options are prefered otherwise previously defined are prefered.
  • rest – menu parameters which aren’t defined by Game.declare()
Returns:

menu or any other type defined by type argument

run()[source]

Returns is game still running.

Returns:True if game is running otherwise False
kill()[source]

Ends game running.

class Mind.Imagination.Hyper_game[source]

Game for easy places controlling.

add_menu(menu)[source]

Adds menu to game.*

blit()[source]

Blits game current menu.

set_menu(menu)[source]

Sets game current menu.

Parameters:menu (Main_menu) – Menu which will be blitted
class Mind.Imagination.Keyboard(definer, flags=0)[source]

Bacis keyboard class.

Parameters:definer (list of tuples) – defines keyboard keys
extend(extension)[source]

Extends keyboard definer.

Parameters:extension (list of tuples) – defines new keyboard keys
update()[source]

Updates keyboard.*

class Mind.Imagination.Main_menu(places, x_distance, y_distance, *options, off=(0, 0), off_type='pixel', start=(50, 50), keyboard=<Mind.Imagination.Keyboard object at 0x01827B90>, dec=['up', 'down', 'hit'])[source]

Basic menu class.

Parameters:
  • places (PLACE or list of PLACE) – place/es on which will menu be blitted
  • x_distance (int) – x distance between each option
  • y_distance (int) – y distance between each option
  • options (option) – menu options
  • off (tuple of two ints) – how off menu is (on relation to the center of screen)
  • off_type (str) – if ‘pixel’ off will be measured in pixels, if ‘percent’ (or ‘%’) off will be measured in percent of screen
  • keyboard (Keyboard) – keyboard which will be used in menu
add_option(option, seted_option=False)[source]

Adds new option to menu.

Parameters:
  • option (:py:class:option) – option which will be added to menu
  • seted_option (bool) – if True menu index will be on that option
set_options()[source]

Should be executed on the end of options adding.

define(type_=None, **options)[source]

Defines options parameters.

Parameters:
  • type (type) – type of option
  • options – arguments for options
get_from(prior=True, **rest)[source]
Returns option from menu combining previously defined and rest
arguments.
Parameters:
  • prior (bool) – if True rest options are prefered otherwise previously defined are prefered.
  • rest – option parameters which aren’t defined by Main_menu.define()
Returns:

option or any other type defined by type argument

set_from(seted_option=False, prior=True, **rest)[source]

Sets option to menu.

Parameters:
  • seted_option (bool) – if True menu index will be on that option
  • prior (bool) – if True rest options are prefered otherwise previously defined are prefered
  • rest – option parameters which aren’t defined by Main_menu.define()
set_game(game)[source]

Sets menu to given game.

Parameters:game (Game) – game which will be added to menu
blit()[source]

Blits menu.

get_keyboard()[source]

Returns game menu keyboard.

Returns:menu keyboard
Return type:Keyboard
lock()[source]

Locks menu index.*

unlock()[source]

Unlocks menu index.*

Mind.Imagination.Vertical_menu(places, distance, *options, off=(0, 0), off_type='pixel', keyboard=<Mind.Imagination.Keyboard object at 0x0282E910>, start=(50, 50), dec=['up', 'down', 'hit'])[source]

Returns menu which is vertical.

Parameters:
  • places (PLACE or list of PLACE) – place/es on which will menu be blitted
  • distance (int) – distance between each option
  • options (option) – menu options
  • off (tuple of two ints) – how off menu is (on relation to the center of screen)
  • off_type (str) – if ‘pixel’ off will be measured in pixels, if ‘percent’ (or ‘%’) off will be measured in percent of screen
  • keyboard (Keyboard) – keyboard which will be used in menu
Mind.Imagination.Horizontal_menu(places, distance, *options, off=(0, 0), off_type='pixel', keyboard=<Mind.Imagination.Keyboard object at 0x0282EA90>, start=(50, 50), dec=['left', 'right', 'hit'])[source]

Returns menu which is horizontal.

Parameters:
  • places (PLACE or list of PLACE) – place/es on which will menu be blitted
  • distance (int) – distance between each option
  • options (option) – menu options
  • off (tuple of two ints) – how off menu is (on relation to the center of screen)
  • off_type (str) – if ‘pixel’ off will be measured in pixels, if ‘percent’ (or ‘%’) off will be measured in percent of screen
  • keyboard (Keyboard) – keyboard which will be used in menu
class Mind.Imagination.printer(x, y, font, newl, color=(0, 0, 0))[source]

Basic printer (for print()) class.

Parameters:
  • x (int) – x of print place
  • y (int) – y of print place
  • font (pygame.font.Font) – text font
  • newl (int) – space between lines
write(text)[source]

Writes text to priter.*

clear()[source]

Clears text on printer

blit()[source]

Blits printer

class Mind.Imagination.option(image, menu, do=<function useless>, pos_do=<function useless>, anti_pos_do=<function useless>)[source]

Bacis menu option class.

Parameters:
  • image (pygame.Surface) – option image
  • menu (Main_menu) – option menu
  • do (function) – what happens when option is activated
  • pos_do (function) – what happens when index comes to option
  • anti_pos_do (function) – what happens when index to another option
set_position(x, y)[source]

Sets option’s position.*

reset_position(x, y)[source]

Changes option’s position*

blit()[source]

Blits option.*

hit()[source]

Executed when menu index is on option and when space ispressed.*

bold()[source]

Executed when menu index comes on option.*

un_bold()[source]

Executed when menu index comes out of option.*

class Mind.Imagination.pusher(x1, y1, image, obj, do, pos_do, anti_pos_do)[source]

Bacis independed option class (mostly used in option class).*

blit()[source]

Blits pusher.*

hit()[source]

Executed when menu index is on option and when space is pressed.*

bold()[source]

Executed when menu index comes on option.*

un_bold()[source]

Executed when menu index comes out of option.*

reset(im, pos)[source]

Resets pusher.

class Mind.Imagination.text_option(font, text, color, menu, do=<function useless>, pos_do=<function useless>, anti_pos_do=<function useless>, cl_txt=None)[source]

Textual menu option class(subclass of option).

Parameters:
  • font (pygame.font.Font) – option font
  • color (color-like tuple) – option color
  • text (str) – option text
  • menu (Main_menu) – option menu
  • do (function) – what happens when option is activated
  • pos_do (function) – what happens when index comes to option
  • anti_pos_do (function) – what happens when index to another option
set_position(x, y)[source]

Sets option’s position.*

blit()[source]

Blits option.*

write(text)[source]

Writes to option’s text.

Parameters:text (str) – text which will be written to option
clear()[source]

Cleats option’s text.

class Mind.Imagination.text_pusher(x1, y1, font, text, cl_text, color, obj, do, pos_do, anti_pos_do)[source]

Textual independed option class (mostly used in text_option class, subclass of pusher).*

update()[source]

Updates pusher.*

write(text)[source]

Writes to pusher’s text.

Parameters:text (str) – text which will be written to option
clear()[source]

Cleats pusher’s text.

class Mind.Imagination.input_option(font, text, color, menu, do=<function useless>, pos_do=<function useless>, anti_pos_do=<function useless>, cl_txt=None, pub='return', ret='return', snd=<function useless>, act_on='hit')[source]

Input menu option class(subclass of text_option).

Parameters:
  • font (pygame.font.Font) – option font
  • color (color-like tuple) – option color
  • text (str) – option text
  • menu (Main_menu) – option menu
  • do (function) – what happens when option is activated
  • pos_do (function) – what happens when index comes to option
  • anti_pos_do (function) – what happens when index to another option
  • pub (str) – when will text be entered
  • ret (str) – when will you return to main menu
  • snd (function) – what happens with text you wrote
  • act_on (str) – when will you enter input option
set_position(x, y)[source]

Sets option’s position.*

blit()[source]

Blits option.*

class Mind.Imagination.input_pusher(x1, y1, font, text, cl_text, color, obj, do, pos_do, anti_pos_do, snd, pub, ret, act_on)[source]

Input independed option class (mostly used in input_option class, subclass of pusher).*

class Mind.Imagination.fake_txt_opt(font, text, color, menu, *args, **kwargs)[source]

Fake menu option, use for titles!