Yann's Forum Posts

  • Wreckless

    My code is pretty straight forward and work as you asked :

    You have place spawnpoints in your layout. Just some instances of an sprite named 'Spawnpoint

    'Object' is the object you want to randomly spawn.

    Then it goes like this:

    +System: Every 7 seconds

    All the following will be triggered every 7 seconds

      Local number rndCount = 0

    I create a local variable. This local variable is accessible only under the System: Every 7 seconds event I just talked about and reset to 0 each tick

      -> Object: destroy

    I destroy the object I placed on the canvas to begin with a clean slate (but maybe you want to keep them, in this case you should only put this line under a System: On start of layout to delete the default one)

      -> Spawnpoint: set occupied to false

    I forgot to add that, it's important to reset the boolean to false to be able to pick the spawnpoints. But you shouldn't add this line if you don't destroy the Object

      -> System: rndCount = floor(random(5))+1

    Our aforementionned local variable gets set to a whole number between 1 and 5

    This number is used to know how many repeat loop we will trigger and consequently IS the number of 'Object' that will be randomly spawned.

    Maybe using a local variable is not necessary and you can directly put the floor(random(5))+1 in the following repeat loop. But I wasn't sure.

      +System: repeat rndCount times

    All the following will be triggered rndCount times before even updating the display. So you'll see rndCount 'Object' instantly appear randomly placed

        +Spawnpoint: [invert] is occupied

    Spawpoint has an 'occupied' boolean variable. I use this variable to filter only inoccupied spawnpoints to avoid two objects being spawned on the same spawnpoint.

        +System: pick random Spawnpoint instance

    Amongst the filtered Spawnpoint (the order of condition is then super important), I pick a random one.

          -> Spawnpoint: Spawn object on layer 3

    I make the randomly picked inoccupied Spawnpoint, spawn the object at its place.

          -> Spawnpoint: set occupied to True

    You set the occupied boolean to true to flag the Spawnpoint as occupied and avoid picking it again.

    +System: On start of layout
      -> Object: destroy
    +System: Every 7 seconds
    Local number rndCount = 0
      // optional //
      -> Object: destroy
      -> Spawnpoint: set occupied to False
      //////////////
      -> System: rndCount = floor(random(5))+1
      +System: repeat rndCount times
        +Spawnpoint: [invert] is occupied
        +System: pick random Spawnpoint instance
          -> Spawnpoint: Spawn object on layer 3
          -> Spawnpoint: set occupied to True
  • Ugotsta

    It lakes only one thing: setting the slider position given a value. For now it only do the opposite.

    All

    You're welcome \o/

  • slice them!

  • When you slice the fruits, destroy the physic's fruit object and use another object to display the anim without any behavior (or just something to make them fall like the bullet behavior with a downward speed)

    Even if you don't use Fruits, that should work!

  • here's an implementation of the selection sort algo

    selectionSort.capx

    more details on wikipedia holder of the truth of the universe

    http://en.wikipedia.org/wiki/Selection_sort

  • Unless just squashing a page with a dumb scale, you'll probably need to create a turning page animation to play as a transition.

    ... as kirby said... (ninja'd \o\)

  • Damn I like it, with families it's so much neater.

  • There's not, a work around would be to set a repeat loop with a high number and to break this loop when the while condition would have become false

    +System: repeat 1000 times
      -> do things
      + while condition becomes false
        -> break loop

    Then it's just a matter of knowing what is the maximum loop your games need.

  • SullyTheStrange

    You're way is ugly :D... But indeed pretty neat for the question asked

    However I would add another global variable that goes from 0 to 1 once one!=two!=three

    To tell the game "ok the variables are now good we can continue"

    You made me realize there's indeed a while in c2... The gameloop itself (:

  • hide the cursor and make a chainsaw sprite follow the mouse coordinates

  • There's no while loop in c2.

    The only sure way I know to do a sampling without replacement is to make a list of your sample, pick one at random, delete the sample from the list.

    I showed an implementation not long ago.

    It went a bit like that:

    global sampleCount = 3  // number of... number you want
    +System: on start of layout
      -> Array: set size to sampleCount,1,1
    +On What you want
      Local text list = "0,1,2,3,4,5,6" 
      +repeat sampleCount times
        -> Array: set value at loopindex to int((tokenat(list,floor(random(tokencount(list,","))),",")))
        -> System: set list to replace(list,str(Array.At(loopindex)),"")
        -> System: set list to replace(list,",,",",")
        -> System: set list to (left(list,0,1) = ",") ? right(list,len(list)-1) : list
        -> System: set list to (right(list,len(list-1),1) = ",") ? left(list,len(list)-1) : list

    The four last actions are used to delete the token from the list string. This way you don't pick it again.

        -> System: set list to replace(list,Array.At(loopindex),"")

    Delete the token leaving the comas

    1,2,3 -> ",2,3" or "1,,3" or "1,2,"

        -> System: set list to replace(list,",,",",")

    Check if there's two comas side to side and delete one

    1,2,3 -> ",2,3" or "1,3" or "1,2,"

        -> System: set list to (left(list,0,1) = ",") ? right(list,len(list)-1) : list

    Check if the first character is a coma and delete it

    1,2,3 -> "2,3" or "1,3" or "1,2,"

        -> System: set list to (right(list,len(list-1),1) = ",") ? left(list,len(list)-1) : list

    Check if last character is a coma and delete it

    1,2,3 -> "2,3" or "1,3" or "1,2"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I updated the capx with coloring. You just need to put a source in instead of a destination out

    Anyway there's no facebook object in my capx

  • I added a trick, To know what is the height of a full heart, I place 2 images points on the heart outline. One for the empty position, one for the full position. I then calculated the height between them and use it as a min/max for the height of the blood mask.

    You just have to replace theses image points and calculate the difference between imagepointX instead of imagepointY... Well send the capx if you don't succeed

  • w00t ninja'd

    Cassianno

    They are all listed in construct when you have to type an expression you should have a window (F4 if it's hidden) with all your layout object, and one of them is "system", if you double click on it you'll see all the system expression available.

    Else, you can also read this page of the fabulouse manual

    http://www.scirra.com/manual/126/system-expressions