Can someone help me for my shooter game?

If you want to use physics collide, you can just put physics circles around each sprite. Comment out the 2 ellipse lines to not show the physics circles.


viewer.mode=STANDARD

function setup() 
    fill(255)
    
    c1 = physics.body(CIRCLE,50)
    c1.type=DYNAMIC
    c1.x=300
    c1.y=HEIGHT
    c1.restitution=.8
    
    c2 = physics.body(CIRCLE,50)
    c2.type=STATIC
    c2.x=300
    c2.y=100
    c2.restitution=.8
end

function collide(contact)
    if contact.state == BEGAN then
        print("collide")
    end
end

function draw()
    background(30, 30, 30, 25)   
    ellipse(c1.x,c1.y,80)    
    ellipse(c2.x,c2.y,80)
    sprite(asset.builtin.Planet_Cute.Character_Boy,c1.x,c1.y+15)
    sprite(asset.builtin.Planet_Cute.Character_Horn_Girl, c2.x, c2.y+15)
end

The one without physics was exactly what I expected! Thank you!!! I will now try to design a “mission” or lvl with the code!! And thank you very much again and I didn’t think they understood it so well

@Killer.Jo Here’s some collision code based on the distance between the x,y values of the 2 sprites. It uses the vec dist function. This is more of a circular check while the other is a square check.


viewer.mode=FULLSCREEN    
      
function setup()
    fill(0,255,0)
    fontSize(80)
    v1=vec2(WIDTH/2,HEIGHT/2)
    v2=vec2(WIDTH/2,100)
end

function draw()
    background(242, 165, 43)
    sprite(asset.builtin.Planet_Cute.Character_Boy,v1.x,v1.y)
    sprite(asset.builtin.Planet_Cute.Character_Horn_Girl, v2.x, v2.y)
    dist=v1:dist(v2)
    if dist<80 then
        text("collide",WIDTH/2,HEIGHT/2)
    end
end

function touched(t)
    if t.state==CHANGED then
        v2.x=v2.x+t.deltaX 
        v2.y=v2.y+t.deltaY 
    end
end

Can you send me from the code I will send you only the part of the code where the guard shoots? So the code I will send you (the code is from you) you have to send me the part of the code where the watch shoots. Would be good if they understood me because you can’t explain that well, especially if I actually write this in German and my translator, who simply translates into English (because, as you know, translators don’t work well

The code:


viewer.mode=FULLSCREEN

function setup()
    vel=1
    shipBullet={}
    orbBullet={}
    hit=false
    msg=""
    shipX,shipY=WIDTH/2,60
    orbX,orbY=WIDTH/2,HEIGHT-50
end

function draw()
    background(255, 185, 0)
    if not hit then 
        shipMove()
        orbMove()
        shipShooting()
        orbShooting()
        orbHit()
        shipHit()
        text("Double tap to shoot",WIDTH/2,80)
    else
        fontSize(100)
        fill(255,0,0)
        text(msg,WIDTH/2,HEIGHT/2)
        fontSize(40)
        fill(255)
        text("Double tap to restart",WIDTH/2,HEIGHT/2-80)
    end
end

function shipMove()
    sprite(asset.builtin.Tyrian_Remastered.Ship_B, shipX, shipY, 100, 100) 
end

function orbMove()
    orbX=orbX+vel
    if orbX>WIDTH or orbX<0 then
        vel=-vel
    end
    sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_2, orbX, orbY,50)
end

function shipShooting()
    offset = 20
    if shoot then
        shoot=false
        if #shipBullet<5 then  -- only allow 5 bullets at a time
            table.insert(shipBullet,vec2(shipX,shipY+offset))
        end
    end
    for a,b in pairs(shipBullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_1, shipBullet[a].x, shipBullet[a].y+offset)
        shipBullet[a].y=shipBullet[a].y+5
    end
    for a,b in pairs(shipBullet) do
        if shipBullet[a].y+offset>HEIGHT then
            table.remove(shipBullet,a)
        end
    end
end

