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 / Converting Tier 1 code to Tier 2

Author
Message
blueFire
13
Years of Service
User Offline
Joined: 23rd Jan 2011
Location: North Carolina
Posted: 17th Jan 2012 03:28
If I have an entire application written in Tier 1 code is there an easy way to convert the code to Tier 2 code so it could be compiled as native code and not use the player?

Jason
anwserman
12
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 17th Jan 2012 03:35 Edited at: 17th Jan 2012 03:36
Short answer: No.

Long answer: No. You'd still have to manually convert everything, but you'll at least be able to use Tier1 as a reference for how the program should function once it is working in Tier2.

(It's easier to convert working code into another language than it is to code from scratch. You at least have the luxury of having a reference point to test the new code against)

Hi there. My name is Dug. I have just met you, and I love you.
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 17th Jan 2012 14:14 Edited at: 17th Jan 2012 14:17
Hi there. I was writing a translator for this exact purpose but there are a few problems with doing this. You can find the thread here. Basically the issue is that some of the platforms AppGameKit deploys to have an in-built loop that you have to put your code in. I seem to remember Meego was one and possibly iOS another... What this means is that all your game code has to be in a callback function that is called every loop. To make tier 2 cross platform, TGC have created a clever template that acts as a wrapper for this system on platforms that already have it and implements this system on platforms that don't like Windows. What I'm getting at here is that whilst my translator (normally) manages to translate the code correctly, it can't easily translate in to this very rigid structure and you would suffer from the same problems if you were translating manually. Let me give you an example.

If you had this code in tier 1:



it could become this code in tier 2:



but if you had this code in tier 1:



then you couldn't easily translate it because you have two loops. Manual translation might become something like this:



but as you can see, this is a pretty major rewrite even for a very simple bit of code.

So basically, you can use my translator to translate the code to save you doing it manually but you'll still have to mash it up so that it fits the template or accept that you will only every deploy to those platforms that don't have the same requirements. I should also point out that I'm not actively working on the translator at the moment because this issue seems to me to have greatly reduced its value although I'm happy to help out with using it and fixing anything if you actually want to have a go with it. Hope that helps.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 17th Jan 2012 16:08
Yes, the translator is still a BIG time saver!

The translator should convert line by line, and then one has to manually cut & paste code into app::Loop() and app::Start()
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 17th Jan 2012 18:05
Quote: "Yes, the translator is still a BIG time saver!"

Thanks .

Quote: "The translator should convert line by line, and then one has to manually cut & paste code into app::Loop() and app::Start()"

You can currently do this with the translator (although it probably needs quite a bit of stabilising) but the problem is that unless your app runs in just one main loop, it will probably be considerably more complex than simply cutting and pasting the output code..

Anyhow if people are interested in using the translator in this way or have any ideas on how I can get around this issue, I'd be happy have another look at it.

blueFire
13
Years of Service
User Offline
Joined: 23rd Jan 2011
Location: North Carolina
Posted: 18th Jan 2012 03:38
In your second example you took two separate loops and turned them into an "if" and an "else if" statement. Wouldn't it work better if you used a literal interpretation of tier 1 code and created two loops instead of the if/else if statements.

Your original tier 1 code example:



Might be better translated as:



You would have to make sure the original tier 1 code had some kind of way to exit from each loop (the above tier 1 code example does not have a way to exit the second loop). Then simply place all the tier 1 code (including loops) inside the main game loop. Would this not work?

Jason
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 18th Jan 2012 09:37 Edited at: 18th Jan 2012 12:03
Quote: "Would this not work?"

The problem with this translation is that the Loop function is not like the body of your tier 1 code. Instead, it is itself inside a loop. Putting another main loop inside this essentially causes the app to hang because it is like having an infinite loop somewhere inside your main loop. There is other platform specific code that must be run to handle things such as inputs. Thus, if you try your code, on most platforms, you will find that you will never be able to exit the first loop because GetPointerPressed() will never be 1 until the code outside of Loop() has had a chance to run. The implementation of the App class is different for each platform but the general idea is that it works like this (this wont actually run and isn't a real implementation):



Sorry if the C++ isn't quite right; I've not checked it. Anyhow from that, you should be able to see how putting your main loop inside your Loop() function will cause the app to hang on some platforms.

For some platforms, by hacking about with the AppCore file or its equivalent, you can do a direct translation and where possible (and where I have a platform of the right kind to test on) my translator will do that too. However for most of the exciting platforms like iOS and Android, this approach doesn't work because this structure is an integral part of the SDK. At least, that is my understanding of it. Hope that clarifies but please to query it if you think I'm wrong here.

sovr
14
Years of Service
User Offline
Joined: 2nd Jan 2010
Location: USA
Posted: 19th Jan 2012 03:12
I developed a tier 2 to tier converter. I can make a tier 1 to tier 2 software software... What type of tier2 are u talking about?

sov the game creator!
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 19th Jan 2012 09:18
Quote: "I developed a tier 2 to tier converter. I can make a tier 1 to tier 2 software software... What type of tier2 are u talking about?"

If by which type of tier 2 you mean which platforms; the ones that were causing me trouble were Meego, Android and iOS I think because they enforced this loop structure. I got the Windows and Mac ones working because they did not require it. So is your translator available for people to use? Could you provide a link?

blueFire
13
Years of Service
User Offline
Joined: 23rd Jan 2011
Location: North Carolina
Posted: 20th Jan 2012 01:03
I am also interested in converting Tier 1 code to Tier 2 code for all platforms currently supported by AppGameKit (and all future platforms supported by AGK).

If you have a link I would also like to try your converter.

Jason
sovr
14
Years of Service
User Offline
Joined: 2nd Jan 2010
Location: USA
Posted: 20th Jan 2012 04:48 Edited at: 20th Jan 2012 04:57
well I am in development of a tier 1 to tier 2 converter. The programming language will be done in java. I will get back with all of you for when I have a workable program (it be in alpha stage when released for testing)... If I would of known this was so popular I would have worked on this program sooner.

here is the link for the previous tier 2 to tier converter... I forgot whether it worked or not:
http://forum.thegamecreators.com/?m=forum_view&t=192979&b=41

cheers!

edit:
I did my first major test, and I made it so it would replace endif's to } and do loops to do{}while, I am very close on placing agk:: before each command... here I put the download on this post!
ohh yea only the ios selection works, and make sure you put the jar and bat file where the source code is, and use the .bat file as the application startup file (with the jar in the same directory).

sov the game creator!

Attachments

Login to view attachments
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 20th Jan 2012 09:20
@sovr
I'm certainly interested in your project. I hope you don't mind me asking though but how are you going to deal with the problem that I outlined above? After all, my translator already does a literal translation of all of the structures available in AppGameKit Tier 1; the problem is making that compatible with all the different platforms..

blueFire
13
Years of Service
User Offline
Joined: 23rd Jan 2011
Location: North Carolina
Posted: 23rd Jan 2012 00:58
I done this little test.



This is Tier 1 code but it worked not only on the player running on my pc but also on my android tablet.

It is a loop inside a loop. The Android has a way to get input inside a loop.

Maybe the Android is a multi-threaded operating system where one thread is running the app while another thread is checking for input. Either way I do not see why the above example would not work in Tier 2 C++ since it worked with Tier 1 basic.

Jason
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 23rd Jan 2012 08:37
@blueFire
So you only ran that code in tier 1, right? In which case I would not have expected a problem. Tier 1 is interpreted through a native app which deals with this kind of thing. Tier 2 however is a native app and needs to deal with it itself. If the code didn't work in either tier; translation would not be a problem. The issue is that it does work in tier one so people will wonder why their translation to tier 2 doesn't work.

blueFire
13
Years of Service
User Offline
Joined: 23rd Jan 2011
Location: North Carolina
Posted: 24th Jan 2012 01:46
Correct, I ran that code in tier 1 only. I am still trying to get my computer set up to build tier 2 code and when I do I will try putting a loop inside a loop on tier 2 and see what happens.

Until then is there anyone else reading this thread that could convert the sample code below to tier 2, build it and then try it on a device to see if it works?



Jason
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 27th Jan 2012 00:38 Edited at: 27th Jan 2012 00:39
A thought (for fun). The whole thing would work if you had a special construct within the ::Loop function that could break out of the function to do what needs to happen outside the master AppGameKit ::Loop function, but then when it returns to the function jump right back to where it left off. Naturally this means no local variables (unless you want to store and restore their states), but something like this might allow a relatively smooth conversion:



Obviously it needs work with the 'return' preceding 'condition', but you get the general gist.

You can populate with as many loops and sequential instructions all day long, but the converter knows the loop constructs and inserts them in a switch case to form a basic state machine, with the same behaviour as a T1 app, but in glorious T2

I drink tea, and in my spare time I write software.
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 27th Jan 2012 08:26
Thanks Lee! That's pretty inspired. I'll see what I can do!

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 27th Jan 2012 13:33
A stack (like Lua - hint) would do this nicely.

-- Jim
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 30th Jan 2012 17:20
here is a thought how about a teir 2 to teir 1 convert. Probley won't happen but, just a thought. Only way this would work is if you didn't put any special C++ functions in your program.

Go through yourself at a wall.
sovr
14
Years of Service
User Offline
Joined: 2nd Jan 2010
Location: USA
Posted: 30th Jan 2012 17:33
well I did make a java program to do that... it is apart of the posts above, there should be a link (forgot if it worked or not). If you are converting tier 2 to tier 1... well by not having specific c++ code in it is a very good thing to do. You could program certain comment commands into the tier 2 so the converter software can understand what the C++ code is doing and replace it with agk tier one code that does a similiar function. Example:



and then the converter program will output:


It would be a lot of work but can be done

sov the game creator!

Login to post a reply

Server time is: 2024-04-19 05:07:25
Your offset time is: 2024-04-19 05:07:25