当前位置: 首页>>代码示例>>Python>>正文


Python Board.draw方法代码示例

本文整理汇总了Python中board.Board.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Board.draw方法的具体用法?Python Board.draw怎么用?Python Board.draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在board.Board的用法示例。


在下文中一共展示了Board.draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
class GameControl:
    def __init__(self, num_of_players):
        self._num_of_players = num_of_players
        self._gameExit = False

        self._SCREEN_W = 800
        self._SCREEN_H = 600

        self._board = Board(10, 10, self._SCREEN_W, self._SCREEN_H)

        pygame.init()

        self._display = pygame.display.set_mode((self._SCREEN_W, self._SCREEN_H))
        pygame.display.set_caption("Robot Derby")

        self._clock = pygame.time.Clock()

    def run(self):
        while not (self._gameExit):
            self._board.draw(self._display)

            pygame.display.update()

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self._gameExit = True
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_q:
                        self._gameExit = True

            self._clock.tick(30)

        pygame.quit()
开发者ID:pballok,项目名称:RobotDerby,代码行数:35,代码来源:gamecontrol.py

示例2: main

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
def main(stdscr):
    stdscr.timeout(FRAME_RATE)
    curses.curs_set(0) # hide the cursor
    curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)

    board = Board(stdscr)
    board.draw()

    a_time = millis()

    while True:
        c = stdscr.getch()

        if c == ord('q'):
            break;
        elif c == curses.KEY_LEFT:
            board.move(-PADDLE_SPEED)
        elif c == curses.KEY_RIGHT:
            board.move(PADDLE_SPEED)

        b_time = millis()
        if b_time - a_time >= FRAME_RATE:
            board.animate()

        stdscr.clear()
        board.draw()
开发者ID:brendan-w,项目名称:rm-out,代码行数:29,代码来源:__main__.py

示例3: main

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
def main():
    global root, canvas, canvas_height, canvas_width, board, snake, scale
    root = Tk()
    root.title("Snake")
    canvas = Canvas(root, width=canvas_width, height=canvas_height)
    scale = Scale(root, from_=0, to=500, orient=HORIZONTAL, length=canvas_width, tickinterval=25,
                  label="Turns Per Second")
    scale.set(tics_per_second)
    scale.bind("<ButtonRelease-1>", on_slider_update)
    canvas.pack()
    scale.pack(side=LEFT)
    b = Button(root, text="Next Step", command=callback)
    b.pack()
    snake = Snake(board_width, board_height, starvation_tics)
    board = Board(board_width, board_height, canvas_width, canvas_height, snake, food_blocks_max, wall_blocks_max,
                  test_config)
    board.draw(canvas)
    canvas.after(int(1000 / tics_per_second), game_loop)
    mainloop()
开发者ID:dragomir44,项目名称:Reinforced_learning_snake,代码行数:21,代码来源:main.py

示例4: __init__

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
class Tetris:

	def __init__(self):
		self.figures = ['line','l','j','s','o']
		self.active_figure = None
		self.draw_new_figure = True


	def initialize_game(self):
		curses.initscr()
		curses.curs_set(0)
		curses.cbreak()
		self.board = Board()

	def main(self,stdscr):
		# c = 0
		# board_steps = 0
		# total_steps = 11
		# pad = curses.newpad(100, 100)
		# #  These loops fill the pad with letters; this is
		# # explained in the next section
		# try:
		# 	pad.addstr(2,10,'Enter Input')
		# except curses.error:
		# 	pass
		# #  Displays a section of the pad in the middle of the screen
		# pad.refresh(0,0, 20,5, 40,75)

		while 1:
			self.window= self.board.draw()
			key = self.window.getch()

			if key == -1:
				status = None
				pass
			if key == 27:
				status = None
				break
			elif key in [65,97,68,100,32]:
				status = self.board.move_figure(self.active_figure,key)
			if status == False:
				self.draw_new_figure = True
			figure = random.choice(self.figures)
			if self.draw_new_figure:
				terminate = self.board.draw_figure(figure)
				open('errors','a').write('terminating'+str(terminate)+'\n')
				self.draw_new_figure = False
				self.active_figure = figure
				if terminate:
					open('errors','a').write('terminating\n')
					break
		curses.endwin()

	def start(self):
		curses.wrapper(self.main)
开发者ID:sumitjain34,项目名称:python-tetris,代码行数:57,代码来源:tetris.py

