magnetic car crane

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

magnetic car crane

Postby telemole » Mon Dec 21, 2009 11:25 pm

Hi folks,

I am a programmer - but new to Algodoo.. I am building some basic games for my 4 and 6 year old kids.

I want to create a crane they operate that works like a giant magnet - picking up cars when they get the magnet over car and 'activate' the magnet somehow... then drop it again when the magnet is 'de-activated'

Anyone have thoughts on how to do this? and perhaps a nice little sample I can pick to pieces to start to understand this code?

thanks in advance!

Cheers,
Sean
telemole
 
Posts: 2
Joined: Mon Dec 21, 2009 11:18 pm

Re: magnetic car crane

Postby Ian151 » Tue Dec 22, 2009 2:36 am

Rating: rated 5.1
Filesize: 37.31 kB
Comments: 1
Ratings: 2
download


Here is a scene that should help. This is what I did...

Seeing how you seem to have Algodoo, I made it with lasers. One laser turns on the magnet, another one shuts it off.

The laser that turns it on...

Code: Select all
(e)=>{e.geom.refractiveindex == 1.1 ? {e.geom.attraction = e.geom.controlleracc} : {}}


The only part you need to really payattention to is the part that says e.geom.attraction =
That part will tell the geometry to change attraction. I set it to change the attraction to whatever the geometries controller acc is, or e.geom.controlleracc.

This is for laser collisions, e.geom and e.laser. for other collisions, such as object and object, it would be e.this or e.other.
"THE BEST 2 PLAYER SCENE EVER MADE!!!" - ianno
http://www.algodoo.com/algobox/details.php?id=24204
Image
User avatar
Ian151
 
Posts: 47
Joined: Tue Sep 01, 2009 12:02 am

Re: magnetic car crane

Postby telemole » Tue Dec 22, 2009 3:31 am

this is fantastic!

Almost exactly what I wanted! Now if I can just be a further pain and ask WHERE you set the laser controls - i was unable to find the script with the key bindings and the statements you quoted...

I did play with the attraction level and also noticed that it is only in effect on matching collision groups - which is perfect.

Can't wait to play more with this! If you can give me a greater understanding I'd really appreciate it! Thanks for this!

Sean
telemole
 
Posts: 2
Joined: Mon Dec 21, 2009 11:18 pm

Re: magnetic car crane

Postby Ian151 » Wed Dec 23, 2009 12:06 am

The lasers are partially hidden above the red magnet. It's where the boxes are all packed together above the magnet. Select the entire attachment, click selection... And then select only lasers from there. Then bring them to the front. I'm glad you found my magnet to be of good use :)
"THE BEST 2 PLAYER SCENE EVER MADE!!!" - ianno
http://www.algodoo.com/algobox/details.php?id=24204
Image
User avatar
Ian151
 
Posts: 47
Joined: Tue Sep 01, 2009 12:02 am

Re: magnetic car crane

Postby Bronie12345 » Wed Dec 30, 2009 6:27 pm

make sure you have algodoo in advanced mode, to see everything...
When you make a comment at a scene, at least be brave enough to subscribe to that scene...
Don't go into a topic unprepared... Read the whole topic, including all the comments, before posting.

92% of teenagers have resorted to rap music. If you are part of the 8% who listens to real music, put this in your signature.
90% of teenagers today would die if Myspace/Facebook were completely destroyed. If you are one of the 10% who would be laughing their heads off, add this to your signature.
User avatar
Bronie12345
 
Posts: 451
Joined: Mon Aug 31, 2009 8:52 pm
Location: The Netherlands


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests