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
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)