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.

Author
Message
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 17th Nov 2011 07:39 Edited at: 27th Nov 2011 07:21
Hi there. As a result of a discussion we were having over on the ADG thread, I started work on a translator to translate AppGameKit BASIC script in to C++.

The translator itself is a pretty brutal command line utility but I threw together this GUI for it:

Naturally this can be improved upon but the translator itself is more important at the moment.

It can currently translate AppGameKit BASIC in to C++; albeit with a quite a lot of glitches. Next thing I hope to work on is getting greater integration with each platform. There are currently some problems with detecting inputs due to the need to hack around the nice App class structure offered in the templates. As it stands, you have to integrate the C++ with the AppGameKit templates manually which can be pretty challenging... I hope to automate it or at least add some help files but that's all for the future.

I'm also keen to open source this because I'm pretty sure that having some more experienced programmers take a look at my codes would make a big difference to the quality of code output! However I have no experience whatsoever of open source. I wondered if anyone knew anything about Google Code or SourceForge and could recommend whether I should upload my codes to one of those or whether it would be better just to zip them up and attach them to a post? I'd guess it's around 2500-3000 lines at the moment but I haven't counted.

So to give you an example of what it does at the moment, this agk script:


Becomes this C++ code:

As you can see, there are some issues with white space here. I will try to sort this too but again, I'm putting working code ahead of everything else at the moment. And just for the record, the program I'm using as a test at the moment is around 1500 lines of AppGameKit BASIC and it translates with only 4 compiler errors. I'll try to post some more substantial code here soon.

I'm keen to get people's help, comments and advice with this, particularly with regard to the best way to integrate the code automatically with the AppGameKit templates. I'm also trying to deal with some issues with strings. AppGameKit strings behave like C++ strings so I've translated them as such but unfortunately, agk functions take and return char arrays instead which is causing some issues.

You can download the current version HERE. This is a pre-beta indev version and I make no claims whatsoever about its current quality or usability. It's really just for the curious at the moment. Back up your codes before you subject them to it!! To use the GUI, you'll need Python 2.7 and wxPython.

Anyhow as I say, I hope this will be useful. Please do give comments & criticisms.

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 17th Nov 2011 10:46
This looks great Lucas! I haven't tested it yet as my C++ knowledge is very limited so I can't provide a lot of helpful feedback in these early stages. But I look forward to the completion of this project.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 17th Nov 2011 22:39
very useful tool
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 20th Nov 2011 02:17 Edited at: 20th Nov 2011 02:18
Thanks for the support!

I've been working as I said on automatically integrating the translated code with the project templates. I've now got the basic example from the first post to translate in to a full VS2010 project that can be compiled without any manual modifications. Now the infrastructure is in place, I hope to extend this to the other platforms. And of course start bug fixing on more complex projects.

Here's the latest screeny:


I've updated the link in the first post to point to the new version. Please feel free to give it a try but again, bear in mind that this is an InDev version so back up everything first!

Also I'm currently leaning towards uploading to Google Code because I've heard it's good for smaller projects like this but I'm still open to suggestions from anyone with any experience of these.

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 27th Nov 2011 07:21 Edited at: 27th Nov 2011 07:23
Sorry for the gap since the last post; not got much time to work on this atm. So since the last post, I've added templates for VS2008, and XCode 3 and 4 for Mac OS X. I've also worked on support for multi-file projects. I've not actually been able to test VS2008 or XCode 4 but given how similar to VS2010 and XCode 3 they are respectively, I'm hopeful that they'll work. I've also been looking in to automatically integrating game assets such as sounds and images. They are now moved across with your project but at the moment, you still have to manually add them to XCode projects before they'll be detected. Hopefully I'll be able to make it entirely automated eventually.