示例5: __init__

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
class Player:

    def __init__(self, size=4):
        self._size = size
        self._board = Board(size)

    def reset(self):
        self._board.reset()

    def on_key_press(self, symbol, modifiers):
        mapper = {
            key.LEFT: (-1, 0),
            key.RIGHT: (1, 0),
            key.UP: (0, 1),
            key.DOWN: (0, -1)
        }
        if symbol in mapper.keys():
            delta = mapper[symbol]
            self._board.push_delta(delta)

    def draw(self):
        self._board.draw()
开发者ID:chongkong,项目名称:2048,代码行数:24,代码来源:player.py

示例6: Game

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
class Game():
    def __init__(self):
        self.ai = Ai()
        self.board = Board(9)
        self.player = Player()
        self.on_turn = self.player
   
    def start(self):
        in_progres = True
        while in_progres:
            if self.on_turn == self.player:
                player_choice = self.player.ask_for_move(self.board)
                try:
                    self.board.make_move(player_choice, self.player.symbol)
                except ValueError:
                    return self.player.ask_for_move(self.board)
                self.on_turn = self.ai
                print(self.board.draw())
            else:
                print('Ai move:')
                ai_move = self.ai.get_ai_move(self.board)
                self.board.make_move(ai_move, self.ai.symbol)
                self.on_turn = self.player
                
                print(self.board.draw())

            if self.board.check_winning(self.player.symbol):
                print('Congrats, You win!!!')
                break
            elif self.board.check_winning(self.ai.symbol):
                print('You are LOOOOOOOOOOSER :P')
                break
            elif self.board.is_full():
                print('TIE')
                
            in_progres = not self.board.is_full()
开发者ID:Shosh,项目名称:hb_tic_tac_toe,代码行数:38,代码来源:game.py

示例7: set

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
b.valid_paths = None

while running:
	event = sf.Event()
	while window.GetEvent(event):
		if event.Type == sf.Event.Closed:
			running = False
		if event.Type == sf.Event.MouseButtonPressed:
			for token in tokens:				
				if token.mouse_over(InputHandler, window):
					token.dragged = True
					if token.i >= 0 and token.j >= 0:
						b.grid[token.i][token.j] = None

					if token.type == 'rect':
						b.invalid = b.find_critical_nodes(b.valid_paths)
						print b.invalid
		if event.Type == sf.Event.MouseButtonReleased:
			for token in tokens:
				if token.dragged:
					token.dragged = False
					b.snap(window, token)
					b.invalid = set()
					b.valid_paths =  b.get_valid_paths()
	window.Clear()
	b.draw(window)
	for t in tokens:
		t.update(InputHandler, window)
		t.draw(window)
	window.Display()
开发者ID:v,项目名称:blockade,代码行数:32,代码来源:game.py

示例8: Board

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
import re
from board import Board


board = Board()
board.populate_vehicles()

while True:
    board.draw()
    cmd = raw_input("Give a shoot: ").lower()
    coordinate_match = re.match(r"([A-La-l])(\d+)", cmd.upper())
    if cmd == "reveal":
        board.draw(reveal=True)
    elif coordinate_match is not None:
        column = coordinate_match.groups()[0]
        row = coordinate_match.groups()[1]
        if column not in Board.columns or row not in Board.rows:
            print("Error: bad coordinate")
            continue
        board.shoot(cmd.upper())
开发者ID:Beatris,项目名称:Artillery,代码行数:22,代码来源:artillery.py

示例9: Board

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
from pygame.locals import *

from board import Board

if __name__ == '__main__':
	screen_width = 640
	screen_height = 480

	pygame.init()
	display = pygame.display.set_mode((screen_width, screen_height))
	pygame.display.set_caption('Squarez')
	fpsClock = pygame.time.Clock()

	board = Board(screen_width, screen_height)

	while True:
		for event in pygame.event.get():
			if event.type == QUIT:
				pygame.quit()
				sys.exit()
			if board.isGameOver() and event.type == KEYUP and event.key == K_SPACE:
				board = Board(screen_width, screen_height)

		board.move(fpsClock.get_time() / 1000)
		display.fill((0, 0, 0))
		board.draw(display)

		pygame.display.update()
		fpsClock.tick(60)

开发者ID:gholami7,项目名称:squarez,代码行数:31,代码来源:game.py