function orbShooting()
    if #orbBullet<1 then    -- change to 2 for 2 bullets
        table.insert(orbBullet,vec2(orbX,orbY)) 
    end
    for a,b in pairs(orbBullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Mine_Spiked_Huge, orbBullet[a].x, orbBullet[a].y)
        orbBullet[a].y=orbBullet[a].y-5
        attack()
    end
    for a,b in pairs(orbBullet) do
        if orbBullet[a].y<0 then
            table.remove(orbBullet,a)
        end
    end
end

function attack()    
    speed=6
    if orbBullet[1].y>shipY then
        v1=vec2(orbBullet[1].x-shipX,orbBullet[1].y-shipY)
        v1=v1:normalize()
    end
    orbBullet[1].x=orbBullet[1].x-v1.x*speed
    orbBullet[1].y=orbBullet[1].y-v1.y
end

function shipHit()
    for a,b in pairs(orbBullet) do
        if orbBullet[a].x>shipX-30 and orbBullet[a].x<shipX+30 and orbBullet[a].y>shipY-30 and orbBullet[a].y<shipY+30 then
            msg="You lose"
            hit=true
        end
    end   
end

function orbHit()
    for a,b in pairs(shipBullet) do
        if shipBullet[a].x>orbX-30 and shipBullet[a].x<orbX+30 and shipBullet[a].y>orbY-30 and shipBullet[a].y<orbY+30 then
            msg="You win"
            hit=true
        end
    end   
end

function touched(t)
    if t.state==BEGAN and t.tapCount==2 then
        shoot=true
        if hit then
            viewer.restart()
        end
    end
    if t.state==CHANGED then
        shipX=shipX+t.deltaX*2
        shipY=shipY+t.deltaY*2
    end
end

Here’s the code where the ship shoots. I added more comments. When you double tap the screen, the “shoot” variable becomes true and a bullet is added to the shipBullet table if there are less than 5 bullets in the table.

I think this is what you’re asking. I don’t understand exactly what you want.

function shipShooting()
    -- so bullet comes from front of ship instead of center
    offset = 20
    
    -- there was a double tap, so add a bullet to the bullet table if less than 5
    if shoot then
        shoot=false
        if #shipBullet<5 then  -- only allow 5 bullets at a time
            table.insert(shipBullet,vec2(shipX,shipY+offset))
        end
    end
    
    -- draw the sprite for the bullets
    for a,b in pairs(shipBullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_1, shipBullet[a].x, shipBullet[a].y+offset)
        shipBullet[a].y=shipBullet[a].y+5
    end
    
    -- if bullet goes off the screen top, remove it from the bullet table   
    for a,b in pairs(shipBullet) do
        if shipBullet[a].y+offset>HEIGHT then
            table.remove(shipBullet,a)
        end
    end
end

Oh no! When I write something, I should make sure that you also know exactly what I mean… Because I actually need the code where the opponent shoots. Or rather, I need a code where another opponent shoots at me (but doesn’t always hit) so the guard should shoot in my direction, but when I dog, the ball just flies on so that I won’t get hit. But please add that in the code from me

Here’s the code with 2 enemy shooters.


viewer.mode=FULLSCREEN

function setup()
    vel1,vel2=1,2
    shipBullet={}
    orb1Bullet={}
    orb2Bullet={}
    hit=false
    msg=""
    shipX,shipY=WIDTH/2,60
    orb1X,orb1Y=WIDTH*.75,HEIGHT-50
    orb2X,orb2Y=WIDTH*.25,HEIGHT-50
end

function draw()
    background(255, 185, 0)
    if not hit then 
        shipMove()
        shipShooting()
        
        orb1Move()
        orb1Shooting()
        orb1Hit()
        ship1Hit()
        
        orb2Move()
        orb2Shooting()
        orb2Hit()
        ship2Hit()
        
        text("Double tap to shoot",WIDTH/2,80)
    else
        fontSize(100)
        fill(255,0,0)
        text(msg,WIDTH/2,HEIGHT/2)
        fontSize(40)
        fill(255)
        text("Double tap to restart",WIDTH/2,HEIGHT/2-80)
    end
end

function shipMove()
    sprite(asset.builtin.Tyrian_Remastered.Ship_B, shipX, shipY, 100, 100) 
end

function orb1Move()
    orb1X=orb1X+vel1
    if orb1X>WIDTH or orb1X<0 then
        vel1=-vel1
    end
    sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_2, orb1X, orb1Y,50)