Several issues have also arisen. One is the continued problem of strings. If anyone can think of a neat way of detecting when an AppGameKit command is returning a string or taking a string as a parameter and wrapping it in a function converting to/from the string class respectively, then please do say. I'm struggling to sort that one myself. Another issue is that the structure of the templates is very different to an AppGameKit Tier 1 project in that it has Start(), End() and Loop() functions that are called when the app feels is appropriate. Therefore to get the sequential code written for Tier 1 to work, I've had to hack around the templates a bit. This is easy enough for the PC and Mac but I'm finding that the Meego and iOS templates are much harder to deal with because the calling of the Loop() function is inside another function like paint() that is itself called from a hidden main loop. I wondered if anyone with more experience of these platforms could suggest a way of integrating sequential code and removing the need to have your main loop in a callback function.

I've updated the link in the top post to the latest version but it's still obvious an InDev version.

Rampage
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: New Zealand
Posted: 27th Nov 2011 08:26 Edited at: 27th Nov 2011 08:48
This is really interesting. I feel so silly to have gotten so far in my project in T1 when I am really a C++ person by heart.
So something like this may inspire me to make the transfer

Although the version you uploaded doesn't open up at all on my computer
EDIT: Never mind, just saw requirements. Sorry
EDIT2: Installed those two things and still doesn't run

Regards,

Max
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 27th Nov 2011 09:27
Wouldn't it be simpler to just convert the T1 source into T2 source line by line, and then let the individual edit the source into Start(), End() and Loop() to fit his need?
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 27th Nov 2011 16:35 Edited at: 27th Nov 2011 16:37
Quote: "Installed those two things and still doesn't run"

What are you trying to run? Do you get any errors? You need to run the .py file if you want the GUI.

Quote: "Wouldn't it be simpler to just convert the T1 source into T2 source line by line, and then let the individual edit the source into Start(), End() and Loop() to fit his need?"

Well, it would be simpler for me! In fact you can do this already simply by selecting the CPP option in the GUI rather than any specific project type. This will just output cpp files and you can integrate them manually. The problem of course it that it involves a lot of code changes if you have more than one main loop in your program as most people will do.

Rampage
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: New Zealand
Posted: 28th Nov 2011 00:25
Quote: "What are you trying to run? Do you get any errors? You need to run the .py file if you want the GUI."

I run the .py file and a console window pops up for less than a second, then disappears.
No errors.
??

Regards,

Max
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 28th Nov 2011 01:54
Hmm, you must be getting an error in the GUI script. If you've got the time, could you create a batch file with the following code in the same directory as the .py file and run it? That way you should be able to see the errors.



Rampage
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: New Zealand
Posted: 28th Nov 2011 05:30 Edited at: 28th Nov 2011 05:31

The import error I spose'? Some of the long lines like files directories and stuff got cut off for some reason.

Regards,

Max
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 28th Nov 2011 06:33
Looks like a Python or wxPython error. Are you running a 64 bit machine? Does this help?

Thanks for testing .

Rampage
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: New Zealand
Posted: 28th Nov 2011 08:03
Not a problem. It was a mistake on my part, I went back and found the 64bit version of Python I installed that. Everything works now

Good work

Regards,

Max
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 28th Nov 2011 16:31
Quote: "Everything works now"

Yay!

But maybe I shouldn't have made the GUI in Python, given that it has all these requirements. I did it because it was very quick and really I've only been working on the command line utility that actually does the translation but when I get a moment, I could write a new GUI in something that could be compiled to be stand alone. Thanks for the support!

Stormwire
13
Years of Service
User Offline
Joined: 3rd Sep 2010
Location:
Posted: 1st Jan 2012 21:37
Ill give it a shot when you get the new gui done. I am sick of Python and all its requirements lol Looks like a excellent project mind. I hope you finish it
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 30th Jan 2012 12:08
Quote: "Looks like a excellent project mind. I hope you finish it"

Thanks for the support .

Sorry it's been a long time since the last post. I got kind of disheartened over the loop issue that was stopping me translating for the most interesting platforms like iOS and Android so I gave up for a bit. However then, none other than Lee himself came to my rescue with this suggestion so I've started having a look at the translator again.

I've converted the GUI to Swing so hopefully that will make people's lives easier (I'll upload it with the next update so it's not available just yet).

However before I push on too much with this, I had a quick question for anyone still following this. How do you see yourself using the translator? The two main ways that occur to me are:
1. To convert a project that you started in Tier 1 to Tier 2 because you realised that you needed something that only Tier 2 offers
2. To convert a completed Tier 1 project to Tier 2 for compilation and deployment without the need for the AppGameKit player

