class Ball: def __init__(self, img): self._velocity = RBVelocity(1, 135) self._pos = RB2DPosition(100, 0) self._img = RBImage(img, RB2DPosition(100, 0)) def update(self): self._pos.movePos(self._velocity.getVelocityX(), self._velocity.getVelocityY()) if self._pos.getX() < 0 or self._pos.getX() > 350: self._velocity.changeAngle(90) self._velocity.changeSpeed(1) elif self._pos.getY() < 0 or self._pos.getY() > 450: self._velocity.changeAngle(90) self._velocity.changeSpeed(1) def draw(self, graphics): if self._img: self._img.draw(graphics, self._pos.getX(), self._pos.getY())
def __init__(self, img): self._velocity = RBVelocity(1, 135) self._pos = RB2DPosition(100, 0) self._img = RBImage(img, RB2DPosition(100, 0))