end

function orb2Move()
    orb2X=orb2X+vel2
    if orb2X>WIDTH or orb2X<0 then
        vel2=-vel2
    end
    sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_2, orb2X, orb2Y,50)
end

function shipShooting()
    offset = 20
    if shoot then
        shoot=false
        if #shipBullet<5 then  -- only allow 5 bullets at a time
            table.insert(shipBullet,vec2(shipX,shipY+offset))
        end
    end
    for a,b in pairs(shipBullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_1, shipBullet[a].x, shipBullet[a].y+offset)
        shipBullet[a].y=shipBullet[a].y+5
    end
    for a,b in pairs(shipBullet) do
        if shipBullet[a].y+offset>HEIGHT then
            table.remove(shipBullet,a)
        end
    end
end

function orb1Shooting()
    if #orb1Bullet<1 then    -- change to 2 for 2 bullets
        table.insert(orb1Bullet,vec2(orb1X,orb1Y)) 
    end
    for a,b in pairs(orb1Bullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Mine_Spiked_Huge, orb1Bullet[a].x, orb1Bullet[a].y)
        orb1Bullet[a].y=orb1Bullet[a].y-5
        attack1()
    end
    for a,b in pairs(orb1Bullet) do
        if orb1Bullet[a].y<0 then
            table.remove(orb1Bullet,a)
        end
    end
end

function attack1()    
    speed1=6
    if orb1Bullet[1].y>shipY then
        v1=vec2(orb1Bullet[1].x-shipX,orb1Bullet[1].y-shipY)
        v1=v1:normalize()
    end
    orb1Bullet[1].x=orb1Bullet[1].x-v1.x*speed1
    orb1Bullet[1].y=orb1Bullet[1].y-v1.y*speed1
end


function orb2Shooting()
    if #orb2Bullet<1 then    -- change to 2 for 2 bullets
        table.insert(orb2Bullet,vec2(orb2X,orb2Y)) 
    end
    for a,b in pairs(orb2Bullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Mine_Spiked_Huge, orb2Bullet[a].x, orb2Bullet[a].y)
        orb2Bullet[a].y=orb2Bullet[a].y-5
        attack2()
    end
    for a,b in pairs(orb2Bullet) do
        if orb2Bullet[a].y<0 then
            table.remove(orb2Bullet,a)
        end
    end
end

function attack2()    
    speed2=4
    if orb2Bullet[1].y>shipY then
        v2=vec2(orb2Bullet[1].x-shipX,orb2Bullet[1].y-shipY)
        v2=v2:normalize()
    end
    orb2Bullet[1].x=orb2Bullet[1].x-v2.x*speed2
    orb2Bullet[1].y=orb2Bullet[1].y-v2.y*speed2
end

function ship1Hit()
    for a,b in pairs(orb1Bullet) do
        if orb1Bullet[a].x>shipX-30 and orb1Bullet[a].x<shipX+30 and orb1Bullet[a].y>shipY-30 and orb1Bullet[a].y<shipY+30 then
            msg="You lose"
            hit=true
        end
    end   
end

function ship2Hit()
    for a,b in pairs(orb2Bullet) do
        if orb2Bullet[a].x>shipX-30 and orb2Bullet[a].x<shipX+30 and orb2Bullet[a].y>shipY-30 and orb2Bullet[a].y<shipY+30 then
            msg="You lose"
            hit=true
        end
    end   
end

function orb1Hit()
    for a,b in pairs(shipBullet) do
        if shipBullet[a].x>orb1X-30 and shipBullet[a].x<orb1X+30 and shipBullet[a].y>orb1Y-30 and shipBullet[a].y<orb1Y+30 then
            msg="You win"
            hit=true
        end
    end   
end

function orb2Hit()
    for a,b in pairs(shipBullet) do
        if shipBullet[a].x>orb2X-30 and shipBullet[a].x<orb2X+30 and shipBullet[a].y>orb2Y-30 and shipBullet[a].y<orb2Y+30 then
            msg="You win"
            hit=true
        end
    end   
end 

function touched(t)
    if t.state==BEGAN and t.tapCount==2 then
        shoot=true
        if hit then
            viewer.restart()
        end
    end
    if t.state==CHANGED then
        shipX=shipX+t.deltaX*2
        shipY=shipY+t.deltaY*2
    end
