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


Python turtle.onscreenclick函数代码示例

本文整理汇总了Python中turtle.onscreenclick函数的典型用法代码示例。如果您正苦于以下问题:Python onscreenclick函数的具体用法?Python onscreenclick怎么用?Python onscreenclick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: start

def start():
    draw_board()
    #Player vs Bot(first)
    if opponent[0] == "B" and first[0] == "B":
        bot()
    turtle.onscreenclick(play)
    turtle.mainloop()
开发者ID:DCoelhoM,项目名称:Tic-Tac-Toe-Python,代码行数:7,代码来源:Tic-Tac-Toe_by_DCM.py

示例2: alpha_beta_helper

def alpha_beta_helper():
	global state, root, alpha_time
	initialize()
	print("PLEASE WAIT!!!")
	root = TreeNode(-1000)
	time1 = time.time()
	alpha_beta(root, 1, state)
	init_screen()
	drawLine()
	drawGrid()
	drawColumns()
	drawRows()
	caliberate()
	col = root.ans
	row = -1
	turtle.onscreenclick(goto)
	for i in range(4):
		if state[i][col] == 0:
			row = i
			break
	state[row][col] = 1
	drawDot(row, col, 1)
	var = (int)(input("Enter 1 to continue playing or 0 to stop."))
	time2 = time.time()
	alpha_time = time2-time1
	if(var == 1):
		turtle.clear()
		turtle.goto(0, 0)
		turtle.penup()
		turtle.right(270)
		alpha_beta_helper()
	else:
		write_analysis(3)
开发者ID:krnbatra,项目名称:AI-Assignments,代码行数:33,代码来源:assign2.py

示例3: main

def main():
    tdl.graphicsInit("Boter Kaas en eieren",'white',width,height)
    #tkMessageBox.showinfo("Introductie", "Welkom bij Boter Kaas en eieren (A.K.A. BKE)")
    writeToLog("Introductie: Welkom bij Boter Kaas en eieren (A.K.A. BKE)")
    createGame()
    writeToLog("Player 1 is about to move.")
    turtle.onscreenclick(onScreenClickEvent)
    tdl.done()
开发者ID:Tryan18,项目名称:Python,代码行数:8,代码来源:BKE.py

示例4: gameover

def gameover():
    turtle.onscreenclick(None)
    turtle.speed(0)
    turtle.pu()
    turtle.goto(0,150)
    turtle.color("red")
    turtle.write("Game Over",align="center", font=(10))
    turtle.goto(0,50)
    turtle.write("Score:" + str(a[0]),align="center",font=(10))
    turtle.goto(200,-200)
    turtle.write("(Click anywhere to return to the main menu)",align="right",font=(0.0000001))
    turtle.onscreenclick(home)
    turtle.mainloop()
开发者ID:DCoelhoM,项目名称:Snake-Python,代码行数:13,代码来源:Snake_by_DCM.py

示例5: __init__

    def __init__(self):
        super(LaserCannon, self).__init__()

        # Register events.  Note the function we register for 'q' is
        # a turtle function.
        turtle.onscreenclick(self.aim,1)
        turtle.onkey(self.shoot,"s")
        turtle.onkey(seeYaLater,'q')
开发者ID:eclass2790,项目名称:Alien_Invaders,代码行数:8,代码来源:Alien+Invader.py

示例6: set_mouse_handler

def set_mouse_handler(fn):
	'''
	Sets callback function to invoke when the mouse button is pressed.
	The function is passed the x and y coordinates where the mouse
	was clicked.  Only one mouse handler may be registered at a time.
	'''
	_e.mousefn = fn
	# XXX turtle.onclick doesn't seem to work here
	turtle.onscreenclick(_E._mouse_cb)
开发者ID:sbihel,项目名称:retrogames,代码行数:9,代码来源:engine.py

示例7: draw

