# Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

### AppGameKit Classic Chat / Calculate velocity vector?

Message
Posted: 29th Aug 2021 02:47
So given the below situation, I want the sprites to meet at the target location, my code works but I don't understand something, at first they were going off in the wrong direction it seemed to be 90 degrees off so I minus the 90 and sure enough they go where I want them to ... but why?

Anyone good at Pythagorean theorem care to explain?

and the helper functions from UCF project

Is it my code that's wrong or the helper functions, I thought I had a grip on the basics of pythag so I want to understand what's up here, yes it works but superglue and duct tape is not my style, not without some WD40 andway .. lol (engineers joke, if it moves and it shouldn't, duct tape, is it doesn't move and it should, WD40)
Open Source plugins
Cl - DnD Plugin

#### Attachments

Posted: 29th Aug 2021 05:03 Edited at: 29th Aug 2021 05:06
does THIS help?

specifically:
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
Posted: 29th Aug 2021 05:14
Yes it does, the ATanFull is the missing link, thanks for that ... I'll work that into my code on tomorrow's epic coding shift lol
Open Source plugins
Cl - DnD Plugin
Posted: 29th Aug 2021 13:54 Edited at: 29th Aug 2021 13:56
You can simplify your distance function a lot. You can lose all of those if conditions because the result will be the same.
The distance between two points is the same regardless of their position relative to each other.
Posted: 29th Aug 2021 16:10
Yeah I actually got your simpler function in my Utils lib but when my code did not work I started scrambling around looking for solutions and google pointed me to the UCF project and some pythag that went straight over my head, I went with the UCF but I knew it was all wrong hence the post, funny thing my original attempt was almost right lol

Thanks for the help though, I actually use that function quite a lot.
Open Source plugins
Cl - DnD Plugin
Posted: 30th Aug 2021 16:47
A bit of detail on how atanfull can be calculated:

Additionally, I might have some stuff here you may find useful: (don't judge harshly, the site started in the DBC days!)
http://zimnox.com/dbcc/?page=eq
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Posted: 30th Aug 2021 18:03
Quote: "don't judge harshly"

Ouch, my eyes!! lol

Thanks for that looks like a wealth of information there, will give it a good look over for sure.
Open Source plugins
Cl - DnD Plugin