end

I meant that you in this code:


    if Training001 then
        background(77)  
        
        sprite(asset.builtin.Planet_Cute.Character_Boy,x,y) 
    sprite(asset.builtin.Tyrian_Remastered.Boss_A, WachenX, WachenY)
    checkCollide() 
    end 

Should make that, the sprite(asset.builtin.Tyrian_Remastered.Boss_A, WachenX, WachenY) attacks the player. (Character boy) as with the code of them (the one they sent me) and why do you actually have to enter at least 20 characters if you want to write something him codea talk?

Not sure if this is what you’re after.


viewer.mode=FULLSCREEN

function setup()
    vel1,vel2=1,2
    boss=vec2(WIDTH/2,HEIGHT)
    shipBullet={}
    orb1Bullet={}
    orb2Bullet={}
    hit=false
    msg=""
    shipX,shipY=WIDTH/2,60
    orb1X,orb1Y=WIDTH*.75,HEIGHT-50
    orb2X,orb2Y=WIDTH*.25,HEIGHT-50
end

function draw()
    background(255, 185, 0)
    if not hit then 
        shipMove()
        shipShooting()
        
        orb1Move()
        orb1Shooting()
        orb1Hit()
        ship1Hit()
        
        orb2Move()
        orb2Shooting()
        orb2Hit()
        ship2Hit()
        
        bossMove()
        bossHit()        
        
        text("Double tap to shoot",WIDTH/2,80)
    else
        fontSize(100)
        fill(255,0,0)
        text(msg,WIDTH/2,HEIGHT/2)
        fontSize(40)
        fill(255)
        text("Double tap to restart",WIDTH/2,HEIGHT/2-80)
    end
end

function bossMove()    
    speed1=2
    local v1=vec2(boss.x-shipX,boss.y-shipY)
    v1=v1:normalize()
    boss.x=boss.x-v1.x*speed1
    boss.y=boss.y-v1.y*speed1
    sprite(asset.builtin.Tyrian_Remastered.Boss_A,boss.x,boss.y)
end

function bossHit()
    if boss.x>shipX-30 and boss.x<shipX+30 and boss.y>shipY-30 and boss.y<shipY+30 then
        msg="You lose"
        hit=true
    end
end


function shipMove()
    sprite(asset.builtin.Tyrian_Remastered.Ship_B, shipX, shipY, 100, 100) 
end

function orb1Move()
    orb1X=orb1X+vel1
    if orb1X>WIDTH or orb1X<0 then
        vel1=-vel1
    end
    sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_2, orb1X, orb1Y,50)
end

function orb2Move()
    orb2X=orb2X+vel2
    if orb2X>WIDTH or orb2X<0 then
        vel2=-vel2
    end
    sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_2, orb2X, orb2Y,50)
end

function shipShooting()
    offset = 20
    if shoot then
        shoot=false
        if #shipBullet<5 then  -- only allow 5 bullets at a time
            table.insert(shipBullet,vec2(shipX,shipY+offset))
        end
    end
    for a,b in pairs(shipBullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Energy_Orb_1, shipBullet[a].x, shipBullet[a].y+offset)
        shipBullet[a].y=shipBullet[a].y+5
    end
    for a,b in pairs(shipBullet) do
        if shipBullet[a].y+offset>HEIGHT then
            table.remove(shipBullet,a)
        end
    end
end

function orb1Shooting()
    if #orb1Bullet<1 then    -- change to 2 for 2 bullets
        table.insert(orb1Bullet,vec2(orb1X,orb1Y)) 
    end
    for a,b in pairs(orb1Bullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Mine_Spiked_Huge, orb1Bullet[a].x, orb1Bullet[a].y)
        orb1Bullet[a].y=orb1Bullet[a].y-5
        attack1()
    end
    for a,b in pairs(orb1Bullet) do
        if orb1Bullet[a].y<0 then
            table.remove(orb1Bullet,a)
        end
    end
end

function attack1()    
    speed1=6
    if orb1Bullet[1].y>shipY then
        v1=vec2(orb1Bullet[1].x-shipX,orb1Bullet[1].y-shipY)
        v1=v1:normalize()
    end
    orb1Bullet[1].x=orb1Bullet[1].x-v1.x*speed1
    orb1Bullet[1].y=orb1Bullet[1].y-v1.y*speed1