I ask because so far, I've been developing mostly for option 1, meaning that I've been emphasising mimicking the way your code is structured over getting every last detail correct. Thus, at the moment,you would have to make a handful of corrections before the code compiles but the code should look reasonably similar to yours in structure. This also means that if your Tier 1 code was readable, your Tier 2 code should be as well. However having investigated Lee's solution and created a proof-of-concept app (and it's the only solution I've seen that works) I think it will create extremely ugly and unreadable spaghetti code. I'm pretty sure I can get it to compile and run as expected but I don't think people would like it if they planned to continue development in Tier 2 as per option 1. So would people still be interested if the translator was more aimed at translation simply for compilation (option 2) rather than translation for continued development in Tier 2? If you could give me a feel for how you would use this, it would be a great help.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 30th Jan 2012 12:14
Lucas, great to see you working on this!

Personally I would not worry about getting the code to look like the original code. Get it to work (as much as possible) and any half decent programmer will be able to work it out as long as you keep variable names etc. similar enough.

I see the translator as a quick way of converting a project for 1 or 2, either way the code will need to be re-organised to suit the structure of the native language. If you can get it close then you'll be simplifying the process, which is all anyone can hope for.

Keep up the good work!

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 6th Feb 2012 18:22
Thanks for the support baxslash. However I'm afraid I must admit that this project has stalled again. I quickly put together an implementation of the translator that I hoped would work. However I'm currently unable to test the output code because my Visual Studio installation has gone horribly wrong. I frittered about 3 hours away trying to resolve the problem and was unable to and I just don't have that sort of time at the moment to devote to fixing it. Just to re-emphasise however that it is not a problem with the translator or with Lee's suggested method; it's just that I can't test that it works until I can get Visual Studio back up and running. Sorry for the continued delays but I do mean to continue to work on this.

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 7th Feb 2012 16:56
Hi again. OK so I've "resolved" the Visual Studio problem. In fact I have no idea how I fixed it. I think my computer just felt sorry for me after a while and did what it was meant to. Anyhow back on topic..

I've tried a basic implementation of the translator that basically aims to output compilable tier 2 code. However as mentioned earlier, this code is not really suitable for editing as it produces enough spaghetti code to allow you to run a small Italian restaurant for several months. Just in case you think I'm overstating the case, here is an example:

This tier 1 code:


Becomes this tier 2 code:


If you test them, you'll see that they do exactly the same thing. However as you can see, the second lot of code is very ungainly. I've not got a lot of time at the moment but I intend to continue development along the lines I'm currently going, that is, to output compilable code that should need as few alterations as possible. However if anyone has any thoughts on this as opposed to a more readable output or anyone can come up with a better way of translating multiple main loops (possibly inside functions), then I would be open to suggestions. Once I'm reasonably happy with the stability of this version, I'll upload it but I've not done so yet.

bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 9th Feb 2012 17:05 Edited at: 9th Feb 2012 17:07
This looks great. I'd personally use it as option 2, rather than 1.

If I want to code in c++ I'll do it myself, but I'd want a converter for speed reasons or to compile without the player (or for specific fixes)

I think it'd be killer if there could be some sort of preprocessor system that we could utilize. For example, some way to put c++ code straight in AppGameKit tier 1. Perhaps a custom IDE that works just like T1, but allows c++ code and when compiled, actually uses GCC or some other C++ compiler.

Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 10th Feb 2012 08:31
Thanks for the support . Given what people have said then, I'll definitely continue down the current rout of outputting compilable code.

Quote: "I think it'd be killer if there could be some sort of preprocessor system that we could utilize."

Good thought; I'll see what I can do!

Kezzla
15
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 11th Feb 2012 05:27
just found this thread, this converter would be a lifesaver!

I'd use it for your option 2: to convert a completed project for easy deployment.

definitely worth pursuing.

I will buy a copy.


Sometimes I like to use words out of contents

Login to post a reply

Server time is: 2024-04-25 06:26:03
Your offset time is: 2024-04-25 06:26:03