本文整理汇总了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()
示例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()
示例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()
示例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)
示例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()
示例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()
示例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()
示例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())
示例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)
示例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()
示例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
示例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)
示例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)
示例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()
示例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()