Exemplo n.º 1
0
 def update_prices_func(file_name):
     win_pick_file.become_target()
     # Open status window to start updating player prices
     settings['update_prices'] = True
     StatusWindow.open_status_window(win_pick_file.x, win_pick_file.y,
                                     db_dict, file_name, settings=settings, win_previous=win_pick_file)
     settings['file_changes'] = True
     win_pick_file.hide()
Exemplo n.º 2
0
    def __init__(self, parent, lines, game_number=0):
        self.lines = lines
        self.auto_mode = False
        self.game_number = game_number
        if lines != None:
            self.lines = shape.list_from_str_list(lines)
            self.lines_shape_index = 0
            self.auto_mode = True
        """
        Intialise the game...
        """
        self.parent = parent
        self.score = 0
        self.level = 0
        self.delay = 1000  #ms

        #lookup table
        self.shapes = [
            square_shape, t_shape, l_shape, reverse_l_shape, z_shape, s_shape,
            i_shape
        ]

        self.thresholds = level_thresholds(500, NO_OF_LEVELS)

        self.status_bar = status_bar(parent)
        self.status_bar.pack(side=TOP, fill=X)
        #print "Status bar width",self.status_bar.cget("width")

        self.status_bar.set("Score: %-7d\t Level: %d " %
                            (self.score, self.level + 1))
        #create the status window
        self.status_window = StatusWindow(parent)
        self.status_window.pack()

        #create the game board
        self.board = Board(parent,
                           scale=SCALE,
                           max_x=MAXX,
                           max_y=MAXY,
                           offset=OFFSET)

        self.board.pack(side=BOTTOM)
        self.board.focus()

        self.parent.bind("<Left>", self.left_callback)
        self.parent.bind("<Right>", self.right_callback)
        self.parent.bind("<Up>", self.up_callback)
        self.parent.bind("<Down>", self.down_callback)
        self.parent.bind("a", self.a_callback)
        self.parent.bind("s", self.s_callback)
        self.parent.bind("p", self.p_callback)
        self.parent.bind("q", self.quit_callback)

        self.shape = self.get_next_shape()

        self.after_id = self.parent.after(self.delay, self.move_my_shape)
Exemplo n.º 3
0
    def __init__(self, app):
        """Constructor.

        Creates the frames and menus.
        """
        title = 'brIDE - v. %s' % __version__
        wx.Frame.__init__(self, None, -1, title)
        self.book = wx.Notebook(self, -1)
        self.statwin = StatusWindow.create(self, (0,550), (800,50))
        self.help = wx.TextCtrl(self, -1)
        self.recent = app.recent
        self.open = []
        self.InitMenu()
        self.InitSizer()
        self.SetSize((800, 600))
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed)
        self.CTRLMAP = {312+999: lambda: self.book.AdvanceSelection(False),
                        313+999: lambda: self.book.AdvanceSelection(True),
                        ord('X')+999: self.OnCtrlX}
        self.CTRLXMAP = {ord('F')+999: lambda: self.OnOpen(None),
                         ord('S')+999: lambda: self.OnSave(None),
                         ord('W')+999: lambda: self.OnSaveAs(None),
                         ord('B'): lambda: self.OnNew(None),
                         ord('K'): lambda: self.OnClose(None),
                         ord('C')+999: lambda: self.OnExit(None)}
        self.ctrlx = False
Exemplo n.º 4
0
    def __init__(self, app):
        """Constructor.

        Creates the frames and menus.
        """
        title = 'brIDE - v. %s' % __version__
        wx.Frame.__init__(self, None, -1, title)
        self.book = wx.Notebook(self, -1)
        self.statwin = StatusWindow.create(self, (0,550), (800,50))
        self.recent = app.recent
        self.InitMenu()
        self.InitSizer()
        self.SetSize((800, 600))
Exemplo n.º 5
0
import StatusWindow

s_path_of_net_xml = "../data/3choices.net.xml"
n_cell_width = 15

