• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python turtle.onscreenclick函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: main

def main():
    display_help_window()

    scr = turtle.Screen()
    turtle.mode('standard')
    xsize, ysize = scr.screensize()
    turtle.setworldcoordinates(0, 0, xsize, ysize)

    turtle.hideturtle()
    turtle.speed('fastest')
    turtle.tracer(0, 0)
    turtle.penup()

    board = LifeBoard(xsize // CELL_SIZE, 1 + ysize // CELL_SIZE)

    # Set up mouse bindings
    def toggle(x, y):
        cell_x = x // CELL_SIZE
        cell_y = y // CELL_SIZE
        if board.is_legal(cell_x, cell_y):
            board.toggle(cell_x, cell_y)
            board.display()

    turtle.onscreenclick(turtle.listen)
    turtle.onscreenclick(toggle)

    board.makeRandom()
    board.display()

    # Set up key bindings
    def erase():
        board.erase()
        board.display()
    turtle.onkey(erase, 'e')

    def makeRandom():
        board.makeRandom()
        board.display()
    turtle.onkey(makeRandom, 'r')

    turtle.onkey(sys.exit, 'q')

    # Set up keys for performing generation steps, either one-at-a-time or not.
    continuous = False
    def step_once():
        nonlocal continuous
        continuous = False
        perform_step()

    def step_continuous():
        nonlocal continuous
        continuous = True
        perform_step()

    def perform_step():
        board.step()
        board.display()
        # In continuous mode, we set a timer to display another generation
        # after 25 millisenconds.
        if continuous:
            turtle.ontimer(perform_step, 25)

    turtle.onkey(step_once, 's')
    turtle.onkey(step_continuous, 'c')

    # Enter the Tk main loop
    turtle.listen()
    turtle.mainloop()
开发者ID:MattRijk,项目名称:algorithms,代码行数:68,代码来源:conway_game_of_life.py


示例17: reset_second_click

 def reset_second_click(self):
     turtle.onscreenclick(self.second)
开发者ID:kkhashayar,项目名称:memory-tile-game-gui-version-,代码行数:2,代码来源:mem-puzzle-class.py


示例18: reset_first_click

 def reset_first_click(self):
     turtle.onscreenclick(self.first)    
开发者ID:kkhashayar,项目名称:memory-tile-game-gui-version-,代码行数:2,代码来源:mem-puzzle-class.py


示例19: draw_kaleido

    t.begin_fill()
    t.circle(50)
    t.end_fill()
    # Left Eye
    t.setpos(x-15, y+60)
    t.fillcolor('blue')
    t.begin_fill()
    t.circle(10)
    t.end_fill()
    # Right Eye
    t.setpos(x+15, y+60)
    t.begin_fill()
    t.circle(10)
    t.end_fill()
    # Mouth
    t.setpos(x-25,y+40)
    t.pencolor('black')
    t.width(10)
    t.goto(x-10, y+20)
    t.goto(x+10, y+20)
    t.goto(x+25, y+40)
    t.width(0)
    
def draw_kaleido(x,y):
    draw_smiley(x,y)
    draw_smiley(-x,y)   
    draw_smiley(-x,-y)
    draw_smiley(x,-y)

turtle.onscreenclick(draw_kaleido)
开发者ID:osluocra,项目名称:pachito_python,代码行数:30,代码来源:Challenge1_MirroredSmileys.py


示例20: circle

    turtle.color(color)
    turtle.penup()
    turtle.goto(x,y)
    turtle.pendown()
    turtle.circle(20)
    turtle.end_fill()
    turtle.penup()
def circle(x,y):
    global color
    draw_circle(color,x,y)


turtle.getscreen().onkeypress(color_red,"r")
turtle.getscreen().onkeypress(color_black,"b")
turtle.getscreen().onkeypress(color_purple,"p")
turtle.onscreenclick(circle)
#turtle.onscreenclick(blue_circle,btn=3)

#draw_circle("blue",70,20)


def draw_square(color,x,y):
    turtle.penup()
    turtle.goto(x,y)
    turtle.begin_fill()
    turtle.color(color)
    turtle.pendown()
    turtle.goto(x+50,y)
    turtle.goto(x+50,y+50)
    turtle.goto(x,y+50)
    turtle.end_fill()
开发者ID:hen16-meet,项目名称:MEET-YL1,代码行数:31,代码来源:Hen_paint.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.ontimer函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.onkey函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap