1
我使用VPython来模拟一个从墙上弹起的球。这不会产生一个窗口,我不知道为什么
为了让我的代码更优雅,我决定使用类继承来设置我的对象的尺寸和属性(此刻,它是球和墙)。在我运行代码之后,shell没有产生任何错误,但是它也没有产生窗口。
我是相当新的编程,我在Wine Mint 18上使用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)
我没有看到任何与初始化窗口相关的代码。你可以请张贴吗?你当前的代码只处理你想要在窗口中绘制的对象。 – Daneel
你可能通过初始化一个窗口来举例说明你的意思吗? –