nuffsaidny's Forum Posts

  • 3 posts
  • Hello all,

    I'm developing 4 video games to help build cyber security awareness among high-school kids. For one game I'm taking them thru a series of steps which help them in creating a strong password. One of the steps requires them to enter the acronym of the phrase they entered initially and I need a way for the game to validate if they entered the correct acronym before allowing them to move forward.

    Basically I'm trying to write a function to "acronymize" text entered into a textbox by the user via the keyboard.

    For example, if the user enters the phrase "hey what's cooking good looking", initially, this text is saved to text variable say "UserPhrase", then the user is prompted to enter the acronym of this phrase, the game/function should compute the acronym of this stored phrase and compare it to the acronym entered by the user, if it is correct, a corresponding text object should display the result which in this case would be "hwcgl" and allow the user to move forward in the game.

    I know how to carry this out in C++ but I am having a high degree of difficulty translating it to Construct 2.

    #include <iostream>

    #include <string>

    #include <cctype>

    using namespace std;

    string acronym(string str);

    int main()

    {

    string str;

    while (true)

    {

    cout << "\nPlease enter a string: ";

    getline(cin, str);

    if (str == "")

    {

    break;

    }

    cout << "\n\nThe acronym is \"" << acronym(str) << "\"" << "\n";

    }

    system("PAUSE");

    return 0;

    }

    string acronym(string str)

    {

    string phrase = "";

    phrase = str[0];

    for (int i = 0; i < str.length(); i++)

    {

    if (str == ' ')

    {

    phrase += str[i+1];

    }

    }

    return phrase;

    }

    Can anyone show me how to achieve this using Regex?

  • Hello all, I'm designing a game to help build cyber security awareness. The game is called Password Wizard and is intended to help players learn how to create a strong password.

    The Game:

    Players must help a wizard defend his castle from the evil Undead Knight and his minions by following onscreen steps to create a password spell before they reach the castle.

    The steps for making the password are as follows:

    Step 1: Have user enter a short phrase that's familiar to them/easy for them to remember

    Step 2: Have them make the phrase into an acronym

    Step 3: Have them capitalize every other letter

    Step 4: Have them replace all the letter A's with the symbol

    Step 5: Have them replace all the letter E's with the number 3

    Step 6: Have them replace all the letter I's with the symbol !

    and so on... which would eventually result in a very strong password.

    The part I need help with is validating the entries made by the user. For example, when they are asked to enter the acronymized version of their phrase, I need the game to be able acronymize the original phrase and compare it to what they entered. If it is correct then let the user move on to the next step.

    Similarly for the other steps, when they replace all the letter A's with the symbol, I want the game to swap out all the A's for symbols in the text and compare it to what they entered. If it is correct then let the user move on to the next step.

    I know how to write a function to carry out the acronymization in C++, but I am having difficulty translating this into Construct 2. This is the C++ code I have:

    #include <iostream>

    #include <string>

    #include <cctype>

    using namespace std;

    string acronym(string str);

    int main()

    {

    string str;

    while (true)

    {

    cout << "\nPlease enter a string: ";

    getline(cin, str);

    if (str == "")

    {

    break;

    }

    cout << "\n\nThe acronym is \"" << acronym(str) << "\"" << "\n";

    }

    system("PAUSE");

    return 0;

    }

    string acronym(string str)

    {

    string phrase = "";

    phrase = str[0];

    for (int i = 0; i < str.length(); i++)

    {

    if (str == ' ')

    {

    phrase += str[i+1];

    }

    }

    return phrase;

    }

    -----------------------------------------------------------------------------------------------------------------------------------------

    This is my attempt at translating it to Construct 2:

    UserPhrase and Acronym are both text type global variables initialized at the top.

    The text object that is being set to Acronym is just my way of verifying the output to the screen after I type in the phrase.

    Here is the current result of this attempt:

    I'm not sure where my logic is going wrong, also to reiterate, I am new to Construct 2 and I'm not very verse in all its functionality. If anyone can shed some light on my situation it would be greatly appreciated. I really want to see these game thru and let kids at the high school nearby test it out and enjoy it.

    Best regards.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey my name is NUFF.

  • 3 posts