在我的俄罗斯方块游戏中,如果原始立方体消失,我就无法创建一个新立方体。当我使用这种方法时,我的第一个立方体消失了,新的立方体出现了。我想用相似的方法制作两个相似的立方体
有我的代码:
from ursina import *
from random import randint
class CubeSprite(object):
dawn = 0
e = Sprite(model='square', color=color.orange, scale_y=0.25, scale_x=0.25, position=(0, 0, 0))
e1 = Sprite(model='square', color=color.green, scale_y=0.25, scale_x=0.25, position=(.25, 0, 0))
e2 = Sprite(model='square', color=color.yellow, scale_y=0.25, scale_x=0.25, position=(0, -.25, 0))
e3 = Sprite(model='square', color=color.red, scale_y=0.25, scale_x=0.25, position=(.25, -.25, 0))
def generation(self):
x_position = randint(-3, 4)
self.e.position = (x_position, 4, 0)
self.e1.position = (x_position + .25, 4, 0)
self.e2.position = (x_position, 3.75, 0)
self.e3.position = (x_position+.25, 3.75, 0)
def movement(self):
if self.dawn < 1:
if held_keys['d'] and self.e3.x < 6.75:
self.e.x += 0.25
self.e1.x += 0.25
self.e2.x += 0.25
self.e3.x += 0.25
if held_keys['a'] and self.e.x > -6.75:
self.e.x -= 0.25
self.e1.x -= 0.25
self.e2.x -= 0.25
self.e3.x -= 0.25
self.e.y -= 0.25
self.e1.y -= 0.25
self.e2.y -= 0.25
self.e3.y -= 0.25
cube = CubeSprite()
cube.generation()
cube2 = object.__new__(CubeSprite)
cube2.generation()