示例#1
0
    def place_piece_event(self, event):

        pos_x, pos_y = event.pos
        
        x, y = self.screen_to_coord(pos_x, pos_y)
        colour = self.board.player
                    
        new_event = pygame.event.wait()

        if new_event.type == pygame.KEYDOWN:
            key   = new_event.key
            piece = None

            if key == ord("a"):
                piece = Pieces.Ant(colour)

            elif key == ord("q"):
                piece = Pieces.Queen(colour)

            elif key == ord("b"):
                piece = Pieces.Beetle(colour)

            elif key == ord("g"):
                piece = Pieces.Grasshopper(colour)

            elif key == ord("s"):
                piece = Pieces.Spider(colour)
                        
            if piece:
                Moves.place_piece(self.board, x, y, piece)
                self.render_step()
示例#2
0
import Board
import BoardUI
import Pieces
import Moves

b = Board.Board()
ui = BoardUI.BoardUI(b)

b.board[10][10].append(Pieces.Spider())
b.board[11][10].append(Pieces.Ant(1))
b.board[12][10].append(Pieces.Queen(1))
b.board[10][11].append(Pieces.Beetle(1))
b.board[11][11].append(Pieces.Spider(1))
b.board[12][11].append(Pieces.Beetle(0))
b.board[10][12].append(Pieces.Grasshopper(0))
b.board[11][12].append(Pieces.Grasshopper(1))
b.board[11][13].append(Pieces.Queen(0))

b.white_queen = True
b.black_queen = True
b.movecount = 6

ui.render()
ui.manage_all_events()