end


function orb2Shooting()
    if #orb2Bullet<1 then    -- change to 2 for 2 bullets
        table.insert(orb2Bullet,vec2(orb2X,orb2Y)) 
    end
    for a,b in pairs(orb2Bullet) do    -- show and increment bullet
        sprite(asset.builtin.Tyrian_Remastered.Mine_Spiked_Huge, orb2Bullet[a].x, orb2Bullet[a].y)
        orb2Bullet[a].y=orb2Bullet[a].y-5
        attack2()
    end
    for a,b in pairs(orb2Bullet) do
        if orb2Bullet[a].y<0 then
            table.remove(orb2Bullet,a)
        end
    end
end

function attack2()    
    speed2=4
    if orb2Bullet[1].y>shipY then
        v2=vec2(orb2Bullet[1].x-shipX,orb2Bullet[1].y-shipY)
        v2=v2:normalize()
    end
    orb2Bullet[1].x=orb2Bullet[1].x-v2.x*speed2
    orb2Bullet[1].y=orb2Bullet[1].y-v2.y*speed2
end

function ship1Hit()
    for a,b in pairs(orb1Bullet) do
        if orb1Bullet[a].x>shipX-30 and orb1Bullet[a].x<shipX+30 and orb1Bullet[a].y>shipY-30 and orb1Bullet[a].y<shipY+30 then
            msg="You lose"
            hit=true
        end
    end   
end

function ship2Hit()
    for a,b in pairs(orb2Bullet) do
        if orb2Bullet[a].x>shipX-30 and orb2Bullet[a].x<shipX+30 and orb2Bullet[a].y>shipY-30 and orb2Bullet[a].y<shipY+30 then
            msg="You lose"
            hit=true
        end
    end   
end

function orb1Hit()
    for a,b in pairs(shipBullet) do
        if shipBullet[a].x>orb1X-30 and shipBullet[a].x<orb1X+30 and shipBullet[a].y>orb1Y-30 and shipBullet[a].y<orb1Y+30 then
            msg="You win"
            hit=true
        end
    end   
end

function orb2Hit()
    for a,b in pairs(shipBullet) do
        if shipBullet[a].x>orb2X-30 and shipBullet[a].x<orb2X+30 and shipBullet[a].y>orb2Y-30 and shipBullet[a].y<orb2Y+30 then
            msg="You win"
            hit=true
        end
    end   
end 

function touched(t)
    if t.state==BEGAN and t.tapCount==2 then
        shoot=true
        if hit then
            viewer.restart()
        end
    end
    if t.state==CHANGED then
        shipX=shipX+t.deltaX*2
        shipY=shipY+t.deltaY*2
    end
end

I would like this in this code now:


if Training001 then
        background(77)  
        
        sprite(asset.builtin.Planet_Cute.Character_Boy,x,y) 
    sprite(asset.builtin.Tyrian_Remastered.Boss_A, WachenX, WachenY)
    checkCollide() 
    end 

I would like the boss to shoot down the Sprite character boy

If you have understood this, just send me a message and tell me what you have understood because then we can see if you have understood me because I don’t think my translator is good

Adding that code isn’t going to do anything without add a lot more code. Adding what I think you want might be too complicated for what the program is doing now. And I still don’t know what you actually want the program to do. I don’t want to just keep adding things that you really don’t want.

So I don’t mean that you should add this in your code, but in my rather this one:


if Training001 then
        background(77)  
        
        sprite(asset.builtin.Planet_Cute.Character_Boy,x,y) 
    sprite(asset.builtin.Tyrian_Remastered.Boss_A, WachenX, WachenY)
    checkCollide() 
    end 

