def __init__(self, position): ball_asset = ImageAsset("images/orb-150545_640.png") #pull from repository ball = Sprite(ball_asset, (0, 400)) ball.scale = 0.07 # custom attributes ball.direction = 1 ball.go = True # Sounds pew1_asset = SoundAsset("sounds/pew1.mp3") pew1 = Sound(pew1_asset) pop_asset = SoundAsset("sounds/reappear.mp3") pop = Sound(pop_asset) super().__init__(ball_asset, position)
# define colors and line style green = Color(0x00ff00, 1) black = Color(0, 1) noline = LineStyle(0, black) # a rectangle asset and sprite to use as background bg_asset = RectangleAsset(myapp.width, myapp.height, noline, green) bg = Sprite(bg_asset, (0, 0)) # A ball! This is already in the ggame-tutorials repository ball_asset = ImageAsset("images/orb-150545_640.png") ball = Sprite(ball_asset, (0, 0)) # Original image is too big. Scale it to 1/10 its original size ball.scale = 0.1 # custom attributes ball.direction = 1 ball.go = True # Sounds pew1_asset = SoundAsset("sounds/pew1.mp3") pew1 = Sound(pew1_asset) pop_asset = SoundAsset("sounds/reappear.mp3") pop = Sound(pop_asset) def reverse(b): b.direction *= -1 # Set up function for handling screen refresh def step():