6.2 Build BallBox Spark App

Create a file named: BallBox.py (note: save it to the same path as Ball.py), and type the content below:

from JMRPiFoundations.Skeleton.RPiSparkModule import RPiSparkModule
from Ball import Ball

class BallBox(RPiSparkModule):
    ball = None

    def setup(self):
        self.ball = Ball(64, 32, 5)

    def run(self):
        self.RPiSpark.Screen.Canvas.ellipse( self.ball.getXY(), 1, 1 )

Type command in the terminal:

$> rspk BallBox -f

At this time you should be able to see a white solid circle in the center of the OLED screen (we use a solid circle to represent the ball)



Was this article helpful?

YES     |     NO


Enjoying the project? Spotted a mistake? Any opinions on the website? Let us know!