sw = StatusWindow.StatusWindow(n_cell_width, s_path_of_net_xml)
Exemplo n.º 6
0
    def __init__(self, parent, lines, game_number = 0):
        self.lines = lines
        self.auto_mode = False
        self.game_number = game_number
        if lines != None:
            self.lines = shape.list_from_str_list(lines)
            self.lines_shape_index = 0
            self.auto_mode = True

        

        """
        Intialise the game...
        """
        self.parent = parent
        self.score = 0
        self.level = 0
        self.delay = 1000    #ms
        
        #lookup table
        self.shapes = [square_shape,
                      t_shape,
                      l_shape,
                      reverse_l_shape,
                      z_shape,
                      s_shape,
                      i_shape ]
        
        self.thresholds = level_thresholds( 500, NO_OF_LEVELS )
        
        self.status_bar = status_bar( parent )
        self.status_bar.pack(side=TOP,fill=X)
        #print "Status bar width",self.status_bar.cget("width")

        self.status_bar.set("Score: %-7d\t Level: %d " % (
            self.score, self.level+1)
        )
        #create the status window
        self.status_window = StatusWindow(parent)
        self.status_window.pack()

        #create the game board
        self.board = Board(
            parent,
            scale=SCALE,
            max_x=MAXX,
            max_y=MAXY,
            offset=OFFSET
            )
        
        self.board.pack(side=BOTTOM)
        self.board.focus()
        

        self.parent.bind("<Left>", self.left_callback)
        self.parent.bind("<Right>", self.right_callback)
        self.parent.bind("<Up>", self.up_callback)
        self.parent.bind("<Down>", self.down_callback)
        self.parent.bind("a", self.a_callback)
        self.parent.bind("s", self.s_callback)
        self.parent.bind("p", self.p_callback)
        self.parent.bind("q", self.quit_callback)
        
        self.shape = self.get_next_shape()

        self.after_id = self.parent.after( self.delay, self.move_my_shape )
