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 snippets

Author
Message
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Feb 2013 11:32 Edited at: 4th Apr 2013 17:12
I would like to start a list of useful snippets for the AppGameKit site. If you have some ideas for small examples of AppGameKit functionality you would like to see then please post them here and I will try to post 2-3 examples per week (here as well as on the AppGameKit site).

The intention is that some of the more popular questions can be answered by looking on the AppGameKit site and also it will provide an overview of how simple some features of AppGameKit are to use in practice.

So, what would you like to see a small example of? I will do my best to create examples of as many of the suggestions posted as possible.

I should probably say I'm talking Tier 1 snippets mainly but I may be able to help with the odd Tier 2 snippet too.

Snippet list:
Choose Image from device

Capture image from camera

Facebook login

Advert commands

Using particles

Date / Time

Hyperlink text

Back Button on Android

Point Sprite at mouse

Create a box2D sprite

Add virtual joystick and button

Ultrabook sensors


Examples from community:
Accelerometer control
HTTP connect and response
View Benchmark data
3D Turret firing

Requests:
Passing files across HTTP


this.mess = abs(sin(times#))
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Feb 2013 12:51
Here is a small example of the kind of snippet I'd like to make to help people understand how to use commands. Let me know if you have any commands or other examples you would like to see or any suggestions on how the examples could be improved.

Facebook login snippet (Tier 1 example):



this.mess = abs(sin(times#))
Talairina
18
Years of Service
User Offline
Joined: 9th Jan 2006
Location: United Kingdom
Posted: 21st Feb 2013 12:51
That's a great idea Baxslash. Thing's like how to pass files across HTTP, interfacing with Facebook or using the Ad commands would be great.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 21st Feb 2013 12:56
Choose Image

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Feb 2013 13:00
Thanks Markus, that's a nice snippet! If anyone else wants to post a simple snippet I can use I would be very grateful. I hope you don't mind if I simplify it for new users though. Although your version is pretty simple to adapt for an app it might not be the simplest code for a new user to understand.

Talairina, I'll see what I can do for your requests. I hope the facebook example is useful


this.mess = abs(sin(times#))
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 21st Feb 2013 15:05 Edited at: 21st Feb 2013 15:15
Accelerometer control snippet, fantastic for phone and tablet tilt controls.

Talairina
18
Years of Service
User Offline
Joined: 9th Jan 2006
Location: United Kingdom
Posted: 21st Feb 2013 15:08
They was more of a suggestion's but I do find that Facebook one quite interesting. Thank's for that Baxslash
CodeGit
19
Years of Service
User Offline
Joined: 16th Aug 2005
Location: Cyber Space
Posted: 22nd Feb 2013 08:19
This is a great idea!!!

------------------
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Feb 2013 21:07 Edited at: 22nd Feb 2013 21:10
HTTP Connect, get a URL and Show the Response$

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Feb 2013 23:58
Thanks again Markus, that's a nice snippet


this.mess = abs(sin(times#))
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Feb 2013 23:43
Very interesting

My first thought was that this is duplicating the Useful Functions thread...but it's not. The Useful Functions can be highly complex pieces of functionality, and don't have the infrastructure to run them out of the box. That's okay , as it is what was always intended.

I see this as a much needed thing too...nice simple code that just shows how it works.

Quote: "You have no friends to display"

...but that's just harsh!

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Feb 2013 09:31
Quote: "...but that's just harsh!"

You should have seen what it said in my original version

Yes, what I'd like to do with this is have some simple examples how to use a certain command or command set. I'll probably simplify it even further to just show the code you need. The FB example will just show how to log your app into Facebook, I'll split the friend list code into a separate example.


this.mess = abs(sin(times#))
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 25th Feb 2013 11:56
@Baxslash:

Although the Facebook login stuff is useful, I found the aquisition of the App ID the hardest part. A decent tutorial for that for beginners might be handy

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 25th Feb 2013 13:19
Quote: "Although the Facebook login stuff is useful, I found the aquisition of the App ID the hardest part. A decent tutorial for that for beginners might be handy "


Quite easy I presume if it is to do with the Facebook Developers site...

If it is the method I presume it to be, can someone point me at the information needed and I will whip up a video by tomorrow for everyone...

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 26th Feb 2013 00:58
@MrValentine:

I had a thread about it earlier in the month I think, I was trying to get the information to put in the FB Developers site to get the ID.

>Here< is the link to that thread.

xGEKKOx also did a thread about setting up an app for iOS and FB, but sadly, he skipped over the bit I'm stuck with (I know it's not exactly the same, but maybe it would have prodded me in the right direction)

>Here< is a link to that thread as well.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 26th Feb 2013 01:48
I managed to get my own app created but that was for my blog, it is and can be tedious at times... specially with FBs recent changes... and they update on a weekly if not almost daily basis...

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Mar 2013 13:43
I've added a simplified version of the Choose Image and Capture Image command usage to the first post.


this.mess = abs(sin(times#))
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 1st Mar 2013 17:45 Edited at: 1st Mar 2013 17:46
Great thread Baxslash. Would you consider editing your original post to include the code snippets others have posted as well (or even just links to their actual posts)? This will make it much easier to review all of the snippets as the thread grows.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Mar 2013 17:46
Yes, I'll do that if you like. I'll try to add links tonight... got to go out now!


this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Mar 2013 11:08 Edited at: 3rd Mar 2013 11:10
View Benchmark Values

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2013 14:47
I've added four new snippets to the list at the top. I will be adding more soon. They will all be up on the AppGameKit website soon too

Added:
Advert commands
Particles
Date/Time
Hyperlink text


this.mess = abs(sin(times#))
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 5th Mar 2013 17:13 Edited at: 5th Mar 2013 17:14
Baxslash: In your Adverts snippet you state "admob is currently only available on iOS"

I asked a couple days ago about the state of AdMob and Android but hadn't heard back from any TGC developer. The documentation indicates it works for Android and iOS and I have successfully created a test project with AdMob adverts on three different Android devices as well as iOS. I know Paul mentioned last year they couldn't implement Admob for Android due to the NDK but it seems like that has been solved now?

I defined two separate apps on the AdMob site, one as an 'Android App' and one as an 'iPhone App' -- using either publisher ID seems to work fine on all Android and iOS devices.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2013 17:16
xCept, isn't that just in the Beta version though? Not sure I should say it's working yet if it's not working in the latest release.


this.mess = abs(sin(times#))
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 5th Mar 2013 17:46
Yes, I'm using 1088 but I've been trying to confirm that it's at least working in that version. I didn't see any mention of Android AdMob integration in the AppGameKit change log which is why I've been wondering. Seems to work fine though.
Ravey
Retired TGC Developer
22
Years of Service
User Offline
Joined: 2nd Nov 2002
Location: Southern TGC Nerve Centre
Posted: 8th Mar 2013 11:44 Edited at: 8th Mar 2013 11:47
// Rotate a sprite to face a location



// This takes the desired resolution height of the app,
// and then adjusts the width to match the ratio of the device being
// run on. This means - no borders.



// This shows how to place a sprite in the center of the screen when the display
// has been set up using the previous code



// Takes a value and the range is belongs to and returns the result from a different range



// Get Distance



// Interpolate between to numbers, useful to smooth movement for network play etc.
// mu# is 0.0 - 1.0 to set the interpolation



// Make a QR code



// Grab an image from the screen


Dave Milton
TGC Team
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Mar 2013 11:47
Thanks Ravey Davey! There's something there for everyone


this.mess = abs(sin(times#))
Zeerun
AGK Developer
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: United Kingdom
Posted: 12th Mar 2013 16:33
Rotating a 3D turret and shooting 3D bullets from the turrets rotation limiting the rate of fire and destroying the bullet if it strays too far
(utilising a wrap180 function you gave me a while ago when I was doing the same thing in 2D )





I seek perfection but wear my scars with pride
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Mar 2013 16:52
Nice, I'll check it out later


this.mess = abs(sin(times#))
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 13th Mar 2013 10:50
Facebook commands are broken in android player 1088 ? i always include Facebook library without any problem when compiling the android player but when i use the commands with my appID (and with your code baxslash), it crashes
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Mar 2013 10:52
MikeMax, which player are you using? I didn't know we'd released a v1088 player...


this.mess = abs(sin(times#))
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 13th Mar 2013 10:53
no i am compiling the 1088 myself with eclipse works well for 3d etc ... compiled with facebook libs without any problem ... except when i want to use FB commands
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Mar 2013 10:55
Can you narrow it down to a specific command that is crashing the player and report it on the issues list?


this.mess = abs(sin(times#))
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 13th Mar 2013 10:58 Edited at: 13th Mar 2013 11:23
i will try

here is a link to my compiled player (compiled with all the libs needed .. especially facebook jar file.)

https://www.dropbox.com/s/gvagwekg3ra2wrh/AGKPlayer108b8.apk


EDIT : Seems to be the FacebookLogin() command which make the app crashes after few seconds (asynchronous command right ?)
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 13th Mar 2013 11:22 Edited at: 13th Mar 2013 11:24
Here is the FaceBook issue link (hoping that is not a specific issue from my compilation ?)

https://code.google.com/p/agk/issues/detail?id=510
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 29th Mar 2013 09:16
I've been working on a series of AI commands from Bucklands book for Autonomous agents ... would that be useful for inclusion? If so, how might they be properly packaged?

----
From the Desk of Prof Versaggi ...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Mar 2013 10:13
That would be very useful but perhaps it deserves its own post? These are really supposed to be very small examples and it sounds like your AI commands could be far larger than I really intended for these examples?


this.mess = abs(sin(times#))
RickV
TGC Development Director
24
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 29th Mar 2013 20:13
Hi all, behind the scenes I'm working with an artist to add a whole snippets section to the main AppGameKit web site. Please keep posting ideas here and when it's ready we'll start populating the main site.

Rick

Financial Director
TGC Team
RickV
TGC Development Director
24
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 4th Apr 2013 01:42
Hi all,

I have been working on the snippets page this evening. Let me know what you think.

AGK Snippets

Rick

Financial Director
TGC Team
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th Apr 2013 01:55
Very good, Rick!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th Apr 2013 10:20
Looking sharp!

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Apr 2013 10:48
Spelling my name wrong though... it's the lower class "Steven" not the middle class "Stephen".

Looks good though Rick

I'll be adding some more later today after a little bug fixing.


this.mess = abs(sin(times#))
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Apr 2013 11:41
Quote: "Spelling my name wrong though... it's the lower class "Steven" not the middle class "Stephen""


I always had aspirations above my class
Although my dad spelt my middle name incorrectly on my birth certificate, just to even things out again

The snippets page is looking very good. Please make sure it retains only snippets that can be copied, pasted and run immediately, it's the ideal format for this kind of resource. If we need more complex stuff that can't be snippetised, we can use Daniel's useful functions thread.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Apr 2013 12:26
Quote: "Please make sure it retains only snippets that can be copied, pasted and run immediately, it's the ideal format for this kind of resource."

That wasn't really the aim of the snippets originally. The aim was to give new or potential users an idea how to perform a simple / single function without all of the clutter of making an executable code example. It seems that that has become less important now that we have some fully executable code on the web page so I may need to clarify with Rick what we are trying to achieve.

Quote: "I always had aspirations above my class"

Me too


this.mess = abs(sin(times#))
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 4th Apr 2013 13:53
I totally agree about not writing the snippets in a copy and paste format. That's just lazy. The less code the easier it is to learn from them. Agk isn't a drag and drop platform is it?

This thread is like a candystore for learning! Sweeeet! Love it.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Apr 2013 16:14 Edited at: 4th Apr 2013 17:11
Point Sprite at mouse


Create a box2D sprite


Add virtual joystick and button


Ultrabook sensors


EDIT: Of course some code requires a loop to explain how it works


this.mess = abs(sin(times#))
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Apr 2013 23:45
Quote: "The aim was to give new or potential users an idea how to perform a simple / single function without all of the clutter of making an executable code example."


OK, I thought the idea was to have a piece of code that only performed the one function, but would run. So it's nice and simple as you say, and beginners can also see the result without having to know anything else. Otherwise it's the same as the useful functions thread?

I'm happy to concede I can have very slow moments, let me know where I'm going wrong

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 5th Apr 2013 01:30
The page is looking pretty good!

Quote: "Otherwise it's the same as the useful functions thread?"

I think this thread is for demonstration purposes (and we don't have to stuff it into functions) as opposed to importing ready-to-use functions into our code.

RickV
TGC Development Director
24
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 5th Apr 2013 10:55 Edited at: 5th Apr 2013 18:51
Hi,

I have updated the page and it's live for anyone who clicks on the Tutorials option from the header menu.

We'll keep adding ideas so that new users get a good sense of the commands AppGameKit has to offer when they first discover our little middleware tool!

Cheers,

Rick

Financial Director
TGC Team
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 17th Apr 2013 20:00
I know it's old, but nothing's old to newbies.

Create a Full screen tiled background

The technique is easy, it's the maths I always mess up.

Works best with devices running native resolution.
Will not work on the subimages of atlas textures
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 18th Apr 2013 01:47 Edited at: 22nd Apr 2013 20:24
Math snippets is always nice to have a reference to

Edit: If these are usable I'm positive they need some revisions

Move a sprite along a circle:


EDIT/ADD:
Move sprite along a sine wave:


EDIT: added Frequency to sine wave

Login to post a reply

Server time is: 2024-11-17 00:30:13
Your offset time is: 2024-11-17 00:30:13