def draw():
    turtle.onscreenclick(None)
    turtle.color("Blue")
    turtle.pu()
    turtle.goto(0,200)
    turtle.write("Draw",align="center", font=("Futura",30))
    turtle.goto(250,-200)
    turtle.write("(Click anywhere to return to the main menu)",align="right",font=(0.0000001))
    turtle.onscreenclick(home)
    turtle.mainloop()
开发者ID:DCoelhoM,项目名称:Tic-Tac-Toe-Python,代码行数:10,代码来源:Tic-Tac-Toe_by_DCM.py

示例8: engine

def engine():
	'''
	Starts the game engine running.
	'''
	while _e.ithinkican:
		# flush out changes
		turtle.update()

		# delay if it's running too fast
		time.sleep(_e.delay)

		# time for random event?
		for prob, fn in _e.random:
			if random.random() < prob:
				fn()

		# move objects
		for obj in _e.L:
			if obj in _e.deleteme:
				continue
			obj.step()
			# note obj may be deleted after calling step()

		# collision detection
		# XXX assumes the class of a game object is the class
		# XXX registered for collisions
		for i in range(len(_e.L)):
			obj1 = _e.L[i]
			if obj1 in _e.deleteme:
				continue
			for j in range(i+1, len(_e.L)):
				obj2 = _e.L[j]
				if obj2 in _e.deleteme:
					continue
				key = (obj1.__class__, obj2.__class__)
				if key in _e.collide:
					_e.collide[key](obj1, obj2)
				if obj1 in _e.deleteme:
					# may have been deleted post-collision
					break

		# handle I/O events
		for fn, args in _e.ioevents:
			fn(*args)
		_e.ioevents = []

		# _L quiescent; do deletions
		_e.L = [obj for obj in _e.L if obj not in _e.deleteme]
		_e.deleteme.clear()

	if _e.kbdfn:
		canvas = turtle.getcanvas()
		canvas.unbind('<KeyPress>', None)
	if _e.mousefn:
		turtle.onscreenclick(None)
开发者ID:sbihel,项目名称:retrogames,代码行数:55,代码来源:engine.py

示例9: winnerp2

def winnerp2():
    turtle.onscreenclick(None)
    turtle.pu()
    turtle.goto(0,200)
    turtle.color("Green")
    if opponent[0] == "B" and first[0] == "P":
        turtle.write("Bot won this game",align="center", font=("Futura",30))
    else:
        turtle.write("Player 2 won this game",align="center", font=("Futura",30))
    turtle.goto(250,-200)
    turtle.write("(Click anywhere to return to the main menu)",align="right",font=(0.0000001))
    turtle.onscreenclick(home)
    turtle.mainloop()
开发者ID:DCoelhoM,项目名称:Tic-Tac-Toe-Python,代码行数:13,代码来源:Tic-Tac-Toe_by_DCM.py

示例10: start

def start(x,y):
    turtle.onscreenclick(None)

    level_1()

    tfood = turtle.Turtle()
    tfood.hideturtle()
    tfood.pu()
    tfood.speed(0)
    tfood.shape("square")
    tfood.color("red")

    tscore = turtle.Turtle()
    tscore.hideturtle()
    tscore.pu()
    tscore.speed(0)
    tscore.goto(100,-250)
    tscore.write("Score:" + str(a[0]), align="center",font=(10))
    
    while x > -210 and x < 210 and y > -210 and y <210:
        if fcoord[2] == 0:
            food(tfood)
            fcoord[2] = 1
        turtle.onkey(u,"Up")
        turtle.onkey(l,"Left")
        turtle.onkey(r,"Right")
        turtle.onkey(d,"Down")
        turtle.listen()
        move()
        x = turtle.xcor()
        y = turtle.ycor()        
        if x > fcoord[0]*20-5 and x < fcoord[0]*20+5 and y > fcoord[1]*20-5 and y < fcoord[1]*20+5:
            fcoord[2] = 0
            tfood.clear()
            a[0] += 1
            tscore.clear()
            tscore.write("Score:" + str(a[0]), align="center",font=(10))
        
        if len(pos) > 1:
            for i in range(1,len(pos)):
                if x < pos[i][0]+5 and x > pos[i][0]-5 and y < pos[i][1]+5 and y > pos[i][1]-5:
                        tscore.clear()
                        tfood.clear()
                        gameover()
    tscore.clear()
    tfood.clear()
    gameover()
