Stencyl 3.4.0 is now out. Get it now!

"EasyMath" Extension

Photon

  • Posts: 2697
Hey all. I'm interested in the potential there is in writing 3.0 extensions, so I decided to start writing up a simple one to get my feet wet.

That being said, there are some math calculations that we use a lot, so I thought this would be a good place to start. Here is what I'm planning/have done so far:

  • max/min among values in a list
  • average among values in a list
  • distance between two points/actors
  • angle between two points/actors
  • overall speed and angle of movement of an actor

Feel free to suggest more.

Download

« Last Edit: November 01, 2015, 05:18:21 pm by Jon »
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

rob1221

  • *
  • Posts: 9005
Quote
max/min between two values
This block already exists (smaller/larger of __ and __).

Photon

  • Posts: 2697
Quote
max/min between two values
This block already exists (smaller/larger of __ and __).
*facepalm*

Wow. All right then. :P

Max/min of list values might still be useful though... unless I glazed over that too.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

SadiQ

  • Posts: 1704
You could convert some of the functions from flash.Utils as they are pretty useful (clamp is one of them).
Be warned with rand() as it's buggy, so if you have a function that relies on it, it probably won't work as expected (shuffle will fail for now).
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Photon

  • Posts: 2697
I haven't really used the flash.Utils before. What do functions like clamp do or where can I view a good description for said functions?
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

SadiQ

  • Posts: 1704
Most functions have some small description written within the Utils.hx file. If some function doesn't provide one you could probably google for the name of the function as most coders use some "standard" name for well known functions.
 Clamp usually keeps a value between a min and maximum value(useful to keep the paddle within the playing area in the game of PONG )
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Photon

  • Posts: 2697
Version 1.0 of my EasyMath extension is finished. It is attached to this post.

  • Find the maximum, minimum, or average of values in a list.
  • Find distances and angles between either points or actors (using x/y center-points for actors).
  • Also find the angle as well as the magnitude of an actor's velocity.
  • Designate radians and degrees for angle values without having to use an extra block.

This is the first time I've done much with Haxe, so feel free to bring something to my attention if I messed up. Enjoy!
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

betofantasioso

  • Posts: 75
I'm using it already. It's awesome thanks Photon!

spoogob

  • Posts: 1106
I'm making good use of this so far - thanks!

LIBERADO

  • *
  • Posts: 2137
 :) Thanks you, Photon, I am using it. This extension will be useful for many users.

« Last Edit: June 26, 2014, 12:22:50 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

LIBERADO

  • *
  • Posts: 2137
(I am spanish, please excuse my bad english)

.........so feel free to bring something to my attention if I messed up. Enjoy!
Ok. If you accept suggestions, then I have a question:

About the blocks "angle from [Actor] to [Actor]" and "angle from (x,y) to (x,y)", I have tested them to set the direction of an object, and I have seen that the object is moving in the opposite direction that I expected, then I have noticed that in this block the vertex of the angle correspond to the second (x, y) field.

That's right?? I thought that it should correspond to the first (x, y) field.

In "angle from...... to......", the word "from" appears to refer to the origin of the angle, and I think that the origin of an angle is its vertex.

I do not know if I'm explaining well what I mean. Please, see the image attached to this post.

« Last Edit: June 26, 2014, 08:10:33 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

Aykay

  • *
  • Posts: 53
I cant figure out how to install this

Justin

  • *
  • Posts: 3702

For Live Support: Join our discord channel and ping me @justin.

MrMusiqua

  • Posts: 5
Umm...I'm not seeing a download button. Is this extension still available?

Justin

  • *
  • Posts: 3702

For Live Support: Join our discord channel and ping me @justin.