Exemplo n.º 7
0
class game_controller(object):
    """
    Main game loop and receives GUI callback events for keypresses etc...
    """
    def __init__(self, parent, lines, game_number = 0):
        self.lines = lines
        self.auto_mode = False
        self.game_number = game_number
        if lines != None:
            self.lines = shape.list_from_str_list(lines)
            self.lines_shape_index = 0
            self.auto_mode = True

        

        """
        Intialise the game...
        """
        self.parent = parent
        self.score = 0
        self.level = 0
        self.delay = 1000    #ms
        
        #lookup table
        self.shapes = [square_shape,
                      t_shape,
                      l_shape,
                      reverse_l_shape,
                      z_shape,
                      s_shape,
                      i_shape ]
        
        self.thresholds = level_thresholds( 500, NO_OF_LEVELS )
        
        self.status_bar = status_bar( parent )
        self.status_bar.pack(side=TOP,fill=X)
        #print "Status bar width",self.status_bar.cget("width")

        self.status_bar.set("Score: %-7d\t Level: %d " % (
            self.score, self.level+1)
        )
        #create the status window
        self.status_window = StatusWindow(parent)
        self.status_window.pack()

        #create the game board
        self.board = Board(
            parent,
            scale=SCALE,
            max_x=MAXX,
            max_y=MAXY,
            offset=OFFSET
            )
        
        self.board.pack(side=BOTTOM)
        self.board.focus()
        

        self.parent.bind("<Left>", self.left_callback)
        self.parent.bind("<Right>", self.right_callback)
        self.parent.bind("<Up>", self.up_callback)
        self.parent.bind("<Down>", self.down_callback)
        self.parent.bind("a", self.a_callback)
        self.parent.bind("s", self.s_callback)
        self.parent.bind("p", self.p_callback)
        self.parent.bind("q", self.quit_callback)
        
        self.shape = self.get_next_shape()

        self.after_id = self.parent.after( self.delay, self.move_my_shape )
    
    
    
    def eval(self):
        touching = 0
        already_hit = []
        for block in self.shape.blocks:
            current = block.coord()
            print "current:", current
            
            #create tuples of coordinates of blocks to check
            right = (current[0]+1, current[1])
            left = (current[0]-1, current[1])
            #TK coord system is down and to right
            #that's why up and down are reversed
            down = (current[0], current[1]+1)
            up = (current[0], current[1]-1)
            
            right_hit = self.board.landed.get(right)
            left_hit = self.board.landed.get(left)
            up_hit = self.board.landed.get(up)
            down_hit = self.board.landed.get(down)
            
            
            if( right_hit and (right not in already_hit)):
                print "\tright hit", right
                already_hit.append(right)
                touching += 1
            if ( left_hit and (left not in already_hit) ):
                print "\tleft hit", left
                already_hit.append(left)
                touching += 1
            if ( up_hit and (up not in already_hit) ):
                print "\tup hit", up
                already_hit.append(up)
                touching += 1
            if ( down_hit and (down not in already_hit) ):
                print "\tdown hit", down
                already_hit.append(down)
                touching += 1
        print "\tTouching: ", touching
        print "-"*20
        
        
    def handle_move(self, direction):
        #if you can't move then you've hit something
        if not self.shape.move( direction ):
            self.status_window.log_text("HIT")
            # if your heading down then the shape has 'landed'
            if direction == DOWN:
                self.eval()
                tmp_score = self.score
                self.score += self.board.check_for_complete_row(
                    self.shape.blocks
                    )
                #check for points added                
                if(self.score > tmp_score):
                    self.status_window.log_text("POINTS " + str(self.score - tmp_score))
                    
                del self.shape
                self.status_window.log_text("LANDED")
                self.shape = self.get_next_shape()

                # If the shape returned is None, then this indicates that
                # that the check before creating it failed and the
                # game is over!
                if self.shape is None:
                    self.status_window.log_text("GAME OVER! SCORE: " + str(self.score))
                    tkMessageBox.showwarning(
                        title="GAME OVER",
                        message ="Score: %7d\tLevel: %d\t" % (
                            self.score, self.level),

                        )

                    Toplevel().quit()
                    self.parent.quit()

                    # self.status_window.quit()
                    # self.status_window.destroy()
                    # sys.exit(0) 
                
                # do we go up a level?
                if (self.level < NO_OF_LEVELS and 
                    self.score >= self.thresholds[ self.level]):
                    self.level+=1
                    self.delay-=100
                    
                self.status_bar.set("Score: %-7d\t Level: %d " % (
                    self.score, self.level+1)
                )
                
                # Signal that the shape has 'landed'
                return False
        return True

    def left_callback( self, event ):
        if self.shape:
            self.status_window.log_text("LEFT")
            self.handle_move( LEFT )
        
    def right_callback( self, event ):
        if self.shape:
            self.status_window.log_text("RIGHT")
            self.handle_move( RIGHT )

    def up_callback( self, event ):
        if self.shape:
            # drop the tetrominoe to the bottom
            while self.handle_move( DOWN ):
                pass

    def down_callback( self, event ):
        if self.shape:
            self.status_window.log_text("DOWN")            
            self.handle_move( DOWN )
            
    def a_callback( self, event):
        if self.shape:
            self.shape.rotate(clockwise=True)
            self.status_window.log_text("ROTATE CLOCKWISE")           
            
    def s_callback( self, event):
        if self.shape:
            self.shape.rotate(clockwise=False)
            self.status_window.log_text("ROTATE COUNTERCLOCKWISE")           
        
    def p_callback(self, event):
        self.parent.after_cancel( self.after_id )
        tkMessageBox.askquestion(
            title = "Paused!",
            message="Continue?",
            type=tkMessageBox.OK)
        self.after_id = self.parent.after( self.delay, self.move_my_shape )
    
    def quit_callback(self, event):
        sys.exit(0)

    def move_my_shape( self ):
        if self.shape:
            self.handle_move( DOWN )
            self.after_id = self.parent.after( self.delay, self.move_my_shape )
        
    def get_next_shape( self ):
        """
        Select the next shape in the list
        """
        if self.lines and len(self.lines) > 0 and self.lines_shape_index < len(self.lines): 
            the_shape = self.lines[self.lines_shape_index]
            self.lines_shape_index = self.lines_shape_index + 1
        else:
            """
            If we were in auto mode, that means we have now ran out of pieces
            Log the score, and move on to the next game
            """
            if self.auto_mode == True:
                print "Game #" + str(self.game_number) + " " + "Score: " + str(self.score)
                return None #This will end the game
            
            """
            Randomly select which tetrominoe will be used next.
            """
            self.shapes = self.status_window.get_shapes()
            the_shape = self.shapes[ randint(0,len(self.shapes)-1) ]

        #check_and_create is a factory function
        s = the_shape.check_and_create(self.board)
        self.status_window.new_shape(s)
        self.status_window.log_board(self.board)
        BoardStates.generate_child_states(self.board, the_shape)
        return s
