frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

Simon mechanics? Record and duplicate a sequence.

Hi all. I’m trying to replicate a “Simon” game. You know the one. 4 buttons and an ever increasing pattern the player has to replicate.

I’ve figured out how to make the four blocks fire randomly once. And if the player hits or kisses that one they win or lose. My question is: how do I add to the pattern. Record that pattern and then check if the player has replicated it? Suggestions? Theories?

Comments

  • edited January 12
    Hey @todorrobot - there are a couple of ways to do this. One way would be to store the sequence in 4 different Number blocks, then compare the result using 4 different filters.

    Another way, that would use a lot less logic, would be to use a programming trick to convert the integers 1-4 into a String data type, so that they get appended instead of added.

    When adding string data, 1+2+3+4 becomes "1234" instead of 10. In an Expression, if you add an empty string ("") to a number, the whole expression becomes a string. This means that you can can use an expression to store a sequence of incoming numbers by appending them.

    Here's an example that generates 4 random numbers and stores them as a sequence: https://flowlab.io/game/play/1068003 (Press space bar to generate and store the sequence). You could then compare that using a filter to the sequence that the player tries.

    Let me know if anything isn't clear.
  • I’m interested in learning how to use strings for saving sandbox info.


    The question is.... how?
  • What do you mean by sandbox info?
  • edited January 12
    Well, take for example terraria. The world is generated, and you can make modifications to the world yourself throughout the game to complete certain objectives.

    Building a house for example.

    How would we save each individual tile’s position Along with type?
  • I'm not sure if I'm understanding you, but games like Terraria and Minecraft do not store the position of each block. They use a value to "seed" a (pseudo) random number generator. The PNRG will then return the same sequence of "random" values, and these are used to choose and position world blocks.

    If you wanted to save modified blocks, I suppose you could have the blocks store and load their own modifications. This seems like it could potentially be pretty inefficient though, I'd need to think about this a bit more.
  • edited January 13
    I was actually wondering how to input strings, because Wizardry made that typing concept way back, and I was wondering how I would type back. This could be used to make usernames, save files or multiplayer game tags. Would a string get saved by the "Save" number function?
  • I imagine, it is still just a number after all
  • Thanks @grazer ! That got me a little farther but I still think I’m in over my head on this one. It does open up some cool possibilities and I’m going to play with it some more later and I’ll let you know where I get hung up.

    I’ve only just started using the “expression” function. I never would have known about that “string” thing. Is there a resource out there that explains some of the capabilities and uses of this block?
  • Wow!!! @CrimsonBlackGames & @grazer, is there a way to save tile placement, or, in fact, any data at all?
  • edited January 13
    I mean technically, if you want to be extremely technical, you could make a game where you place tiles by a grid position lock, then have a save button that has a block move from tile 1, 1 all the way to the end of your map, then wrap to 2, 1 and so on going horizontal, then wrapping down, and on collision or whatever, having each tile send its X and Y number to the main memory computer object on the GUI, and add those grid numbers to a string. If you had a string for x and a string for a y, string 12345 X and string 11111 Y would spawn the tiles when you load the game at 1, 1 then 1, 2 then 1, 3 then 1,4 then 1, 5. That's how you would spawn and save tiles positions, but then you need another string to tell each tile what type of tile it should be. Yes, it is possible, at least I see no reason it wouldn't be, depending on maximum string length. The only issue is I can't really think of how you would do anything bigger than a 9 by 9 map, because 10 and higher would still add to the string and be misread as 1 0 1 1 1 2 1 3 1 4 etc instead of 10 11 12 13 14. If you can get past that, it could work.
  • I dont know how to use a save block!
  • edited January 13
    PS this is for my game Terraria V3.2, which I am remaking because of massive size and lag.
  • @todorrobot - the Expression block is just intended for mathematical expressions, outlined in the behaviors handbook here: https://flowlab.io/behavior_handbook/#logic-math-expression

    The string hack I posted above is due to the fact that the Expression parser understands the Haxe programming language. The trick just takes advantage of that fact to cast the values to a different Haxe datatype. This is not something that is really intended or documented anywhere.
Sign In or Register to comment.

flowlab.io

| make games in your browser
@ 2017 Flowlab.io, All rights reserved.

Contact us

Get In Touch