Help needed.

About advanced scenes, and the Thyme scripting language used in Algodoo.

Help needed.

Postby Kole1911 » Fri Sep 14, 2018 7:50 pm

So uhm, i'm trying to make a bullet circle script but it mostly failed.
basically it would shoot by the count of 360/n amount, the amount consists of how many projectiles will be spawned, help will be appreciated!

Also here's what i have for now.

Code: Select all
(e)=>{
    spd = math.pi / 2 * 181;
    eq = [math.sin(spd * sim.time), math.cos(spd * sim.time)];
    Scene.addcircle({
        pos := e.pos;
        attraction := 0;
        radius := 0.06;
        heterocollide := true;
        collideset := 2;
        drawcake := false;
        drawborder := false;
        color := [1, 0, 1, 1];
        density := 1;
        vel := eq;
        pos := e.this.pos + 0.5 * eq;
        timeToLive := 5;
        friction := 0.01;
        restitution := 0
    })
}
Kole1911
 
Posts: 5
Joined: Thu Sep 13, 2018 12:49 pm

Re: Help needed.

Postby FRA32 » Mon Sep 24, 2018 12:48 pm

Can you elaborate what exactly you want to acomplish, and what failed? I am unfortunally not yet able to deduce from the given information what the desired result should look like.
If you want something to spawn bullets in a circle around some point, the script would look like this:
Code: Select all
(e)=>{
   n = 10;
   bulletspeed = 10;
   bulletDist = 2;
   for(n,(i)=>{
      ang = 2*math.pi/n*i;
      scene.addCircle({
         pos := pos+bulletDist*[math.cos(ang),math.sin(ang)];
         vel := bulletSpeed*[math.cos(ang),math.sin(ang)];
         radius := 0.06;
         heterocollide := true;
         collideset := 2;
         density := 1;
         drawcake := drawborder := false;
         color := [1,0,1,1];
         timetolive := 5;
         friction := 0.01;
         restitution := 0;
      })
   })
   
}


I hope this helps for now!
FRA32
 
Posts: 213
Joined: Wed Dec 03, 2014 9:51 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron