Browse Search Popular Register Upload Rules User list Login:
Search:
Oncollides as functions

Image:
screenshot of the scene

Author: TC42

Group: Default

Filesize: 16.91 kB

Date added: 2011-06-08

Rating: 5

Downloads: 393

Views: 646

Comments: 4

Ratings: 1

Times favored: 0

Made with: Algodoo before v1.8.5

Tags:
scripting,
function,
oncollide,
phunlet,
friendly

Scene tag

You can substitute a function for an object's oncollide, because the oncollide of an object is a function. (Definition of a function: ()=>{}; oncollide: (e)=>{})
So here is a new way of calling functions without defining them with scene.my; it is phunlet friendly. I included some useful functions if you need them. If you can find a use for this, please tell me.
Last edited at 2012/07/08 20:03:04 by TC42
Please log in to rate this scene
edit
Similar scenes
Title: Attraction Script Engine
Rating: 5
Filesize: 47.99 kB
Downloads: 228
Comments: 1
Ratings: 1
Date added: 2017/09/16 23:05:42
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Checkpoint
Rating: 5
Filesize: 11.85 kB
Downloads: 201
Comments: 0
Ratings: 1
Date added: 2011/05/09 01:14:50
Made with: Algodoo before v1.8.5
Rating: rated 5
download
Title: Console and onCollide Tutorial
Rating: 5
Filesize: 18.22 kB
Downloads: 272
Comments: 2
Ratings: 1
Date added: 2013/07/27 19:24:49
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Tactical Nuke [Phunlet]
Rating: 5.625
Filesize: 64.35 kB
Downloads: 3942
Comments: 5
Ratings: 2
Date added: 2012/09/07 19:44:52
Made with: Algodoo v2.0.1
Rating: rated 5.6
download
Title: Strings functions (Thyme)
Rating: 5.625
Filesize: 1.86 kB
Downloads: 249
Comments: 1
Ratings: 2
Date added: 2010/02/27 22:12:21
Made with: Algodoo before v1.8.5
Rating: rated 5.6
download
Title: onCollide
Rating: 8.5018
Filesize: 42.45 kB
Downloads: 5378
Comments: 16
Ratings: 27
Date added: 2009/03/22 01:21:15
Made with: Phun
Rating: rated 8.5
download
Yay! The best method of hacking Thyme since the New Method!

Also, could you explain scene.my.PointIsInEllipse? My GUI is spazzing out again (you know what I mean), so I can't really use the box to read off of, so I tried to use the Appearance menu, but I realized that I simply didn't understand the function at all.

scene.my.ispointinellipse = (a, b, x, y, point, T, F) =>
{{(((point(0) - x) ^2) /a^2) + (((point(1) - y)^2)/b^2) <= 1} ? {T} : {F}}

What are a, b, x, and y?

Are a and b the max and min radius, x and y are the coordinates of the center?
You know, I haven't even memorized what the values of that function do, and I wrote it! *checks legal pad with notes on it*

Okay, so the formula to graph an ellipse is 1=(x-x1)^2/A^2 + (y-y1)^2/B^2
Link to equations
So if you graph it (using a graphing calculator, preferably), A is horizontal width of the ellipse, and B is the vertical width of the ellipse. X1 and Y1 are the xy coords of the center of the ellipse. See for yourself

All the function does is replace the = with <=, to check if a point is in an ellipse, rather than to graph one.

So yes, for the most part, you guessed correctly. :tup:
Last edited at 2011/06/09 15:13:23 by TC42
scene.my.PointIsInEllipse = (size, pos, point, T, F)=>{{(((point(0) - pos(0))^2 / size(0)) + ((point(1) - pos(1))^2 / point(1))) <= 1} ? {T} : {F}}

Hmm... Nope. Doesn't work. I don't know.

However, renaming yours does work:
scene.my.PointIsInEllipse = (size, pos, point, T, F) =>
{{(((point(0) - pos(0)) ^2) /size(0)^2) + (((point(1) - pos(1))^2)/size(1)^2) <= 1} ? {T} : {F}}

Ah, now I get it. The denominators are suppost to be squared. How did I miss that...:bonk:
:s huh? Wish I knew c.
Last edited at 2011/07/05 00:10:01 by FuzzyLogicBrain