Jump to content
aberdeen-music

OOP grass in Director


lepeep

Recommended Posts

I just started pissing around with OOP in Director again (after leaving it for so long)...I recently picked up a book on OOP in ActionScript 2.0 and decided to get back on the snake with Director...see what you think (you'll need the Shocwave DIRECTOR plug in ... fuck flash...

he he, this is 1 parent script and 1 frame script and one set of utilities (Trig etc)

enjoy, the grass that keeps on growing.

and, if you don't like the results, press "C" to "clear" the ground.

http://www.g-r-a.co.uk/director/

peep

Link to comment
Share on other sites

that's the Beauty of OOP (Object Orientated Programming).

you make a parent "script", feed it some random vals, and presto, let the Math / Trig do the talking.

it's all recursive bits n bobs really...

start with a "length", a "startAngle" (constrained) and a speed / devision value...and watch as the parent script starts, and makes chirdren...

here are some of the utilities to help it along:

on startMovie me

gRad=PI/180 -- store for future reference

the actorList = []

end

on getDist theClick

a = abs(theClick[1][1] - theClick[2][1])

b = abs(theClick[1][2] - theClick[2][2])

return sqrt((a*a)+(b*b))

end

on retNewLoc f, dist, rot

tRotation=rot*gRad -- convert degrees -> radians

tNewX=f[1]+cos(tRotation)*dist

tNewY=f[2]+sin(tRotation)*dist

return (point(tNewX,tNewY))

end

on Turn clicks -- sent by mouseUP [fromPoint, toPoint]

slope = clicks[2] - clicks[1]

newAngle = getAngle(slope)

return(newAngle)

end Turn

on GetAngle slope -- sent by Turn

deltaH = slope[1]

deltaV = slope[2]

if deltaH then

slope = float (deltaV) / deltaH

angle = atan (slope)

if deltaH < 0 then

angle = angle + pi

end if

else if deltaV > 0 then

angle = pi / 2

else if deltaV < 0 then

angle = (3 * pi) / 2

else

angle = 0

end if

-- Convert to degrees for .rotation

angle = (angle * 180) / pi

return angle

end GetAngle

on retPerc tot, x -- tot = total, x = incriment

myPerc = (100.0/tot)*x

return myPerc

end

on retVal tot, p -- tot = total, p = percent of total

myVal = (tot/100.0)*p

return myVal

end

on startFire locX, howMany, howLong, howFast, r, g, b

repeat with i = 1 to howMany

n = new(script "shoot", locX, random(howLong)+howLong/2, random(howFast)+howFast/2, r,g,b, i)

(the actorList).add(n)

n.startShot()

end repeat

end

Link to comment
Share on other sites

and...

er' date=' what now? [/quote']

I think I am going to try and make alist of all the points, and add a wind, to make it sway once it's grown...now that would be nice.

I've already got an OOP tree...so I think an OOP digital garden, with OOP butterflies, that polonate flowers would be pretty amazing......we'll see...

Link to comment
Share on other sites

phil' date=' i have no idea what any of that stuff means. it would be cool if you could make a garden with it though.

so could you make a tree that grows on it's own with that? i could have a use for such a thing.[/quote']

no,that was just the "uts", bits of code that the Parent script looks to, for calculations for percents, trig etc...

the parent script is still "in development" (and heaps of comments etc in it), so, when It's finished, I'll upload it, for people who use Director to use at their free will...cos I am nice like that.

Link to comment
Share on other sites

you can use it without knowing code, for sure, much like you can use flash without knowing (much/any) code.

I've been using director for 10 years now...and I still find it easier and more obvious than flash.

but, I am working hard on trying to understand und learn all the sneaky pitfalls in flash...

like trying to attach a mouseOver onto something that's NOT a button...eh ?...stupid program.

Link to comment
Share on other sites

  • 1 month later...

I've been working on this for a few days now...

and, I've come up with "grass / plants" that are affected by a virtual gust of wind...

It's still in development, but, have a look...see what you think.

(Director Shockwave), and remember, click the white area to grow a plant ... or three (too many, and it'll run like shite)

http://g-r-a.co.uk/phil/

Link to comment
Share on other sites

I was working on it at home, for a few days...

I've had the idea for a while...

It's not perfect...

or realistic...but, getting into the physics of flow motion / dynamics..is probably a bit beyond my tiny grasp of Math.

thanks for looking...

one good thing is, now I can connect two moving points, I can also send "butterflies" etc to these points... next project!

I also want to incorporate seasons, so leaves appear, and die and fall...

keep yer eyes peeled...

and...to also make it in flash, so the lines / smoothness (and plug in availability) are there for all.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...