def move_down(*y): if not y: Cursor.y += 1 Screen.print("\033[1B") else: Cursor.y += y Screen.print("\033[" + str(x) + "B")
def move_up(*y): if not y: Cursor.y -= 1 Screen.print("\033[1A") else: Cursor.y -= y Screen.print("\033[" + str(x) + "A")
def move_right(*x): if not x: Cursor.x += 1 Screen.print("\033[1C") else: Cursor.x += x Screen.print("\033[" + str(x) + "C")
def move_left(*x): if not x: Cursor.x -= 1 Screen.print("\033[1D") else: Cursor.x -= x Screen.print("\033[" + str(x) + "D")
def main(): screen = Screen() screen.setWindow(0, 0) screen.setFramerate(30) screen.setFont('resources/fonts/Courier Prime Code.ttf', 24) screen.start()
def main(): screen = Screen() input_path, output_path = argparse() try: input_file = open(input_path, "r") output_file = open(output_path, "w+") except FileNotFoundError: raise SystemExit(USAGE) for item in input_file.read().split("\n"): output_file.write(screen.change_state(item) + "\n") input_file.close() output_file.close()
def create_screen(): if config.virtual_hardware: from screen.virtualscreen import VirtualScreen return VirtualScreen() else: from screen.screen import Screen return Screen()
def enterInit(self): ''' init of main/global structures ''' self.screen = Screen() if ConfigVariableBool('stats').getValue(): self.update_gaming=pstat(self.update_gaming) PStatClient.connect() taskMgr.add(self.update, 'GameClient.update') self.acceptOnce('escape',self.demand,extraArgs=['Quit']) self.demand('Intro')
class Test(unittest.TestCase): def setUp(self): self.test_screen = Screen() def test_create_button(self): self.assertTrue( self.test_screen.create_menu_button(DISPLAY_WIDTH - 110, DISPLAY_HEIGHT - 40)) def test_draw_sidebar(self): Screen.draw_sidebar( Player(1, 1, [], 1, bonus_on_level=None, level_map=None), 4, 1) self.assertTrue(True)
class Game(object): def __init__(self): self.screen = Screen() self.done = False def start_game(self): self.screen.main_menu() while not self.done: self.events() # pg.display.update() def events(self): for event in pg.event.get(): if event.type == pg.QUIT: self.done = True else: self.keys = pg.key.get_pressed() def next_level(self): pass def quit_game(self): pass
class GameClient(FSM.FSM): def __init__(self): FSM.FSM.__init__(self, 'GameClient.fsm') self.defaultTransitions = { 'Game_setup':['Main_menu', 'Gaming'], 'Gaming':['Stats', 'Pause', 'Quit'], 'Init':['Intro'], 'Intro':['Main_menu'], 'Main_menu':['Options', 'Game_setup', 'Quit', 'Load_game'], 'Options':['Main_menu', 'Gaming'], 'Pause':['Main_menu', 'Quit', 'Options', 'Gaming'], 'Quit':[], 'Stats':['Game_setup'], } #any method in this global list gets called once a frame __builtin__.update_list=[] #any object in this global list gets its dispose method called by current frame's end __builtin__.dispose_list=[] self.is_running=True self.screen=None self.fake_keypresses=[]#['q','a']#,'mouse1','mouse1-up','space'] def enterGame_setup(self): self.screen.open_game_setup() self.acceptOnce(self.screen.frame.sgn_start, self.demand, extraArgs=['Gaming']) if ConfigVariableBool('dev-mode').getValue(): messenger.send(self.screen.frame.sgn_start) def exitGame_setup(self): #TODO grab setup options here self.game_conf=self.screen.frame.config self.screen.close() def enterGaming(self): self.proxy=ServerProxy() self.proxy.send_config(self.game_conf) self.screen.open_gaming() del self.game_conf update_list.append(self.update_gaming) #meant for synchro with server. #not intensely used until now, but would when server is ran in its own thread, #or when it is separated for real networked gaming. self.frame_no=GEntity.frame_no=0 def exitGaming(self): self.screen.close() update_list.remove(self.update_gaming) def enterInit(self): ''' init of main/global structures ''' self.screen = Screen() if ConfigVariableBool('stats').getValue(): self.update_gaming=pstat(self.update_gaming) PStatClient.connect() taskMgr.add(self.update, 'GameClient.update') self.acceptOnce('escape',self.demand,extraArgs=['Quit']) self.demand('Intro') def exitInit(self):pass def enterIntro(self): ''' game introduction. video/screens. ''' #skip to main menu with enter self.acceptOnce(ConfigVariableString('key-confirm').getValue(), self.demand,extraArgs=['Main_menu']) #go to main menu when screen is done self.acceptOnce(Screen.sgn_intro_done, self.demand,extraArgs=['Main_menu']) #show splash intro self.screen.open_intro() if ConfigVariableBool('dev-mode').getValue(): self.demand('Main_menu') def exitIntro(self): self.screen.close_intro() self.ignore(ConfigVariableString('key-confirm').getValue()) self.ignore(Screen.sgn_intro_done) def enterMain_menu(self): ''' menu offers 4 choices: -play game -load game -options -quit ''' self.screen.open_main_menu() self.acceptOnce(self.screen.frame.sgn_play, self.demand,extraArgs=['Game_setup']) if ConfigVariableBool('dev-mode').getValue(): self.demand('Game_setup') def exitMain_menu(self): self.screen.close() def enterOptions(self):pass def exitOptions(self):pass def enterPause(self):pass def exitPause(self):pass def enterQuit(self): ''' last cleanup before closing the window. ''' #TODO clean close self.screen.close() del self.screen self.is_running = False def exitQuit(self):pass def update_gaming(self): # out('client update',frame_no=self.frame_no) void=True self.frame_no+=1 GEntity.frame_no=self.frame_no #process data from server (server's update included) for d in self.proxy.new_data: void=False #some of them are to be processed here if network.stc_start_game in d: out('network.stc_start_game') self.screen.frame.start_game() elif network.stc_end_game in d: out('network.stc_end_game') self.demand('Stats') #if etc #the rest is given to the gframe, responsible for the graphic stuff else: self.screen.frame.process_server_input(d) if void: if len(self.fake_keypresses): messenger.send(self.fake_keypresses[0]) self.fake_keypresses.pop(0) for o in __builtin__.dispose_list:o.dispose() __builtin__.dispose_list=[] def update(self, task): ''' main update method. runs the whole time. other updates can register to update_list to get called every frame. ''' [f() for f in update_list] return task.again
def __init__(self): self.screen = Screen() self.done = False
def setUp(self): self.test_screen = Screen()
def test_draw_sidebar(self): Screen.draw_sidebar( Player(1, 1, [], 1, bonus_on_level=None, level_map=None), 4, 1) self.assertTrue(True)
from cursor.cursor import Cursor from screen.screen import Screen from getch import getch import time import sys Screen.clear() screen_width, screen_height = Screen.size() print(str(screen_width) + " " + str(screen_height)) key = getch() Screen.print(key)
def move(x, y): Cursor.x = x Cursor.y = y Screen.print("\033[" + str(x) + ";" + str(y) + "H")