示例10: draw

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
 def draw(self):
     t = CairoTurtle(self.canv, self._frame)
     board = Board(t)
     board.scale = 1.15
     board.draw()
开发者ID:donkirkby,项目名称:blind-hex,代码行数:7,代码来源:blind_hex.py

示例11: int

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
                        try:
                            move_coords = typing_text.split(" ")
                            coord1 = int(move_coords[0])# move([0],[1])
                            coord2 = int(move_coords[1])
                            board.humanMove((coord1, coord2))
                        except Exception as exp:
                            display("Invalid command - %s" %str(exp))
                            print (exp)
                        typing_text = ""
                        #innerLogic.humanMove(move_coords)
                if pygame.key.get_pressed()[pygame.K_BACKSPACE]:
                    typing_text = typing_text[:-1]
                    typing_text = typing_text[:-1]


    board.draw(inmenu)
    if inmenu:
        screen.blit(menu, menurect)
    else:
        screen.blit(console, (bwidth, 0))
        if is_cpu_turn:
            screen.blit(cpu_play, (bwidth, 0))
        else :
            board.draw(inmenu)
            # --- CONSOLE TEXT ---
            fnt = pygame.font.SysFont("Calibri", font_size)
            hintfnt = pygame.font.SysFont("monotype", font_size)
            if show_numbers:
                count = 1
                j = 0
                offset = 5
开发者ID:cavemanpi,项目名称:Checkers,代码行数:33,代码来源:gui.py

示例12: print

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
            #dic = pickle.loads(net_board_data)
            #print('Got one dic-->\n', dic)
            #print('-------------')
            net_board_data = b''
            
            tetris.board = dic['board']
            #tetris.block = dic['block']
            tetris.score = dic['score']
            
            tetris.block.ref_pos = dic['ref_pos']
            tetris.block.turn_type = dic['turn_type']
            tetris.block.turn_delta = dic['turn_delta']
            tetris.block.color_num = dic['color_num']
            tetris.block.block_type = dic['block_type']
            
            #print('dic : ref_pos -> ' ,dic['ref_pos'])
            #print('dic : turn_type -> ', dic['turn_type'])
            tetris.draw()
    
            # tetris.draw()
    elif remain_size < 0:
        print('error: remain_size should not negetive')
         

    #print('chuck size: ' , len(chuck),'len(remain_data): ', len(remain_data), ' remain size:' , remain_size )    
    #print('Press Any Key.....')
    #getwch()
    sleep(0.1)
    

开发者ID:beardad1975,项目名称:tetrisAndCS,代码行数:30,代码来源:net_tetris_one_way_server.py

示例13: make_scale

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
#! /usr/bin/python
import argparse

from scales import make_scale
from board import Board

parser = argparse.ArgumentParser()
parser.add_argument('-t', '--tunning', type=str, 
                    help='Guitar tunning', default='EADGBE')
parser.add_argument('-k', '--key', type=str, 
                    help='Key note of the scale', required=True)
parser.add_argument('-s', '--scale', type=str, 
                    help='Scale to draw', required=True)
args = parser.parse_args()

note = args.key.lower()
scale = args.scale.lower()

scale_notes = make_scale(note, scale)
board = Board(args.tunning)
print board.draw(scale_notes)
开发者ID:pablodo,项目名称:pyguitar,代码行数:23,代码来源:tab_generator.py

示例14: GraphWin

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
from board import Board
from graphics import *

win = GraphWin("Chess visualizer 5000", Board.size, Board.size)
b = Board()
b.draw(win)

win.mainloop()
开发者ID:simmlemming,项目名称:chessvis,代码行数:10,代码来源:chessvis.py

示例15: Shape

# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import draw [as 别名]
s1 = Shape(spawnShape())
'''
print 'before rotate:'
s1.draw(None)

s1.rotate()
print 'after 1st rotate:'
s1.draw(None)

s1.rotate()
print 'after 2nd rotate:'
s1.draw(None)

s1.rotate()
print 'after 3th rotate:'
s1.draw(None)

s1.rotate()
print 'after 4th rotate:'
s1.draw(None)
'''
s2 = Shape(spawnShape())
b = Board(s1,s2)
b.draw()
movedown(b)
#b.rotate()

print '------------------------------------------'
b.draw()
开发者ID:guitay,项目名称:tetris,代码行数:31,代码来源:tetris.py


注:本文中的board.Board.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。