Spawn lots of circles with different parameters

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

Spawn lots of circles with different parameters

Postby Cindex » Fri May 14, 2010 9:09 am

I've been into programming for quite some time. I took a break for about a year, and I wanted to get back into it. I didn't want to get into anything TOO serious (as in huge scripts like Java or something) and I remembered all the fun I had with Phun.

Needless to say, I came back to it. (Or, Algodoo anyways.)

So here's what I got so far...
Code: Select all
(e)=>{
    scene.addCircle({
        radius := 0.1;
        pos := e.pos;
        vel = [50, 50];
    });
    scene.addCircle({
        radius := 0.1;
        pos := e.pos;
        vel = [-50, 50];
        e.this.density = 0;
    })
}


Now here's what I want it to do...

Code: Select all
(e)=>{
    countX := 50;
    countY := 50;
    for( 10, (x)=>{
        scene.addCircle({
            radius := 0.1;
            pos := e.pos;
            vel = [countX, countY];
            countX = countX - 10;
            countY = countY + 10;
        })
    }
}


Now, I KNOW that's not right. Can anyone correct me, please?
Cindex
 
Posts: 1
Joined: Fri May 14, 2010 8:45 am

Re: Spawn lots of circles with different parameters

Postby Mr_Stabby » Fri May 14, 2010 9:31 am

Code: Select all
    countX := 50;
    countY := 50;
    for( 10, (x)=>{
        scene.addCircle({
            radius := 0.1;
            pos := e.pos;
            vel := [countX, countY];
        })
        countX = countX - 10;
        countY = countY + 10;
    }

or
Code: Select all
    for( 10, (x)=>{
        scene.addCircle({
            radius := 0.1;
            pos := e.pos;
            vel := [x*(-10)+50, x*10+50];
        })
    }
Mr_Stabby
 
Posts: 155
Joined: Wed Dec 16, 2009 12:16 am

Re: Spawn lots of circles with different parameters

Postby RA2lover » Fri May 14, 2010 6:48 pm

you forgot to use ; between the end of the for function and the count change. the lack of it will cause a script failure
Jrv wrote:
TC42 wrote:Quite honestly, I didn't think anyone on 4chan has that good a use of grammar, spelling, usage, mechanics, ect.
But I've never been there, so I may be wrong.


GTFO newfgt
User avatar
RA2lover
 
Posts: 607
Joined: Mon Aug 31, 2009 8:43 pm
Location: Brazil


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 7 guests