SimoneT's Recent Forum Activity

  • Domse65

    Got it!

    This might not be the best way, but it's the best I have at this moment:

    Create a second Array(Array2) to store the X location on your original Array where the value 1 might be found.

    Then set value at Array2.At(floor(random(0, Array2.Width))) to 2.

    Here is a capx to help:

    https://www.dropbox.com/s/8x9qi6acmomaj ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • joeb12

    Do you have a capx to share, because it should work fine on its own.

  • joeb12

    Did you make sure to set yes to loop in your animation properties window of the sprite on the left side of the screen?

  • Domse65

    To be clear, your array has only 2 values? If so, an easy way is to use choose():

    set at value at choose(0,1) to 2

    Or you have several values of 0 and 1 and you only want to choose a random 1 value and turn it into 2?

  • Programmer25

    The BoundToLayout behavior should cover what you are trying to accomplish.

    If for some reason, you want to stop the ScrollTo behavior, you can create an invisible sprite that, when PlayerBox is overlapping it, disables ScollTo, and Else enables it.

  • rah8011

    Welcome to Construct2! I highly recommend looking up the video tutorials to get you started!

    https://www.scirra.com/tutorials/top/pa ... e=detailed

  • rah8011

    Did you go in the projects window on the right, right click on the layout folder and click on "add layout"?

  • BillAlex

    Nope, my bad!

    I skimmed your capx too quickly. I misread tilemap.PositionToTileX/Y as set position of tilemap...

    Ninjadoodle

    My way works if you are using sprites objects, and BillAlex's way works for tilemap objects.

  • Hi Ninjadoodle

    BillAlex 's way to do it works great.

    But, if you only want to change the tile's frame, not position, you can do this:

    Add 4 global variables: SwapNumber1, SwapNumber2, TileName1, TileName2.

    When you select a tile (sub event: if counter is 0) => Set SwapNumber1 to tile's UID, set TileName1 to tile's name, add 1 to counter

    (sub event: if counter is 1) => Set SwapNumber2 to tile's UID, set TileName2 to tile's name.

    (sub sub event: select tile by UID (SwapNumber1)=> set Self.Name to TileName2, set animation frame to Self.Name

    sub sub event: select tile by UID (SwapNumber2)=> set Self.Name to TileName1, set animation frame to Self.Name, set counter to 0.

    Hope this helps.

  • KHC

    That's great! Glad it worked out for you. Again, I'll be glad to help if I can on future bumps in the road. Btw, always leave the artwork for the end (it's fun, the best part for me, but sometimes a total waste of energy if your game happens to change direction whilst programming), and make lots of comments or notes about your work (it's easy to get lost in your events). And never be afraid to ask for help!

    Till next time,

    Happy game designing!

  • ErudioLtd

    Good, makotto is right. You need to create your cards, split them and then shuffle you array:

    (the +1 is your card back)

    Event 1: On start of Layout=> Set DeckArray width to NumberOfCardsInYourDeck +1

    (I am assuming that frame0 is your card back and 1 to whatever are your card faces)

    Event 2: For 0 to NumberOfCardsInYourDeck ("deck") => Create Card at X,Y (it doesn't matter yet), set Card.ArrayNumber to loopindex("deck"), DeckArray set value at loopindex("deck")

    Event 3: Compare 0 < Card.ArrayNumber >= NumberOfCardsInYourDeck/2 => set position to X, Y (pile 1)

    Event 4: Compare NumberOfCardsInYourDeck/2 < Card.ArrayNumber >= NumberOfCardsInYourDeck => set position to X, Y (pile 2)

    (Now you shuffle like in the tutorial)

    Event 5: For 1 to NumberOfShuffles => set Slot1 to ceil(random(0, NumberOfCardsInYourDeck)), set Slot2 to ceil(random(0, NumberOfCardsInYourDeck)), set Card1 to DeckArray.At(Slot1), set Card2 to DeckArray.At(Slot2), DeckArray set value at Slot2 to Card1, DeckArray set value at Slot1 to Card2

    For each Card => set Card.FaceFrameNumber to DeckArray.At(Card.ArrayNumber)

    When you flip cards: set animation frame to Card.FaceFrameNumber

    Cards created, split and shuffled!

    Hope this helps.

  • ErudioLtd

    Have you checked out kittiewan's Memory Match tut?

    She has a simple effective way to shuffle cards:

    https://www.scirra.com/tutorials/280/cr ... match-game

SimoneT's avatar

SimoneT

Member since 25 Jun, 2014

None one is following SimoneT yet!

Trophy Case

  • 10-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

12/44
How to earn trophies