Exemplo n.º 8
0
import StatusWindow
import NavigationWindow

s_path_of_net_xml = "./test_map/Davenport.net.xml"
s_window_title = "Status Window"
n_max_window_width = 1000
n_max_window_height = 600
n_cell_width = 10
n_edge_length_scale = 1
is_cells_mode_on = False
is_minimap_mode_on = True

sw = StatusWindow.StatusWindow(s_path_of_net_xml)
sw.set_window_title(s_window_title)
sw.set_window_max_dimensions(n_max_window_width, n_max_window_height)
sw.set_edge_length_scale(n_edge_length_scale)
sw.set_cell_width(n_cell_width)
sw.set_cells_mode(is_cells_mode_on)
sw.set_minimap_mode(is_minimap_mode_on)

nw = NavigationWindow.NavigationWindow(sw)
Exemplo n.º 9
0
    def enter_btn_func():
        # Rename file
        if box_type == 'rename':

            # Get new name
            new_file_name = value_tf.value

            if len(new_file_name) > 0:

                if not isfile('JSONs/' + file_prefix + new_file_name + '.json'):
                    # Rename file
                    rename('JSONs/' + file_prefix + old_file_name + '.json',
                           'JSONs/' + file_prefix + new_file_name + '.json')

                    # Disable pick file back button in case the selected file has changed
                    settings['file_changes'] = True

                    PickFile.open_pick_file_window(window_x, window_y, db_dict, settings)
                    win_enter_text.hide()

                else:
                    message.text = "A file with that name already exists."

            else:
                message.text = "File name must be at least 1 character."

        # Duplicate file
        elif box_type == 'duplicate':

            # Get new name
            duplicate_file_name = value_tf.value

            if len(duplicate_file_name) > 0:

                if not isfile('JSONs/' + file_prefix + duplicate_file_name + '.json'):
                    # Create duplicate file
                    copyfile('JSONs/' + file_prefix + old_file_name + '.json',
                             'JSONs/' + file_prefix + duplicate_file_name + '.json')

                    PickFile.open_pick_file_window(window_x, window_y, db_dict, settings)
                    win_enter_text.hide()

                else:
                    message.text = "A file with that name already exists."

            else:
                message.text = "File name must be at least 1 character."

        elif box_type == 'download':
            valid_name = False

            # Get new player database name
            new_player_db_name = value_tf.value

            if new_player_db_name != download_settings['last_entered_text']:
                download_settings['overwrite_counter'] = 0
                message.text = message_text

            if len(new_player_db_name) > 0:

                if not isfile('JSONs/play_db_' + new_player_db_name + '.json'):
                    valid_name = True

                else:
                    download_settings['last_entered_text'] = new_player_db_name

                    if download_settings['overwrite_counter'] == 0:
                        download_settings['overwrite_counter'] += 1
                        message.text = "File already exists. Overwrite?"
                    elif download_settings['overwrite_counter'] == 1:
                        download_settings['overwrite_counter'] += 1
                        message.text = "Are you sure you want to overwrite?"
                    elif download_settings['overwrite_counter'] == 2:
                        download_settings['overwrite_counter'] += 1
                        message.text = "Really, really, really sure?"
                    elif download_settings['overwrite_counter'] >= 3:
                        valid_name = True

                if valid_name:
                    # Open status window to start download of players
                    StatusWindow.open_status_window(win_enter_text.x, win_enter_text.y, db_dict,
                                                    get_prices=sort_order_radio_group.value,
                                                    file_name=new_player_db_name, settings=settings,
                                                    win_previous=win_enter_text, win_next='FilesMenu')
                    win_enter_text.hide()

            else:
                message.text = "File name must be at least 1 character."