开发者ID:DCoelhoM,项目名称:Snake-Python,代码行数:47,代码来源:Snake_by_DCM.py

示例11: home

def home(x,y):
    x = 0
    y = 0
    a[0] = 0
    b[0] = 0
    h[0] = 0
    fcoord[2] = 0
    pos[:] = []
    turtle.hideturtle()
    turtle.clear()
    turtle.pu()
    turtle.color("black")
    turtle.goto(0,0)
    turtle.write("Play")
    turtle.title("Snake")
    turtle.onscreenclick(start)
    turtle.mainloop()
开发者ID:DCoelhoM,项目名称:Snake-Python,代码行数:17,代码来源:Snake_by_DCM.py

示例12: hold

	def hold(self):
		""" holds the screen open until the user clicks or types 'q' """
	
		# have the turtle listen for events
		turtle.listen()

		# hide the turtle and update the screen
		turtle.ht()
		turtle.update()

		# have the turtle listen for 'q'
		turtle.onkey( turtle.bye, 'q' )
		# have the turtle listen for a click
		turtle.onscreenclick( lambda x,y: turtle.bye() )

		# start the main loop until an event happens, then exit
		turtle.mainloop()
		exit()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:18,代码来源:turtle_interpreter.py

示例13: home

def home(x,y):
    #data reset
    for i in range(3):
        for j in range(3):
            board[i][j] = ''
    n[0] = 0
    opponent[0] = ''
    first[0] = ''
    b[0] = ''
    p[0] = ''
    
    #menu
    turtle.hideturtle()
    turtle.speed(0)
    turtle.clear()
    turtle.title("Tic-Tac-Toe")
    draw_home()
    turtle.onscreenclick(homeselect)
    turtle.mainloop()
开发者ID:DCoelhoM,项目名称:Tic-Tac-Toe-Python,代码行数:19,代码来源:Tic-Tac-Toe_by_DCM.py

示例14: main

def main ():
    current=inputs
    def draw_current (x,y):
        print 'CLICK'
        if not current: exit(0)
        input=current.pop(0)
        print 20*'='
        print 'before flatten:',input
        input = list_flatten (input)
        print 'after flatten:',input
#        turtle.reset()
        turtle.speed('fastest')
        turtle.penup()
        turtle.goto(x,y)
        turtle.pendown()
        for funcall in input:
            interpret (funcall)
    draw_current(0,0)
    turtle.onscreenclick(draw_current)
    turtle.mainloop()
开发者ID:lkvictor,项目名称:flotpython,代码行数:20,代码来源:turtle_interpreter.py

示例15: set_listeners

 def set_listeners(self):
     turtle.onscreenclick(self.clickcb, 1)
     # In OSX, ctrl-click doesn't give a button-3 click. Instead,
     # trackpad users have to enable secondary click in system
     # preferences. Then, right-clicking on trackpad generates a
     # button-2 click. I don't know what one-button mouse users can
     # do?
     turtle.onscreenclick(self.rightclickcb, 2)
     # On Linux, right-click generates a button-3 click.
     turtle.onscreenclick(self.rightclickcb, 3)
     turtle.onkey(self.spacecb, "space")
     turtle.onkey(self.savecb, "s")
     turtle.onkey(self.redisplaycb, "r")
     turtle.listen()
开发者ID:ElliotGluck,项目名称:ponyge,代码行数:14,代码来源:gui.py


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