How do I create a simple game similar to simon says but simpler? Newbie user

0 favourites
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I've been testing construct 3 for 5 days now and I already have a basic understanding of programming but I'm still learning. I'm having trouble creating a simon says game but simpler, because it will only show a sequence of 5 objects lighting up and the player has to repeat this sequence at once. I need to create 20 circles in random positions on a 1000 x 500 screen. My first problem is that the circles cannot overlap and also need to occupy the screen evenly. I've seen an example of simon says in construct 2 but it didn't help me much. Could anyone give me some suggestions?

  • I suggest you place the circles manually in the layout editor, and then on start of the game randomize their frames or animations. For example, if there are 20 frames in the animation and you want to display them in random order:

    System For Each Circle Order by random(1) : Circle set animation frame to loopindex
    
  • Thanks but I'd prefer to create these circles randomly. I don't know how to do it, but thinking logically, the correct thing would be to divide the area (1000x500) into four parts and create 5 circles in each area, in different positions and at a certain distance from each other. What do you think? It would be possible?

  • If you want them just to look like they were placed randomly, you can still place them manually in a grid, and then when the game starts shift them slightly in random directions.

    Circle Move random(100) pixels at angle random(360)

  • Thanks for the suggestion. But how to prevent them from overlapping?

  • Don't shift them too far, just enough to look random, but not enough to overlap.

    There are other methods of course, here are a couple of old examples:

    howtoconstructdemos.com/spawn-objects-randomly-without-overlapping-2-capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you. I will check it.

    I also have doubts about how to make the initial sequence of 5 random circles be shown at an interval of 5 seconds. I imagine you should use a loop for that. How should I identify the circles, preventing any repetitions from being shown? How to check if the user clicked on a wrong circle without waiting for the sequence to end?

  • You can use instance variables and Timer behavior. For example, create "seq" instance variable, pick 5 random circles, assign them seq values from 1 to 5.

    Start a Timer for these picked circles for (2.5+Circle.seq*0.5) seconds.

    This means that the timer for the first circle will trigger in 3 seconds, the timer for the second circle in 3.5 seconds and so on.

    Check out official examples in C3 to learn how to use Timer and other features.

  • I decided to create the objects randomly and check if they are overlapping to set a new position. As there will be times when there will be several objects, sometimes it takes a while until they are all positioned correctly. There's no way to avoid that, right?

    A problem I'm encountering is that I don't know the exact moment when the system finishes positioning all the objects, so I can start displaying the sequence. I am using this code to check it:

    + object: [X] Is overlapping object

    + System: objAmount = 22

    -> System: Set group "G22" Deactivated

    -> System: Set objAmount to 0

    -> System: Call function start

  • Have you tried that link I posted above? You can create and randomly distribute all objects pretty much instantly - in one tick.

  • In fact, I had used another one that prevented overlapping, but after you said it, I went to see it and this one also has an example that does that. It works really well, thanks.

    Regarding the sequence, would you have a link to an example?

  • Have you tried that link I posted above? You can create and randomly distribute all objects pretty much instantly - in one tick.

    I still have a problem knowing when all the objects are already positioned on the screen, even using the example you suggested

  • Events in Construct run from top to bottom. "Wait 0" means to wait until the next tick. So in my example first 30 sprites are created in event #2. Then there is a "wait 0" required to finish their creation. Then events 4-6 are distributing the sprites. So in event #7 they will already be positioned randomly without overlapping.

    Note that event #7 is nested inside #3, which means that it will also be delayed by one tick, and will run after events 4-6.

  • Thanks! I will give it a try.

    Regarding the sequence, could you give an example of this?

  • I followed your instructions but the result is pretty weird. Sometimes it shows 4, sometimes it shows 3, and only sometimes it shows 5 and it takes a long time to start

    My code:

    * On function 'seq'

    ----+ System: Repeat 5 times

    --------+ System: Pick a random object instance

    ---------> System: Add 1 to seq

    ---------> object: Set id to seq

    ---------> object: Start Timer "time" for 1+object.id×1.5 (Once)

    + object: On Timer "time"

    -> object: Set animation frame to 1

    -> System: Wait 1 seconds

    -> object: Set animation frame to 0

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