Attempting to code cannon

As you can see here I already have the cannon turning but I’m attempting to have red ellipses fly out of it. For some reason the if than statement to turn the cannon it connecting to the ellipse. Also I want to ellipses to come out of the cannon somehow. If you are holding down they keep flying, when you let go they stop… Seeking help

displayMode(FULLSCREEN)   

function setup()
    x,y=WIDTH*1/5,HEIGHT/2
    ang=0


    
    a,b=0,0
    end
function touched(touch)
        
    if touch.state==BEGAN or touch.state==MOVING then
        ang=math.deg(math.atan(touch.y-y,touch.x-x))
        end


    
    end
function draw()
    background(2, 2, 2, 255)
    translate(x,y)
    rotate(ang-90)
    sprite("Tyrian Remastered:Boss D", 0,0,100,100)

    fill(217, 38, 38, 255)
    ellipse(a, b, 30)
  
       if touch.state==BEGAN or touch.state==MOVING then
        a=a+5
        b=b+5
    

    end
    end

Hi, just a few things wrong with the code. First of all, the shooting and blowing up sounds are very badly timed and long, also you have to let go of the screen for a new fire ball to come in. Wondering if there is a way to make more then one come out at once. Could you tell me which line the if then statement is that is when the fire ball is a 0 x so if you aren’t able to hit the fireball I can add features to that without help.

Removed code.

Please put “~~~” before and after your code you will get a nice:

my code here

@NG_2000 Don’t start different discussions for the same subject. Also, when you post code put ~~~ on a line before and after your code as @Jmv38 said. I added them to your code above.

Ok

Thank you guys for the help

I will do so

Can you guys help with the code?

Removed code, see updated code below.

Wow

I just wish I understood what all of it means. I get most of it of it, but not all. Learning in school

For some reason ~~~ isn’t working?

There can’t be any spaces before the ~~~. Here’s a version for game over. I don’t think you’re learning anything if I keep writing the code. I’ll give you suggestions, but it’s time for you to start learning how to do things. It’s going to take awhile, but it will be worth it.

 Removed code, updated code below.

Good, cause I should do that myself

Here’s an updated version.

Removed code, see updated code below.

How do i make it if a fire rock hits ship game=over?

Create another for loop using the rocks table and check if a rock and the ship are less than 30 pixels apart. If they are, game over.

Sorry to be annoying, but I don’t know how to do that. I’m kind of beginner and am trying to go farther that what I am learning at school. I know what you mean by checking but I see you did that in the near beginning and can’t seem to recreate it. Tried for about an hour. Also something is wrong with the code and when ever I touch the screen it freezes up. I realized I copied the code down twice and tried to fix it, but messed up something in the code. Thanks

Removed code

Wow bro thanks