Topic: [Suggestion] Vector maths and some commands

it's been a while since i used this API, i hope i'm in time with this suggestion.

i've been growing fond of vectors, given that they function like a variable with multiple values. so i'd like to suggest support for vector variables, storing from 2 up to 4 values. arrays work good so far but are harder to grasp. so here's what i think:

let "$vectorvariable = vector2(x,y)"

or

vector3(x,y,z)

or

vector4(r,g,b,a)

usage scenario:

let's say we implement color-shifting effects on sprites (instead of using an image with alpha < 1) we'll call it blend_sprite, for now.

let "$blending = vector4($red, $green, $blue, $alpha)


blend_sprite $blending

If the vector input was vector3 or vector2 or even a normal variable,  the last values would not be used or changed.

this would be a fancy way to change the overall color and alpha of a sprite.


you want to easily give a trajectory to an object, that may depend on more than one force.

we all know the command

move X Y

so, suppose we are making an top-view racer. we would want to input various forces in X/Y planes. For this we would probably need something like a function that would work with trigonometry, using sin/cos, deg2rad or rad2deg, etc, because i must say, that was a tough nut to crack.

so perhaps,

angular_movement(velocity, destination)

destination would have to be a vector2 with the X and Y position of the motion destination, from which the rotation would be automatically calculated.

Reference: the new shot system, in the sources of SD.

if we could crunch that nasty calculation into one easy to use command, that would be neat smile

manipulating vector values through scripting would then allow more dynamic trajectories and physics. operating various vectors into one final movement vector would do this, and i'd be glad to help, scripting objects making use of this dynamics, for use in the Open Surge Game.

I once read a suggestion from Jobro suggesting some "Angry Birdesque" elements, and to do that we would need vectors and angular_movement for efficient scripted physics.


last but not least, with so much vectors we may eventually need a single value from a vector. so, for example:

let "$var = $vec3.Z"

let "$vec2 = $vec3.YZ

or just being able to call $vecN.* when a value is asked, like in variables. N is the number of coordinates. vec is a name to represent this example. not necessarily would we have to use such name.

Last edited by KZR (2012-10-05 19:27:43)

https://image.ibb.co/kuSYrm/SD_sml.pnghttps://image.ibb.co/kHq8P6/SeD_sml.pnghttps://image.ibb.co/cJf8P6/LTot_W_sml.png

Re: [Suggestion] Vector maths and some commands

Also would be nice if they put the command "quit_game."

Re: [Suggestion] Vector maths and some commands

I know, I saw your topic and I agree.

https://image.ibb.co/kuSYrm/SD_sml.pnghttps://image.ibb.co/kHq8P6/SeD_sml.pnghttps://image.ibb.co/cJf8P6/LTot_W_sml.png

Re: [Suggestion] Vector maths and some commands

vector math, okay. smile

http://opensnc.sourceforge.net/wiki/index.php/TODO_List

Re: [Suggestion] Vector maths and some commands

pardon me for asking so much, but would we get angular_movement as well? I mean, all that vector/radian complex calculation in one code function. That way, even mid-level scripters could have a way into complex physics without the initial shock of "OH SO MANY MATHS".

https://image.ibb.co/kuSYrm/SD_sml.pnghttps://image.ibb.co/kHq8P6/SeD_sml.pnghttps://image.ibb.co/cJf8P6/LTot_W_sml.png

Re: [Suggestion] Vector maths and some commands

KZR wrote:

pardon me for asking so much, but would we get angular_movement as well? I mean, all that vector/radian complex calculation in one code function. That way, even mid-level scripters could have a way into complex physics without the initial shock of "OH SO MANY MATHS".

I think this thread poses a very reasonable request, but I before taking any further actions, let me ask a few things. I don't fully understand what angular_movement means, nor what is the motivation behind it. What is it?

We have

so, suppose we are making an top-view racer. we would want to input various forces in X/Y planes. For this we would probably need something like a function that would work with trigonometry, using sin/cos, deg2rad or rad2deg, etc, because i must say, that was a tough nut to crack.

and then

Reference: the new shot system, in the sources of SD.

Both scenarios use some math, but they are very different things. What is the demand here?

so perhaps,
angular_movement(velocity, destination)
destination would have to be a vector2 with the X and Y position of the motion destination, from which the rotation would be automatically calculated.

If by 'rotation' you mean angle, you may simply use atan2().

--------------

edit

maybe we can break down the request into two

1. a new decorator:
angularMove $velocity $angle

2. a new function, which will return the angle formed between the object and a destination:
angleTo($destination_x, $destination_y)

with 1., you can make a racing-car movement. Combining 2. and 1., you get a shoot system.

Last edited by Alexandre (2012-10-08 03:53:32)

Re: [Suggestion] Vector maths and some commands

that sounds like a reasonable plan, maybe vectors aren't so needed after all.

My guess is that the brick_*() functions in conjunction with that can produce some very good 2D physics, both in sidescrolling and in topview.

https://image.ibb.co/kuSYrm/SD_sml.pnghttps://image.ibb.co/kHq8P6/SeD_sml.pnghttps://image.ibb.co/cJf8P6/LTot_W_sml.png

Re: [Suggestion] Vector maths and some commands

KZR wrote:

that sounds like a reasonable plan, maybe vectors aren't so needed after all.

well, okay
http://opensnc.sourceforge.net/wiki/ind … List#Tasks