I want to shoot bubbles out of my Bubblegun, but i don't know how I need to program that


import greenfoot.*; public class BubbleGun extends Actor { protected GreenfootImage bubbleImage = new GreenfootImage("bubble.png"); private boolean spaceDown = false; public void act() { // shooting if (spaceDown != Greenfoot.isKeyDown("space")) { spaceDown = !spaceDown; if (spaceDown) { Bubble bubble = new Bubble(); getWorld().addObject(bubble, getX()+0, getY()+0); // adjust offsets ass needed } } /** other gun actions here */ } private class Bubble extends Actor { protected void addedToWorld(World world) { setRotation(BubbleGun.this.getRotation()); setImage(bubbleImage); } public void act() { move(5); } } }