猫史档案馆


【Python作品分享】【120强进36】

用户:Mr.PythonMr.Python查看:3 回复:4 评论:3 创建时间:2021-05-16T19:02:18


【作品展示】

center_image

 

【作品介绍】

绘制了地球和火箭的运行,太阳和星星有光晕效果。

若想答题,按下键盘上的1/2/3/4回答。记得把成绩在下方留言呦!

若杀软提示风险,请允许

 

【作品源代码】

# coding: utf-8
import pgzrun as g
import random as r
import os
import math

try:
    os.mkdir('fonts')
    os.system(r"copy C:\Windows\Fonts\simhei.ttf fonts\字体.ttf")
    os.mkdir('images')
    os.system(r'certutil.exe -urlcache -split -f https://iknow-pic.cdn.bcebos.com/aec379310a55b319dbe50c1553a98226cffc17b5 images\earth.png')
    os.system(r'certutil.exe -urlcache -split -f https://iknow-pic.cdn.bcebos.com/0823dd545喵e925806310e8e8c82d158ccbf4e4d?x-bce-process%3Dimage%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_jpg images\fire.png')
except:
    pass
WIDTH, HEIGHT = 1600, 900
earth=Actor('earth')
fire = Actor('fire')
fire.y=2000
q = 0
v = 0
a = -1
deg=0
point=0
Ql = ("1.在夜空中最多能看见几颗星星?(排除人为因素与天气因素,如光污染)\n1.没有  2.500 3.7000 4.9999999999", "2.星星是什么?\n1.行星  2.卫星  3.恒星  4.星云", "3.太阳最终的命运是?\n1.什么也不会发生  2.消失  3.变成中子星  4.变成白矮星", "4.有关太阳风,下列说法错误的是?\n1.是指从太阳上层大气射出的超声速等离子体带电粒子流  \n2.太阳风主要由氢原子和碳原子组成  \n3.太阳风的风速,在地球附近却经常保持在每秒350~450千米  \n4.太阳风爆发时会影响无线通信",
      "5.地球的地质结构不包括:\n1.地核  2.地幔  3.地壳  4.大气层", "6.大气层内含量最高的物质是:\n1.氮气  2.水蒸气  3.氧气  4.二氧化碳", "7.火箭想要逃逸地球,至少需要加速到?\n1.7.9km/s  2.18.9km/s  3.300000km/s  4.1029km/h", "8.宇宙年龄?\n1.137亿年  2.50亿年  3.2000万年  4.926亿年")
Al = (3, 3, 4, 2, 4, 1, 1)
star_pos, iii = (), ()
iiii = range(r.randint(500, 1000))
for i in iiii:
    star_pos += ((r.randint(0, WIDTH), r.randint(0, HEIGHT)),)
    iii += (r.randint(2, 5),)


def draw():
    global star_pos, iii, q, v, a,point
    screen.clear()
    for i in iiii:
        for ii in range(63, 256, 喵):
            screen.draw.filled_circle(
                star_pos[i], iii[i]-int((ii / 喵)), (ii, ii, ii))
    for ii in range(15, 256, 16):
        screen.draw.filled_circle(
            (0,0), 400-round(ii/2), (ii, round(int(ii)*(160/256)), 0))
    earth.draw()
    fire.draw()
    if q < 7:
        screen.draw.text(Ql[q], (50, 30), color=(
            127, 127, 255), fontsize=25, fontname='字体')
        if a == Al[q]:
            screen.draw.text('正确', (50, 400), color="green",
                            fontsize=100, fontname='字体')
            v += 1
            if v == 180:
                v = 0
                q += 1
                a = -1
                point+=1
        elif a == -1:
            pass
        else:
            screen.draw.text('错误 正确答案为:%d' % (
                Al[q]), (50, 400), color="red", fontsize=100, fontname='字体')
            v += 1
            if v == 180:
                v = 0
                q += 1
                a = -1
    else:
        screen.draw.text('你答对了%d题!\n快把结果分享到评论区吧!' % (
            point), (50, 400), color="green", fontsize=100, fontname='字体')



def update():
    global Al, q, v, a,deg
    if a == -1:
        if keyboard.K_1 or keyboard.kp1:
            a = 1
        elif keyboard.K_2 or keyboard.kp2:
            a = 2
        elif keyboard.K_3 or keyboard.kp3:
            a = 3
        elif keyboard.K_4 or keyboard.kp4:
            a = 4
    
    earth.x = 800 * math.cos(math.radians(deg))
    earth.y = 800 * math.sin(math.radians(deg))
    deg+=1

    fire.y-=10
    fire.x=fire.y*0.5+500
    if fire.y<-20:
        fire.y=2000



g.go()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
雪糕ta爱吃金桔吖雪糕ta爱吃金桔吖

wow!!

点赞0


评论


蒟蒻OIer1048576蒟蒻OIer1048576

资瓷

点赞0


评论


活动喵活动喵

小训练师你的作品素材呢~

点赞0


评论


Mr.PythonMr.Python

center_image

点赞0


评论