How do I Correctly Manage Variables

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello, this is my first post -- I have two days ago installed Construct to try to build myself an application to quiz myself on anagrams. I have gone through the first tutorial and have read much through the examples.

    I am discovering that it is most fortunate I have at least a little programming background for what I am trying to accomplish here. Still, it has been a decade since I have done any programming, so this is very new to me. I have a database of words and their anagrams (and sub-anagrams), and will explore some of the json and ajax options with that soon, but for now, I am only trying to get the most basic of functionality.

    So far, I have managed to build this quiz, which I just manually put the key word and their anagrams in two global variables, and then check for user input in the TextBox. I first have a section that does the validation that I found in another tutorial.

    An event is set for when a user hits 'Return' key to check the entry, and using find() I compare and either append the guess value into a 'correct' text box object or incorrect text box object. Next, I just want to check for duplicate answers, but a question in my mind about best approach here has come up about variable use.

    I do not see how to easily set local variables (and should I be using local or global?) . I created the 'guess' variable and assigned it to the textbox in my current project. Is this best practice? How can I see this variables in the Event viewer? I will want to create other variables such as timer and number of guesses. Where should I declare these? (Am I using 'or' logic correctly here? What about if/else? What is the best tutorial to understand logic flow building here?) I don't have objects colliding that cause events, just correct and uncorrect guesses that I want to time and keep track.

    I hope my questions are not too vague -- I'm just trying to get a sense for building a word guessing game, and the logic seems more complex than the graphics based game tutorials -- I want to make sure it is easily managed as I continue to work on it, and thus my first question of correct variable use. Many thanks for helping me get started in the right direction.

    -KB

    Screen Shot

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For your question about local or global variables, I'll invite you to check out the manual article as well as the "Variables (Local/Global/Instances)" section from the "How do I FAQ". The elements listed there should provide answers to your questions.

    As for your remark on the graphic versus text logic, it's kind of true.

    Game logic is game logic, and it's one of the most difficult aspect of programming no matter what.

    Construct 2 provides a better graphic base and is designed to make it easier to handle graphical "behaviors". Nevertheless you can still do text manipulation (as you've found yourself using tokenat). It's a bit more advanced than beginner "platform game making" with C2, but still manageable.

    I'd say the next step in your game/program is to take advantage of the dictionary/array so that you can have more words/anagrams available within your game.

    Your next step is to "feed" the variables Anagram and Words with datas from one of the two aforementioned plugin.

    Keep up the good learning and work.

  • Why dont u use an array to stock all those words?

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