用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
zwz521007的公告
喜欢自由的工作气氛,羡慕GOOGLE那种编程的环境。用自己去感染身边的每一个人,程序员的生活应该是自由,愉快的。
文章分类
    存档

    原创  2年前写的PYTHON程序,怀念下PYTHON 收藏

      本程序生成一个3D篮球场,源代码如下。 '''This is a program which generate a basketball field''' from visual import * scene = display(title='Welcome to NBA', width=1280, height=800,center=(0,3,0), background=(0.1,0,0)) bannar = label(pos=(4,4,5), text='http://blog.sina.com.cn/u/1240983007\nWelcome to my BLOG!', height=20, border=5,color=color.white) playground=box(pos=(0,0,0), length=18.7, height=0.15, width=10,color=color.red,axis=(1,0,0)) #side floor front_side=box(pos=(0,0,5), length=20.7, height=0.15, width=1,color=color.green,axis=(1,0,0)) back_side=box(pos=(0,0,-5), length=20.7, height=0.15, width=1,color=color.green,axis=(1,0,0)) left_side=box(pos=(-9.35,0,0), length=2, height=0.15, width=10,color=color.green,axis=(1,0,0)) right_side=box(pos=(9.35,0,0), length=2, height=0.15, width=10,color=color.green,axis=(1,0,0)) #center cycle center_cycle=ring(pos=(0,0,0), axis=(0,1,0), radius=1, thickness=0.15,color=color.white) center_cycle=cylinder(pos=(0,0,0), axis=(0,0.1,0), radius=1,color=color.yellow) #center line center_line=curve(pos=[(0,0,-4.5), (0,0,0), (0,0,4.5)], radius=0.118,color=color.white) #left cycle left_cycle=cylinder(pos=(-5,0,0), axis=(0,0.1,0), radius=1, color=color.yellow) #right cycle right_cycle=cylinder(pos=(5,0,0), axis=(0,0.1,0), radius=1, color=color.yellow) #three point line left_three_point_line=ring(pos=(7.4,0,0), axis=(0,1,0), radius=3.5, thickness=0.1,color=color.white) right_three_point_line=ring(pos=(-7.4,0,0), axis=(0,1,0), radius=3.5, thickness=0.1,color=color.white) #left penalty shot line left_penalty_shot_line=curve(pos=[(-10,0,-2.4), (-5,0,-1), (-5,0,1),(-10,0,2.4)], radius=0.13) #right penalty shot line right_penalty_shot_line=curve(pos=[(10,0,-2.4), (5,0,-1), (5,0,1),(10,0,2.4)], radius=0.13) #left backboard left_backboard_base=box(pos=(-10,0,0), length=2, height=0.4, width=2) left_backboard_pillar=cylinder(pos=(-9.3,0,0), axis=(0,3,0), radius=0.15,color=color.cyan) left_backboard_top_branch=curve(pos=[(-8.4,4.6,-1.2),(-9.3,3,0),(-8.4,4.6,1.2)], radius=0.05,color=color.orange) left_backboard_buttom_branch=curve(pos=[(-8.4,2.8,-1.2), (-9.3,3,0), (-8.4,2.8,1.2)], radius=0.05, color=color.orange) left_backboard_elegant=curve(pos=[(-8.4,3,0), (-9.3,3,0), (-10.5,0,0)], radius=0.08,color=color.cyan) left_backboard=box(pos=(-8.4,3.7,0), length=0.1, height=2, width=3) left_backboard_inline_rectangle=curve(pos=[(-8.4,2.9,-0.5), (-8.4,3.7,-0.5), (-8.4,3.7,0.5),(-8.4,2.9,0.5), (-8.4,2.9,-0.5)], radius=0.08, color=color.red) left_backboard_hoop=ring(pos=(-8.0,2.85,0), axis=(0,1,0), radius=0.4, thickness=0.03,color=color.orange) left_backboard_buttom_edge=curve(pos=[(-8.4,3.6,-1.5), (-8.4,2.7,-1.5), (-8.4,2.7,1.5),(-8.4,3.6,1.5)], radius=0.1,color=color.blue) #right backboard right_backboard_base=box(pos=(10,0,0), length=2, height=0.4, width=2) right_backboard_pillar=cylinder(pos=(9.3,0,0), axis=(0,3,0), radius=0.15, color=color.cyan) right_backboard_top_branch=curve(pos=[(8.4,4.6,-1.2), (9.3,3,0), (8.4,4.6,1.2)], radius=0.05,color=color.orange) right_backboard_buttom_branch=curve(pos=[(8.4,2.8,-1.2), (9.3,3,0), (8.4,2.8,1.2)], radius=0.05, color=color.orange) right_backboard_elegant=curve(pos=[(8.4,3,0), (9.3,3,0), (10.5,0,0)], radius=0.08,color=color.cyan) right_backboard=box(pos=(8.4,3.7,0), length=0.1, height=2, width=3) right_backboard_inline_rectangle=curve(pos=[(8.4,2.9,-0.5), (8.4,3.7,-0.5), (8.4,3.7,0.5),(8.4,2.9,0.5), (8.4,2.9,-0.5)], radius=0.08, color=color.red) right_backboard_hoop=ring(pos=(8.0,2.85,0), axis=(0,1,0), radius=0.4, thickness=0.03,color=color.orange) right_backboard_buttom_edge=curve(pos=[(8.4,3.6,-1.5), (8.4,2.7,-1.5), (8.4,2.7,1.5),(8.4,3.6,1.5)], radius=0.1,color=color.blue) #left front corner light left_front_corner_pillar=cylinder(pos=(-9.3,0,5), axis=(0,5,0), radius=0.06) left_front_corner_lamp_handler=curve(pos=[(-9.3,5,5), (-9.3,5.5,6)], radius=0.03,color=color.green) left_back_corner_lamp_handler=curve(pos=[(-9.3,5,5), (-9.3,5.5,4)], radius=0.03,color=color.green) left_front_corner_lamp=sphere(pos=(-9.3,5.4,6), radius=0.2,color=color.yellow) left_back_corner_lamp=sphere(pos=(-9.3,5.4,4), radius=0.2,color=color.yellow) #left back corner light left_back_corner_pillar=cylinder(pos=(-9.3,0,-5), axis=(0,5,0), radius=0.06) left_front_corner_lamp_handler=curve(pos=[(-9.3,5,-5), (-9.3,5.5,-6)], radius=0.03,color=color.green) left_back_corner_lamp_handler=curve(pos=[(-9.3,5,-5), (-9.3,5.5,-4)], radius=0.03,color=color.green) left_front_corner_lamp=sphere(pos=(-9.3,5.4,-6), radius=0.2,color=color.yellow) left_back_corner_lamp=sphere(pos=(-9.3,5.4,-4), radius=0.2,color=color.yellow) #right front corner light right_front_corner_pillar=cylinder(pos=(9.3,0,5), axis=(0,5,0), radius=0.06) right_front_corner_lamp_handler=curve(pos=[(9.3,5,5), (9.3,5.5,6)], radius=0.03,color=color.green) right_back_corner_lamp_handler=curve(pos=[(9.3,5,5), (9.3,5.5,4)], radius=0.03,color=color.green) right_front_corner_lamp=sphere(pos=(9.3,5.4,6), radius=0.2,color=color.yellow) right_back_corner_lamp=sphere(pos=(9.3,5.4,4), radius=0.2,color=color.yellow) #right back corner light right_back_corner_pillar=cylinder(pos=(9.3,0,-5), axis=(0,5,0), radius=0.06) right_front_corner_lamp_handler=curve(pos=[(9.3,5,-5), (9.3,5.5,-6)], radius=0.03,color=color.green) righ_back_corner_lamp_handler=curve(pos=[(9.3,5,-5), (9.3,5.5,-4)], radius=0.03,color=color.green) right_front_corner_lamp=sphere(pos=(9.3,5.4,-6), radius=0.2,color=color.yellow) right_back_corner_lamp=sphere(pos=(9.3,5.4,-4), radius=0.2,color=color.yellow) #center front front light center_front_corner_pillar=cylinder(pos=(0,0,5), axis=(0,5,0), radius=0.06) center_front_corner_lamp_handler=curve(pos=[(0,5,5), (0,5.5,6)], radius=0.03,color=color.green) center_back_corner_lamp_handler=curve(pos=[(0,5,5), (0,5.5,4)], radius=0.03,color=color.green) center_front_corner_lamp=sphere(pos=(0,5.4,6), radius=0.2,color=color.yellow) center_back_corner_lamp=sphere(pos=(0,5.4,4), radius=0.2,color=color.yellow) #center front front light center_back_corner_pillar=cylinder(pos=(0,0,-5), axis=(0,5,0), radius=0.06) center_front_corner_lamp_handler=curve(pos=[(0,5,-5), (0,5.5,-6)], radius=0.03,color=color.green) center_back_corner_lamp_handler=curve(pos=[(0,5,-5), (0,5.5,-4)], radius=0.03,color=color.green) center_front_corner_lamp=sphere(pos=(0,5.4,-6), radius=0.2,color=color.yellow) center_back_corner_lamp=sphere(pos=(0,5.4,-4), radius=0.2,color=color.yellow) #define the bleacher for xy in range(1,6,1): back_bleacher= box(pos=(0,xy,-xy-4.5), axis=(1,0,0), length=18.7, height=0.05, width=1) front_bleacher= box(pos=(0,xy,xy+4.5), axis=(1,0,0), length=18.7, height=0.05, width=1) #at last wo create a basketball scene.range = 10 # fixed size, no autoscaling ball = sphere(pos=(3,2,1), radius=0.25, color=color.orange) ball.velocity = vector(0,-1,0) dt = 0.01 while 1: rate(100) ball.pos = ball.pos + ball.velocity*dt if ball.y <= 0.2: ball.velocity.y = -ball.velocity.y else: ball.velocity.y = ball.velocity.y - 9.8*dt

    发表于 @ 2008年01月23日 22:17:00 | 评论( loading... ) | 编辑| 举报| 收藏

    新一篇:追忆那些年老色衰的代码--献给程序员同行,没事看看那些旧代码吧

    • 发表评论
    • 评论内容:
    •  
    Copyright © zwz521007
    Powered by CSDN Blog