How do I Build a Interpreter

0 favourites
  • 4 posts
From the Asset Store
Create your own beautiful snowman in this fun game!
  • I have written a Interpreter in Javascript and other HTML5 platforms.

    What the "Players" do is connect to a website and download a set of instructions.

    I put these instructions into an array, then with a switch/case statement I call

    functions that interpret the instructions, I got from the website, and preform actions

    like draw a picture or play a sound. That way I can have one Player and many games.

    Think of it as the very old Merlin game..(1978) or these 50 in 1 games from years ago

    one interface or Player and many games.

    Where do I start? I felt if I could get the Javascript-SDK to work, I would just find how

    to do the net connection, and use the internal functions to preform the instructions.

    As a newbie I am at a loss.

    I want to use Construct2 because of the cross platform abilities.

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This isn't really a beginner topic and since you said you've made an interpreter before you likely know better than I on how to make one but here is a way to do it.

    https://dl.dropboxusercontent.com/u/542 ... reter.capx

    It's an interesting idea but it's probably better to just make the games in C2 and have one project that opens links to the other games.

  • RoJohound thank you for the file.

    I really need the other 3 parts.

    Connecting to website.

    Getting data into an array ( and with new Beta having better memory management) this will work better.

    and looping through the array to pass the data to functions.

    your example is good, but very very simple, compared to our instructions.

  • 1. Look at the AJAX object for a way to download files from websites. I hear you can get more complicated communication if you make the website with PHP, but that's outside the scope of what I'm interested in.

    2. You can either convert the text to an array with a for loop and using tokenat() and tokencount() kind of like in my capx, or you can directly add the commands to the array with the push action, one word at a time. After it's all in an array, you can use the array.asJSON expression to get a text representation of the array. In fact you can save a file with that to your website and use the array's download action and bypass the ajax object.

    3. My capx was a simple example case of this. You'll have to add events to handle every function you want to use.

    Overall the process to make an interpreter is much like doing it in any other programming language. It can get as advanced and complicated as you like.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)