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 / AGK V2 Alpha 7.1, Media Free - Compass Code

Author
Message
Jammy
21
Years of Service
User Offline
Joined: 15th Jan 2003
Location: Scotland
Posted: 9th Oct 2014 22:48 Edited at: 9th Oct 2014 22:49
I was playing with AppGameKit V2 Alpha 7.1 and its sensor commands. Much like the excellent tutorial that has now been published in the newsletter. I decided to make a compass.

AGK V2 makes it so easy. Most of the code is to create the graphics. There is no media needed - just copy and paste the code.





I tried to make it rotation independent, but the trigonometry got too complicated for me. If you can work it out it would be nice if you can post the solution.

Attachments

Login to view attachments
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 10th Oct 2014 01:24
If you use the device resolution;

And draw the compass in a square which is the size of the shortest edge it will fit both orientations.

Every few frames check if the orientation has changed and if it has change the virtual res;


You could probably do the same in percent mode, but I don't use that so am not sure the best approach.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Oct 2014 12:10
Nice , the first thing I made in AppGameKit V1 when the sensor commands were introduced was a compass...but I didn't manage to make a medialess version.

You could add the other outputs to the same app and have a much better version of the newsletter tutorial. Anyone coding using the sensors needs something like this as a reference.

Now that it is so easy to make an APK in V2, I have the tutorial version permanently on my phone as a reference for coding.

Jammy
21
Years of Service
User Offline
Joined: 15th Jan 2003
Location: Scotland
Posted: 14th Oct 2014 01:19
Thanks Marl, However by "Rotation independent" I meant that for accuracy your device has to be flat. I believe that by using Magnetic X,Y and Z you can make it accurate whether your device is flat or not,a true 3D Compass. The mathematics of this are a bit difficult for me. Any help would be appreciated.

Cheers BatVink - I must have missed the release of the sensor commands in AGK1. I do plan and developing this further the next step is to add "Google maps" or "open street maps" using the tutorial here

I have made the compass app available on Google play for those that don't yet have AGK2 - or just search for JammySoft

Login to post a reply

Server time is: 2024-11-25 09:51:18
Your offset time is: 2024-11-25 09:51:18