And in this code I want the guard (asset.builtin.Tyrian_Remastered.Boss_A) to shoot the player (the player is (asset.builtin.Planet_Cute.Character_Boy,x,y) I know if I should write more

What code is your code that you want me to add those lines to. Can you repost your code.

1 Like

if Training001 then
        background(77)  
        
        sprite(asset.builtin.Planet_Cute.Character_Boy,x,y) 
    sprite(asset.builtin.Tyrian_Remastered.Boss_A, WachenX, WachenY)
    checkCollide() 
    end 

I’m totally confused about what you want done. You want those lines of code added to something, but I don’t know what. Repost the code that you want those lines of code inserted into.


if Training001 then
        background(77)  
        
        sprite(asset.builtin.Planet_Cute.Character_Boy,x,y) 
    sprite(asset.builtin.Tyrian_Remastered.Boss_A, WachenX, WachenY)
    checkCollide() 
    end 

I would like that in the upper code one of the two sprites shoots off the other sprite. And, I think I almost always write the same answer, so could you tell me what exactly you don’t understand? Or if you have understood that now, send me the code where one of the two sprites shoots the other sprite

Tap screen to shoot.

viewer.mode=FULLSCREEN

function setup()
    fill(255)
    x = 0
    y=HEIGHT-100
    speed=5
    WachenX=WIDTH/2
    WachenY=100
    missle=vec2(WachenX,WachenY)   
end

function draw()   
    background(128)
    sprite(asset.builtin.Planet_Cute.Character_Boy,x, y)
    sprite(asset.builtin.Tyrian_Remastered.Boss_A, WachenX, WachenY)
    
    x=x+speed
    if x<0 or x>WIDTH then
        speed= -speed
    end
    
    if Training001 then
        missle.y=missle.y+40
        if missle.y>HEIGHT then
            missle=vec2(WachenX,WachenY)   
            Training001=false
        end
        sprite(asset.builtin.Tyrian_Remastered.Mine_Spiked_Huge,missle.x,missle.y)
        checkCollide() 
    end 
    if missleCollide then
        missleHit()
    end   
end

function checkCollide()
    if missle.x>x-30 and missle.x<x+30 and missle.y>y-30 and missle.y<y+30 then
        missleCollide=true
        sound(asset.downloaded.Game_Sounds_One.Explode_1)
    end
end

function missleHit()
    sprite(asset.builtin.Tyrian_Remastered.Explosion_Huge,x,y,100)
    Training001=false
    missle=vec2(WachenX,WachenY)
    text("Double tap to restart",WIDTH/2,HEIGHT/2)   
end

function touched(t)
    if t.state == BEGAN then
        if t.tapCount==2 then
            missleCollide=false
        else
            Training001=true
        end
    end
end

Good! But the sprite is supposed to shoot automatically. And the player (the Sprite character boy) should be able to move

Slide your finger to move the boy.


viewer.mode=FULLSCREEN

function setup()
    fill(255)
    dx,dy=0,0
    x=100
    y=HEIGHT-100
    WachenX=WIDTH/2
    WachenY=100
    missle=vec2(WachenX,WachenY)  
    Training001=true 
end

function draw()   
    background(128)
    sprite(asset.builtin.Planet_Cute.Character_Boy,x+dx, y+dy)
    sprite(asset.builtin.Tyrian_Remastered.Boss_A, WachenX, WachenY)

    
    if Training001 then
        missle.y=missle.y+20
        if missle.y>HEIGHT then
            missle=vec2(WachenX,WachenY)   
            Training001=true
        end
        sprite(asset.builtin.Tyrian_Remastered.Mine_Spiked_Huge,missle.x,missle.y)
        checkCollide() 
    end 
    if missleCollide then
        missleHit()
    end   
end

function checkCollide()
    if missle.x>x+dx-30 and missle.x<x+dx+30 and missle.y>y+dy-30 and missle.y<y+dy+30 then
        missleCollide=true
        sound(asset.downloaded.Game_Sounds_One.Explode_1)
    end
end

function missleHit()
    sprite(asset.builtin.Tyrian_Remastered.Explosion_Huge,x+dx,y+dy,100)
    Training001=false
    missle=vec2(WachenX,WachenY)
    text("Double tap to restart",WIDTH/2,HEIGHT/2)   
end

function touched(t)
    if t.state == BEGAN then
        if t.tapCount==2 then
            missleCollide=false
            Training001=true
        end
    elseif t.state==CHANGED then
        dx=dx+t.deltaX
        dy=dy+t.deltaY
    end
end

Could you still do that the opponent in the direction of the player and that the player partially reloads?