• 个人简介

    该用户很懒,这里啥都写了 (´・ω・`)…………(本用户已移入c++) image 本人状态:摆烂ing 撕作业ing 摸鱼ing (◐‿◑) ……

    from tkinter import*
    root=Tk()
    c=Canvas(root,width=400,height=400)
    c.configure(bg='dark blue',highlightthickness=0)
    c.body_colour='SkyBlue1'
    body=c.create_oval(35,20,365,350,outline=c.body_colour,fill=c.body_colour)
    ear_left=c.create_polygon(75,80,75,10,165,70,outline=c.body_colour,fill=c.body_colour)
    ear_right=c.create_polygon(255,45,325,10,320,70,outline=c.body_colour,\
                              fill=c.body_colour)
    foot_left=c.create_oval(65,320,145,360,outline=c.body_colour,fill=c.body_colour)
    foot_right=c.create_oval(250,320,330,360,outline=c.body_colour,fill=c.body_colour)
    
    eye_left=c.create_oval(130,110,160,170,outline='black',fill='white')
    pupil_left=c.create_oval(140,145,150,155,outline='black',fill='black')
    eye_right=c.create_oval(230,110,260,170,outline='black',fill='white')
    pupil_rignt=c.create_oval(240,145,250,155,outline='black',fill='black')
    
    mouth_normal=c.create_line(170,250,200,272,230,250,smooth=1,width=2,state=NORMAL)
    def toggle_eyes():
        current_color=c.itemcget(eye_left,'fill')
        new_color=c.body_colour if current_color=='white'else 'white'
        current_state=c.itemcget(pupil_left,'state')
        new_state=NORMAL if current_state==HIDDEN else HIDDEN
        c.itemconfigure(pupil_left,state=new_state)
        c.itemconfigure(pupil_rignt,state=new_state)
        c.itemconfigure(eye_left,fill=new_color)
        c.itemconfigure(eye_right,fill=new_color)
    def blnk():
        toggle_eyes()
        root.after(250,toggle_eyes())
        root.after(3000,blnk())
    
    root.after(1000,blnk())
    root.mainloop()
    c.pack()
    
    from itertools import cycle
    from random import randrange
    from tkinter import Canvas, Tk, messagebox, font
    canvas_width = 800
    canvas_height = 400
    root = Tk()
    c = Canvas(root, width=canvas_width, height=canvas_height, background='deep sky blue')
    c.create_rectangle(-5, canvas_height - 100, canvas_width + 5, canvas_height + 5, \
                       fill='sea green', width=0)
    c.create_oval(-80, -80, 120, 120, fill='orange', width=0)
    c.pack()
    color_cycle = cycle(['light blue', 'light green', 'light pink', 'light yellow', 'light cyan'])
    egg_width = 45
    egg_height = 55
    egg_score = 10
    egg_speed = 500
    egg_interval = 4000
    difficulty_factor = 0.95
    catcher_color = 'blue'
    catcher_width = 100
    catcher_height = 100
    catcher_start_x = canvas_width / 2 - catcher_width / 2
    catcher_start_y = catcher_height - catcher_height +250
    catcher_start_x2 = catcher_start_x + catcher_width
    catcher_start_y2 = catcher_start_y + catcher_height
    catcher = c.create_arc(catcher_start_x, catcher_start_y,\
                           catcher_start_x2, catcher_start_y2, start=200, extent=140,\
                           style='arc', outline=catcher_color, width=3)
    game_font = font.nametofont('TkFixedFont')
    game_font.config(size=18)
    score = 0
    score_test = c.create_text(10,10,anchor='nw',font=game_font,fill='darkblue',text='Score'+str(score))
    lives_eremaining=3
    lives_test=c.create_text(canvas_width-10,10,anchor='ne',font=game_font,fill='darkblue',\
                             text='Lives:'+str(lives_eremaining))
    eggs=[]
    def create_egg():
        x=randrange(10,740)
        y=40
        new_egg=c.create_oval(x,y,x+egg_width,y+egg_height,fill=next(color_cycle),width=0)
        eggs.append(new_egg)
        root.after(egg_interval,create_egg)
    def move_eggs():
        for egg in eggs:
            (egg_x,egg_y,egg_x2,egg_y2)=c.coods(egg)
            c.move(egg,0,10)
            if egg_y2>canvas_height:
                pass
        root.after(egg_speed,move_eggs)
    '''def egg_droppend(egg):
        eggs.remove(egg)
        c.delete(egg)
        lost_a_life()
        if lives_eremaining==0:
            messagebox.showinfo('Game Over','Final Score:'+str(score))
            root.destroy()'''
    def lost_a_life():
        global lives_eremaining
        lives_eremaining-=1
        c.itemconfigure(lives_test,text='Lives:'+str(lives_eremaining))
    def check_catch():
        (catcher_x,catcher_y,catcher_x2,catcher_y2)=c.coords(catcher)
        for egg in eggs:
            (egg_x, egg_y, egg_x2, egg_y2) = c.coords(egg)
            if catcher_x<egg_x and egg_x2 <catcher_x2 and catcher_y2<egg_y2<40 :
                eggs.remove(egg)
                c.delete(egg)
                increase_score(egg_score)
            root.after(100,check_catch())
    def increase_score(points):
        global score,egg_speed,egg_interval
        score+=points
        egg_speed=int(egg_speed*difficulty_factor)
        egg_interval=int(egg_interval*difficulty_factor)
        c.itemconfigure(score_test,test='Score:'+str(score))
    def move_left(event):
        (x1,y1,x2,y2)=c.coords(catcher)
        if x1>0:
            c.move(catcher,-20,0)
    def move_right(event):
        (x1, y1, x2, y2) = c.coords(catcher)
        if x2 < canvas_width:
            c.move(catcher, 20, 0)
    c.bind('<Left>',move_left)
    c.bind('<Right>',move_right)
    c.focus_set()
    root.after(1000,create_egg)
    root.after(1000,move_eggs)
    #root.after(1000,check_catch)
    root.mainloop()
    
    

    AC: awful correct 粗劣的答案

    WA:wonderful answer 完美的答案

    RE: right ending 运行成功

    CE:compiled easily 轻松通过编译

    TLE:time limit enough 时间充裕

    MLE:memory limit enough 空间充裕

    OLE:output length excellent 输出长度完美

    AK:all knocked-off 全部失败

    点击

    还有这个

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

    This person is lazy and didn't write any solutions.
  • Stat

  • Rating