Exemplo n.º 10
0
def main():
    global VERSION
    global write, log
    BatchMode = False
    ##Parse command-line args
    for i in range(len(sys.argv)):
        if sys.argv[i] == '-F':
            # batch mode - get input from control file
            BatchMode = True
            try:
                controlfilename = sys.argv[i + 1]
            except:
                sys.stderr.write(
                    "Must supply control file name; falling back to interactive mode\n"
                )
                BatchMode = False

    options = {}
    if BatchMode:
        # create logger instance
        log = logger.Logger("izterrain.log")
        # set output function
        write = log.scrn
        options = grokCmdFile(controlfilename)
        if not options:
            # scream and die
            print "CANNOT PARSE COMMAND FILE %s. ABORT." % (controlfilename)
            sys.exit(0)

    else:
        ##Convenience variables
        data_filetypes = (("Reduced Data Files", "*.out"), ("All Files", "*"))
        dem_filetypes = (("DEM Files", "*.hdr"), ("All Files", "*"))
        out_filetypes = (("Inner zone TC Files", "*.iztc"), ("All Files", "*"))

        ##Fire up the GUI
        root = Tkinter.Tk()
        root.title("Inner Zone Terrain Correction")
        # create status window
        status_win = StatusWindow.StatusWindow(root, 150, 30)
        status_win.show()

        # create logger instance
        log = logger.Logger("izterrain.log", window=status_win)

        # set output function
        write = log.win

        # get default control options
        options = defaultOptions()

    # timestamp the log files
    write("# Started %s\n" % time.asctime(time.localtime(time.time())))
    write("########################################################\n")
    write("##      Inner Zone Terrain Corrections from DEMs      ##\n")
    write("%s\n" % VERSION)
    write("##                   Paul Gettings                    ##\n")
    write("########################################################\n")
    write("\n*** READ REDUCED GRAVITY DATA ***\n\n")

    if not BatchMode:
        write("#-----------------------\n")
        write(
            "# Select the reduced gravity data file.  The file should be in the format\n"
        )
        write("# output by 'reduce.py'; comments are OK.\n")
        write("#-----------------------\n")
        root.update()
    #
    # Read Raw Data
    if BatchMode:
        raw_file = options["raw_file"]
    else:
        raw_file = tkFileDialog.askopenfilename(parent=root,
                                                title="Gravity Data File",
                                                initialdir=".",
                                                filetypes=data_filetypes)

    if not raw_file:
        write("!!! must enter a processed data filename!\n")
        if not BatchMode:
            tkMessageBox.showerror("No File Name",
                                   "Must enter a data filename!")
        sys.exit()

    write(">>> Reading station data file\n")
    try:
        data = explfileop.readData(raw_file)
    except Exception, e:
        write("!!! error processing data file %s\nException: %s\n" %
              (raw_file, e))
        if not BatchMode:
            tkMessageBox.showerror("Data File Error",
                                   "Error processing data file %s!" % raw_file)
        sys.exit()
Exemplo n.º 11
0
def init_status_win():
    global status
    win = Toplevel()
    win.title("Program Status")
    status = StatusWindow(win, 80, 24)
    status.show()
