Posted: 20th Dec 2011 3:55
Hi guys,

Just wondering if there is any built-in commands for handling 2D vectors? I ran around in the documentation looking for it, but can't seem to find anything. I'm not the best coder, so I'm not really sure where to start if I need to manage them myself. I know with DBpro we had MakeVector or something like that...is there a similar command for AppGameKit?

If not, is there some way I can understand a little more how to create a vector data-type myself? I understand the direction and magnitude stuff...I think.

Any help would be great!

Cheers,
Greenlig
Posted: 20th Dec 2011 5:08
There are no built in commands for AppGameKit tier 1.

Here is an example for coding them yourself.

+ Code Snippet
type vectortype
    x as float
    y as float
endtype

v1 as vectortype
v2 as vectortype
v3 as vectortype


v1 = setvector(1.0, 2.0)
v2 = setvector(3.0, 4.0)
v3 = addvectors(v1, v2)

do
    print(str(v1.x))
    print(str(v1.y))
    print(str(v2.x))
    print(str(v2.y))
    print(str(v3.x))
    print(str(v3.y))
    sync()
loop

function setvector(x as float, y as float)
    vector as vectortype
    vector.x = x
    vector.y = y
endfunction vector

function addvectors(vector1 as vectortype, vector2 as vectortype)
    vector as vectortype
    vector.x = vector1.x + vector2.x
    vector.y = vector1.y + vector2.y
endfunction vector
Posted: 20th Dec 2011 18:54
http://forum.thegamecreators.com/?m=forum_view&t=192569&b=6
Posted: 21st Dec 2011 0:58
Fantastic, from both of you.

Thanks heaps guys!

Greenlig
Posted: 21st Dec 2011 9:48
Nice share Phaelax! Handy work there, thanks!