Randomly Generate Sequence of Images (Memory Game)

0 favourites
  • 6 posts
From the Asset Store
Match the similar cards with each other and free all animals!
  • This post and question is more about the foundation approach for a game that I am working on. I have a multiple word phrase/sentence that I would like to move players through one correct word at a time. I would like to show 1 right answer per screen or sequence and two incorrect answers.

    In the end the game will be either a 3 lane side scrolling game or a 3 lane vertical game where you move the player to the correct lane and shoot something at the word. If you get it correct you move on. If you don't then you move backwards or start over.

    I think the answer lies in a arrays and sprite sheets but would love to grab some direction as I am new to the game dev world and programming logic to be honest. I have read a few things on arrays in the forums and I am starting to grasp them but with the added functionality I am looking for it makes things steeper in terms of learning curve.

    I envision a sprite sheet with 3 columns and multiple rows pending on the sentence length. The first position of every column would be the correct answer and the other columns would be incorrect.

    Each screen would have 3 locations or image points. I want to randomly generate the correct answer and two wrong answers for each image point. Doesn't have to use image points if that does not make sense however it felt like the a great starting point.

    If the correct answer is chosen then I would like to load the next word in the sentence randomly at 1 of the 3 image points next to the two wrong answers.

    Any links to relevant articles. Suggestions on approach, etc. would be great. I don't expect anyone to do the work for me but would like a more solid concept or something to chase down and figure out as I am lacking the programming logic skills to understand the best approach.

    Any resources or books would be appreciated on how problems like this or other game problems are solved would be amazing as well.

    Sorry for the longer post and thanks for the time spent reading it.

  • well, i did't understand very well how you picture the gameplay but it looks like is about correct choice and wrong choice, so a few things to help you start:

    forget about arrays (for now); the concept of arrays helps but only if you know how it works and how to apply to your project. stick with the basic and simple logic.

    now lets think about your concept

    start making the choices; write or wrong answers, with the mechanic you want (shooting on then)

    put down the possible questions and the correct answers

    now you can make the set of questions a unique sprite with lets say, 20 questions and each question a frame of the same sprite

    make the same thing with the answers (each frame a answer)and then compare the question frame with the answer frame

    for the randomness you can make the sprite with random frame at the start of the layout, this way is a simple progamming pick random frame;

    ps: using this metod you have to make sure that it will be always a right answer to choose and diferent questions on each column. you can do this using variables

    this is not very polish but i hope this give you a starting point :]

  • Sorry for the delay in responding back to your reply. I really appreciate the ideas. However, I am still having a hard time implementing. I am trying to figure out the best way to clearly state my goals or plan. I will do my best to clarify.

    Here is the idea. I have a sentence that I am wanted the player to build one word at a time. To build the sentence the player must move to one of three lanes and choose the correct answer. So each sequence has one correct answer and 2 incorrect answers. I would like to do a few things here.

    1) Randomly generate the location of the correct and incorrect answers for each word in the sequence.

    2) Randomly generate the incorrect words for each sequence.

    Here is an example for a 5 words sentence...

    Word 1 in sequence: correct word 1 - wrong - wrong

    Word 2 in sequence: wrong - wrong - correct word 2

    Word 3 in sequence: wrong - correct word 3 - wrong

    Word 4 in sequence: correct word 4 - wrong - wrong

    Word 5 in sequence: correct word 5 - wrong - wrong

    Does your method still apply here after a little more clarification, or at least what I hope to be clarification.

    Thanks again for any time spent replying!

  • s000.tinyupload.com/index.php

    maybe you can learn from this.

    What it does:

    on start -> save sentences to array (I'd suggest using the CSVtoArray-Plugin, so you can write your sentences in excel, save the table as .csv and then import the csv-string into the game)

    after that the sentences are split up word by word and each word is saved at y=1, y=2 and so on of the array.

    So for one sentence the array would look like:

    x=0, y=0: I like to watch TV

    x=0, y=1: I

    x=0, y=2: like

    x=0, y=3: to

    x=0, y=4: watch

    x=0, y=5: TV

    The keyboard controls will be easily understandable for you. (A or Space shoots, later on in the sheet left and right puts the player to the lane to his left/right, if not at the edge already)

    The group spawnsentence sets the sentence that is next to spawn by randoming a number. The number represents the x in the array, which you later on will access. It also activates the group that is supposed to spawn the words on screen. It also disables itself to prevent a new sentence from spawning till all words are spawned by the spawnwords-group.

    Spawnwords-group. Uses the word-variable to detect which word it is at (word will chose where the word is taken from in the array). It selects a random lane by randoming between 0 and 2 to spawn the right word and the text that contains the right word gets the instance variable rightword set to 1. This later on helps to detect whether you hit a correct or a false word.

    For the lanes that are not filled with a word yet, a function to spawn false words is run, the function parameter tells the function where to spawn the word.

    False words get the variable rightword set to 0. False words are selected with a while-loop, where the system looks at a random word in the array and compares it to the right word. If the two words are not equal, it uses this word for the false text. If they are the same it looks up a random word again. In case you don't want "can" and "Can" to be detected as different words, use lowercase() for the while-condition.

    The rest of the events is kind of straight forward again. Hit detection, text movement, increasing difficulty over time, scoring based on difficulty (so later on you get more points), substraction of lives, game over display, removing the most front sentence from the sentence display after 5 words have been shot or passed the destroy-mark.

  • Thanks for your time putting this together. Really excited to see it and learn what you have done here. Sounds like I am going to be able to utilize the concepts mentioned for sure.

    Side questions. Where did you get the r147 version. I am developing in a team and assume you picked up the beta of that at some some point. I found the download but since we are in the middle of live projects I don't want to have the other members of my team upgrade if the version is not stable. We are on r146 stable as seen in the download area of the site.

    Thoughts? and thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I upgraded it too the beta because I wanted to view another capx from this forum that was using it. Ofc better stick to the stable version for development. You can install the beta separately without uninstalling the stable version if I am not mistaken.

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