Exemplo n.º 12
0
def init_status_win():
  global status
  win = Toplevel()
  win.title("Program Status")
  status = StatusWindow(win, 80, 24)
  status.show()
Exemplo n.º 13
0
class game_controller(object):
    """
    Main game loop and receives GUI callback events for keypresses etc...
    """
    def __init__(self, parent, lines, game_number=0):
        self.lines = lines
        self.auto_mode = False
        self.game_number = game_number
        if lines != None:
            self.lines = shape.list_from_str_list(lines)
            self.lines_shape_index = 0
            self.auto_mode = True
        """
        Intialise the game...
        """
        self.parent = parent
        self.score = 0
        self.level = 0
        self.delay = 1000  #ms

        #lookup table
        self.shapes = [
            square_shape, t_shape, l_shape, reverse_l_shape, z_shape, s_shape,
            i_shape
        ]

        self.thresholds = level_thresholds(500, NO_OF_LEVELS)

        self.status_bar = status_bar(parent)
        self.status_bar.pack(side=TOP, fill=X)
        #print "Status bar width",self.status_bar.cget("width")

        self.status_bar.set("Score: %-7d\t Level: %d " %
                            (self.score, self.level + 1))
        #create the status window
        self.status_window = StatusWindow(parent)
        self.status_window.pack()

        #create the game board
        self.board = Board(parent,
                           scale=SCALE,
                           max_x=MAXX,
                           max_y=MAXY,
                           offset=OFFSET)

        self.board.pack(side=BOTTOM)
        self.board.focus()

        self.parent.bind("<Left>", self.left_callback)
        self.parent.bind("<Right>", self.right_callback)
        self.parent.bind("<Up>", self.up_callback)
        self.parent.bind("<Down>", self.down_callback)
        self.parent.bind("a", self.a_callback)
        self.parent.bind("s", self.s_callback)
        self.parent.bind("p", self.p_callback)
        self.parent.bind("q", self.quit_callback)

        self.shape = self.get_next_shape()

        self.after_id = self.parent.after(self.delay, self.move_my_shape)

    def eval(self):
        touching = 0
        already_hit = []
        for block in self.shape.blocks:
            current = block.coord()
            print "current:", current

            #create tuples of coordinates of blocks to check
            right = (current[0] + 1, current[1])
            left = (current[0] - 1, current[1])
            #TK coord system is down and to right
            #that's why up and down are reversed
            down = (current[0], current[1] + 1)
            up = (current[0], current[1] - 1)

            right_hit = self.board.landed.get(right)
            left_hit = self.board.landed.get(left)
            up_hit = self.board.landed.get(up)
            down_hit = self.board.landed.get(down)

            if (right_hit and (right not in already_hit)):
                print "\tright hit", right
                already_hit.append(right)
                touching += 1
            if (left_hit and (left not in already_hit)):
                print "\tleft hit", left
                already_hit.append(left)
                touching += 1
            if (up_hit and (up not in already_hit)):
                print "\tup hit", up
                already_hit.append(up)
                touching += 1
            if (down_hit and (down not in already_hit)):
                print "\tdown hit", down
                already_hit.append(down)
                touching += 1
        print "\tTouching: ", touching
        print "-" * 20

    def handle_move(self, direction):
        #if you can't move then you've hit something
        if not self.shape.move(direction):
            self.status_window.log_text("HIT")
            # if your heading down then the shape has 'landed'
            if direction == DOWN:
                self.eval()
                tmp_score = self.score
                self.score += self.board.check_for_complete_row(
                    self.shape.blocks)
                #check for points added
                if (self.score > tmp_score):
                    self.status_window.log_text("POINTS " +
                                                str(self.score - tmp_score))

                del self.shape
                self.status_window.log_text("LANDED")
                self.shape = self.get_next_shape()

                # If the shape returned is None, then this indicates that
                # that the check before creating it failed and the
                # game is over!
                if self.shape is None:
                    self.status_window.log_text("GAME OVER! SCORE: " +
                                                str(self.score))
                    tkMessageBox.showwarning(
                        title="GAME OVER",
                        message="Score: %7d\tLevel: %d\t" %
                        (self.score, self.level),
                    )

                    Toplevel().quit()
                    self.parent.quit()

                    # self.status_window.quit()
                    # self.status_window.destroy()
                    # sys.exit(0)

                # do we go up a level?
                if (self.level < NO_OF_LEVELS
                        and self.score >= self.thresholds[self.level]):
                    self.level += 1
                    self.delay -= 100

                self.status_bar.set("Score: %-7d\t Level: %d " %
                                    (self.score, self.level + 1))

                # Signal that the shape has 'landed'
                return False
        return True

    def left_callback(self, event):
        if self.shape:
            self.status_window.log_text("LEFT")
            self.handle_move(LEFT)

    def right_callback(self, event):
        if self.shape:
            self.status_window.log_text("RIGHT")
            self.handle_move(RIGHT)

    def up_callback(self, event):
        if self.shape:
            # drop the tetrominoe to the bottom
            while self.handle_move(DOWN):
                pass

    def down_callback(self, event):
        if self.shape:
            self.status_window.log_text("DOWN")
            self.handle_move(DOWN)

    def a_callback(self, event):
        if self.shape:
            self.shape.rotate(clockwise=True)
            self.status_window.log_text("ROTATE CLOCKWISE")

    def s_callback(self, event):
        if self.shape:
            self.shape.rotate(clockwise=False)
            self.status_window.log_text("ROTATE COUNTERCLOCKWISE")

    def p_callback(self, event):
        self.parent.after_cancel(self.after_id)
        tkMessageBox.askquestion(title="Paused!",
                                 message="Continue?",
                                 type=tkMessageBox.OK)
        self.after_id = self.parent.after(self.delay, self.move_my_shape)

    def quit_callback(self, event):
        sys.exit(0)

    def move_my_shape(self):
        if self.shape:
            self.handle_move(DOWN)
            self.after_id = self.parent.after(self.delay, self.move_my_shape)

    def get_next_shape(self):
        """
        Select the next shape in the list
        """
        if self.lines and len(self.lines) > 0 and self.lines_shape_index < len(
                self.lines):
            the_shape = self.lines[self.lines_shape_index]
            self.lines_shape_index = self.lines_shape_index + 1
        else:
            """
            If we were in auto mode, that means we have now ran out of pieces
            Log the score, and move on to the next game
            """
            if self.auto_mode == True:
                print "Game #" + str(self.game_number) + " " + "Score: " + str(
                    self.score)
                return None  #This will end the game
            """
            Randomly select which tetrominoe will be used next.
            """
            self.shapes = self.status_window.get_shapes()
            the_shape = self.shapes[randint(0, len(self.shapes) - 1)]

        #check_and_create is a factory function
        s = the_shape.check_and_create(self.board)
        self.status_window.new_shape(s)
        self.status_window.log_board(self.board)
        BoardStates.generate_child_states(self.board, the_shape)
        return s
Exemplo n.º 14
0
    if not "cmd" in args.keys():
        sys.stderr.write("Please give executeable to debug.")
        sys.exit(-2)

    if "--vim-servername" in args.keys():
        vimservername = args["--vim-servername"]
    else:
        vimservername = "pygdb"

    #Create Terminal
    dbgterm = GdbTerminal.GdbTerminal(args["cmd"])

    #Create windows
    mainCtrlWnd = MainControlWindow.MainControlWindow(dbgterm)
    statusWnd = StatusWindow.StatusWindow(dbgterm, vimservername)
    dbgterm.initialize()

    #Load configuration
    conf = Configuration.Configuration()
    conf.load(".pygdb.conf")
    statusWnd.applyConfiguration(conf)

    gtk.main()

    #Store config
    conf = Configuration.Configuration()
    statusWnd.fillConfiguration(conf)
    conf.delCurrpos()
    conf.store(".pygdb.conf")