def __init__(self, title, number_of_columns, number_of_rows, column_titles, field_size): """ :param title: str; tables title, dsipalyed on top of the table :param number_of_columns: int; number of columns in the table :param number_of_rows: int; number of rows in the table :param column_titles: list[str, ...]; list containg all columns' titles :param field_size: float; size of a virtual field that is determined by the size of the window that inhabits the GUI """ self.title = title font = SysFont(None, int(field_size * 3 / 2)) # sets font self.writing = Writing( title, font, DARKGREEN, (field_size, field_size / 5)) # initializes title as writing self.fake_size = [number_of_columns, number_of_rows] # sets size in rows and colums column_list = [ ] # creates a lsit later containg every column inhabiting the table for i in range(number_of_columns): column_list.append( Column(number_of_rows, column_titles[i], i, title)) # creates a column self.columns = column_list self.refresh_loc(field_size) # initializes coordiantes and locations
def babbinProduceSpeech(): global tookFuel if tookFuel: return Writing('playername', 'male').babbin4() elif metBabbinFirstTime: return Writing('playername', 'male').babbin2() else: return Writing('playername', 'male').babbin1()
def stephenProduceSpeech(): global stepheni stepheni += 1 if stepheni == 5: stepheni = 0 if stepheni == 0: return Writing('playername', 'male').stephen() if stepheni == 1: return Writing('playername', 'male').stephen1() if stepheni == 2: return Writing('playername', 'male').stephen2() if stepheni == 3: return Writing('playername', 'male').stephen3() if stepheni == 4: return Writing('playername', 'male').stephen4()
class Column: """ one column with a title as Writing containing several TableSpot objects """ def __init__(self, number_of_rows, title, column_number, table_title): """ :param number_of_rows: int; number of rows column contains :param title: str; title of column, displayed bigger than TableSpot writings on top of column :param column_number: int; x coord in the table the column is in """ self.title = title self.number = column_number self.writing = Writing(title, None, DARKGREEN, None) # initializes its writing spot_list = [ ] # creates a list later containing all spots in this column for i in range(number_of_rows): spot_list.append(TableSpot("test", column_number, i, table_title)) # adds TableSpot self.spots = spot_list self.table_title = table_title def refresh_loc(self, field_size): """ refreshes column's coordiantes on the table surface :param field_size: float; size of a virtual field that is determined by the size of the window that inhabits the GUI """ self.writing.font = SysFont(None, int(field_size)) # resizes font # calculates titles's center column_width = 3 if self.table_title == "Remaining Ships" else 4 self.writing.top_left_corner = [ field_size * 3 / 2 + field_size * self.number * column_width, field_size * 3 / 2 ] for spot in self.spots: # goes through every spot in this column spot.refresh_loc(field_size) # refreshes its coordiantes def draw(self, language, table_surf, ships): """ displays its title and all spots in this column on the table surface :param language: str; language the program's texts are currently displayed in :param table_surf: Surface; surface the table is shown on :param ships: list[list[Ship, ..], list]; list containing all ships that are on the board """ self.writing.content = translate_title( language, self.title) # transaltes title if neccessary self.writing.draw(table_surf, True) # dsipalys the title as writing for spot in self.spots: # goes through every spot in this column spot.draw(table_surf, language, ships) # displays its content as writing
def __init__(self, content, column_number, row_number, title): """ :param content: str; cells content displayed as text :param column_number: int; x coord in the table this spot is in :param row_number: int; y coord in the table this spot is in """ self.column = column_number self.row = row_number if not column_number: # gets content for first column that does not change content = get_content_left_column(row_number, title) self.title = content self.writing = Writing(content, None, LIGHTGREEN, None) # initializes its writing self.table_title = title
class Line: """ one line of Chat using writing.Writing to display itself """ def __init__(self, field_size, line_number, orientation): """ creates Line and its writing :param field_size: float; size of a virtual field that is determined by the size of the window that inhabits the GUI :param line_number: int; 0 - 5, number to sort line :param orientation: str; width/height, what is bigger """ # sets size self.width = field_size * 6 self.height = field_size * 4 / 6 # sets location x_coord = 24 if orientation == "width" else 12 location = [field_size * x_coord, field_size * 0.5 + field_size * 4 / 6 * line_number] self.number = line_number # creates writing with default values content = None color = (125, 125, 125) font = SysFont(None, int(field_size * 4 / 6)) self.writing = Writing(content, font, color, location) def refresh_loc(self, field_size, orientation): """ refreshes line's size and writing's coordinates :param field_size: float; size of a virtual field that is determined by the size of the window that inhabits the GUI :param orientation: str; width/height, what is bigger """ # updates size self.width = field_size * 6 self.height = field_size * 4 / 6 # updates writing's coordiantes x_coord = 24 if orientation == "width" else 12 self.writing.top_left_corner = [field_size * x_coord, field_size * 0.5 + field_size * 4 / 6 * self.number] self.writing.font = SysFont(None, int(field_size * 4 / 6)) def draw(self, screen): """ displays line on the game window :param screen: Surf; surface that covers the whole window """ if self.writing.content: # line has a dsipalying meesage self.writing.draw(screen) # line's writing is displayed
def __init__(self, number_of_rows, title, column_number, table_title): """ :param number_of_rows: int; number of rows column contains :param title: str; title of column, displayed bigger than TableSpot writings on top of column :param column_number: int; x coord in the table the column is in """ self.title = title self.number = column_number self.writing = Writing(title, None, DARKGREEN, None) # initializes its writing spot_list = [ ] # creates a list later containing all spots in this column for i in range(number_of_rows): spot_list.append(TableSpot("test", column_number, i, table_title)) # adds TableSpot self.spots = spot_list self.table_title = table_title
def __init__(self, field_size, line_number, orientation): """ creates Line and its writing :param field_size: float; size of a virtual field that is determined by the size of the window that inhabits the GUI :param line_number: int; 0 - 5, number to sort line :param orientation: str; width/height, what is bigger """ # sets size self.width = field_size * 6 self.height = field_size * 4 / 6 # sets location x_coord = 24 if orientation == "width" else 12 location = [field_size * x_coord, field_size * 0.5 + field_size * 4 / 6 * line_number] self.number = line_number # creates writing with default values content = None color = (125, 125, 125) font = SysFont(None, int(field_size * 4 / 6)) self.writing = Writing(content, font, color, location)
def frostingEffect(thisFrosting, thisMsBabbin, clickx, clicky): global tookFuel if thisMsBabbin.click(clickx, clicky, False): thisFrosting._inventory.removeItem(thisFrosting) thisFrosting.depopulate funkyFrostingFuel.populate() tookFuel = True info = Dialogue(canvas, Writing("playername", "male").babbin4(), 'Mrs. Babbin', sprites.babbinface, chemRoom, msBabbin, player, inventory) info.show() return True return False
def mullarkeyProduceSpeech(): return Writing('playername', 'male').mullarkey()
def hanasDialogue(): if stairwellEnter: inventory.addItem(flashlight) return Writing('playername', 'male').chanas3() else: return Writing('playername', 'male').chanas2()
from room import Room from door import Door from infobox import Infobox import sprites from random import choice # Create canvas root = Tk() canvas = Canvas(root, width=1024, height=1024, bg='white') canvas.grid() canvas.focus_set() # Player inventory = Inventory(canvas) player = Player(canvas, 64, 96, 475, 510, 1, sprites.boyAvatars, 8, inventory) writeObject = Writing('playerName', 'male') # Rooms nexus = Room([], [player], sprites.rooms[0], canvas, inventory) freshmanHallway = Room([], [player], sprites.rooms[1], canvas, inventory) freshmanSophomoreHallway = Room([], [player], sprites.rooms[2], canvas, inventory) sophomoreJuniorHallway = Room([], [player], sprites.rooms[3], canvas, inventory) juniorHallway = Room([], [player], sprites.rooms[4], canvas, inventory) juniorNexus = Room([], [player], sprites.rooms[5], canvas, inventory) boysBathroom = Room([], [player], sprites.rooms[6], canvas, inventory) courtyard = Room([], [player], sprites.rooms[7], canvas, inventory) mathRoom = Room([], [player], sprites.rooms[8], canvas, inventory) chemRoom = Room([], [player], sprites.rooms[9], canvas, inventory) stairwellEnter = False
class TableSpot: """ one single table cell dispalying itself as its writing """ def __init__(self, content, column_number, row_number, title): """ :param content: str; cells content displayed as text :param column_number: int; x coord in the table this spot is in :param row_number: int; y coord in the table this spot is in """ self.column = column_number self.row = row_number if not column_number: # gets content for first column that does not change content = get_content_left_column(row_number, title) self.title = content self.writing = Writing(content, None, LIGHTGREEN, None) # initializes its writing self.table_title = title def refresh_loc(self, field_size): """ refreshes spot's coordiantes on the table surface :param field_size: float; size of a virtual field that is determined by the size of the window that inhabits the GUI """ self.writing.font = SysFont(None, int(field_size * 4 / 7)) # resizes font # calculates writing's center column_width = 3 if self.table_title == "Remaining Ships" else 4 self.writing.top_left_corner = [ field_size * (3 / 2 + self.column * column_width), field_size * (5 / 2 + self.row) ] # calcualtes writing's size, currently not used further self.size = [field_size * 3, field_size * 3] def draw(self, table_surf, language, ships): """ displays its writing on the table surface and thus on the game window :param table_surf: Surface; surface the table is shown on :param language: str; language the program's texts are currently displayed in :param ships: list[list[Ship, ..], list]; list containing all ships that are on the board """ if self.column: # content is dynamic self.get_content(language, ships) # updates content elif self.table_title == "Stats": self.writing.content = translate_title(language, self.title) self.writing.draw(table_surf, True) # displays itself as writing def get_content(self, language, ships): """ updates content depending on language and remaining ships :param language: str; language the program's texts are currently displayed in :param ships: list[list[Ship, ..], list]; list containing all ships that are on the board """ if self.table_title == "Remaining Ships": self.writing.content = get_content_spot_ships( self.column, self.row, ships, language) else: self.writing.content = get_content_spot_stats( self.column, self.row, language)
class Table: """ table with a title containing several columns and rows, only columns as objects """ def __init__(self, title, number_of_columns, number_of_rows, column_titles, field_size): """ :param title: str; tables title, dsipalyed on top of the table :param number_of_columns: int; number of columns in the table :param number_of_rows: int; number of rows in the table :param column_titles: list[str, ...]; list containg all columns' titles :param field_size: float; size of a virtual field that is determined by the size of the window that inhabits the GUI """ self.title = title font = SysFont(None, int(field_size * 3 / 2)) # sets font self.writing = Writing( title, font, DARKGREEN, (field_size, field_size / 5)) # initializes title as writing self.fake_size = [number_of_columns, number_of_rows] # sets size in rows and colums column_list = [ ] # creates a lsit later containg every column inhabiting the table for i in range(number_of_columns): column_list.append( Column(number_of_rows, column_titles[i], i, title)) # creates a column self.columns = column_list self.refresh_loc(field_size) # initializes coordiantes and locations def refresh_loc(self, field_size): """ updates coordinates on teh table surface :param field_size: float; size of a virtual field that is determined by the size of the window that inhabits the GUI """ # gets surface with fitting size if self.title == "Remaining Ships": self.location = [field_size * 25, field_size * 5 ] # updates location on the game window column_width = 3 else: self.location = [field_size * 10, field_size * 5.5] column_width = 3.75 self.surf = Surface((self.fake_size[0] * 4 * field_size, self.fake_size[1] * 3 * field_size)) self.writing.font = SysFont(None, int(field_size * 3 / 2)) # resizes title's font # calculates title's center self.writing.top_left_corner = [ field_size * self.columns.__len__() * column_width / 2, field_size * 3 / 4 ] for column in self.columns: # goes through every column column.refresh_loc(field_size) # updates its locations def draw_outline(self, table_surf): """ does nothing, use to draw outline? :param table_surf: Surface; surface the table is shown on """ pass def draw(self, language, screen, ships=[[[0]]]): """ dsiplays table on table surface and table surface on the game window :param language: str; language the program's texts are currently displayed in :param screen: Surface; surface that covers the whole window :param ships: list[list[Ship, ..], list]; list containing all ships that are on the board """ table_surf = self.surf.copy( ) # gets a new surface to prevent overlaying writings table_surf.set_colorkey( BLACK ) # sets a colorkey to make table surface transparent apart from its content self.writing.content = translate_title( language, self.title) # translates title if neccessary self.writing.draw(table_surf, True) # displays its title self.draw_outline( table_surf) # does nothing, potentially display an outline here? for column in self.columns: # goes through every column column.draw(language, table_surf, ships) # displays it screen.blit(table_surf, self.location) # displays table surface on game window