Swarm of ships

I’ve been playing around with making a swarm of ships. Move with one or more fingers, and press fire to create a mayhem. :slight_smile:

https://gist.github.com/tnlogy/4971294

The behaviour is mesmerising and has a real retro feeling.

Love the fact that they destroy each other.

I wanted to create waves of enemies, like in old top-down shooters. But instead I became the wave of ships. :slight_smile:

I hope no one minds me exhuming stuff from this far back, but this is a cool little project, so I fixed it up a little, for anyone who wanders across it like I did,

I corrected a couple lines that were causing errors due to lua updates, and I made an icon for it, and I made it a .zip so you don’t have to go to GitHub to get it,

@tnlogy, nice job!

I made a little tweak that added more ships and put them in random positions in screen instead of all in a straight line. Just a little more chaos for everybody’s enjoyment.

Reminded me of a mob program I wrote in the past. Tap the screen to make the sprites exchange positions.

viewer.mode=FULLSCREEN

function setup()
    size=35
    objects1,objects2,objects3,objects4={},{},{},{}    
    for z=1,120 do
        a=physics.body(CIRCLE,size)
        a.x=math.random(WIDTH)
        a.y=math.random(HEIGHT)
        a.gravityScale=0
        ob=z%4
        if ob==0 then
            table.insert(objects1,a)
        elseif ob==1 then
            table.insert(objects2,a)
        elseif ob==2 then
            table.insert(objects3,a)
        elseif ob==3 then
            table.insert(objects4,a)
        end
    end    
    target1=vec2(WIDTH/2,HEIGHT-150)
    target2=vec2(WIDTH/2,150)
    target3=vec2(150,HEIGHT/2)
    target4=vec2(WIDTH-150,HEIGHT/2)
end

function draw()
    background(142, 88, 38, 255)
    drawMob(objects1,target1,asset.builtin.Planet_Cute.Character_Boy)
    drawMob(objects2,target2,asset.builtin.Planet_Cute.Character_Cat_Girl)
    drawMob(objects3,target3,asset.builtin.Planet_Cute.Character_Horn_Girl)
    drawMob(objects4,target4,asset.builtin.Planet_Cute.Character_Pink_Girl)
end

function drawMob(obj,tar,spr)
    for i,v in ipairs(obj) do
        move=tar-vec2(v.x, v.y)   
        if move:len()>10 then
            move=move:normalize()*10
        end
        v.x=v.x+move.x
        v.y=v.y+move.y
        sprite(spr,v.x,v.y,25)
    end
end

function touched(touch)
    if touch.state==BEGAN then
        target1,target2=target2,target1
        target3,target4=target4,target3
    end
end
1 Like

Fun to see some comments on this old project! I still think you could make an interesting shootemup with this concept :slight_smile:

Havent logged in here in a while :slight_smile:

Good to see you @tnlogy. If you’re interested in poking around a bit there’s some really interesting stuff going on with the new objective-c bindings, and the WebRepo project has become a terrific way to share and discover projects.

@tnlogy I hope you don’t mind, I’ve added this to WebRepo (with credit given) :smile:

Its great that you share it, thanks! :slight_smile: