【发布时间】:2016-09-20 14:15:28
【问题描述】:
我正在使用 VPython 来模拟一个从墙上弹起的球。
为了让我的代码更优雅,我决定使用类继承来设置我的对象的尺寸和属性(目前,它是球和墙)。运行代码后,shell 没有产生任何错误,但是,它也没有产生窗口。
我对编程很陌生,我在 Linux Mint 18 上的 Wine 中使用 VPython 2.7。我感觉我错过了一些明显的东西,但我不知道它是什么。
到目前为止我的代码如下:
from visual import *
class Obj(object):
def __init__(self, pos, color): #sets the position and color
self.pos = pos
self.color = color
class Sphere(Obj):
def __init__(self, pos, color, radius):
super(Sphere, self).__init__(pos, color)
self.radius = radius
class Box(Obj):
def __init__self, pos, color, radius):
super(Box, self).__init__(pos, color)
self.size = size
self.opacity = opacity
ball1 = Sphere((-5,0,0,), color.orange, 0.25)
wallR = Box((6,0,0), color.cyan, (0.,12,12), 0.3)
【问题讨论】:
-
我没有看到任何与初始化窗口相关的代码。你能把它贴出来吗?您当前的代码只处理您要在窗口中绘制的对象。
-
你能举个例子来说明初始化窗口的含义吗?
标签: python python-2.7 vpython