Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2012-10-05 19:20:36

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

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


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#2 2012-10-05 19:24:49

MatheusRRR
Member
From: Rio de Janeiro, Brazil
Registered: 2012-10-05
Posts: 335
Website

Re: [Suggestion] Vector maths and some commands

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

Offline

#3 2012-10-05 19:28:11

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: [Suggestion] Vector maths and some commands

I know, I saw your topic and I agree.


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#4 2012-10-05 21:01:45

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: [Suggestion] Vector maths and some commands

Offline

#5 2012-10-07 10:13:53

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

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".


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#6 2012-10-08 02:15:20

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

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)

Offline

#7 2012-10-08 15:11:18

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

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.


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#8 2012-10-09 12:57:23

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

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

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org