Yann's Forum Posts

  • aragon

    Instead of digging very old unrealated topic you should create your own really (: (it's not because someone mention loop that it's related to your issue)

    Now if you want an answer we need to be able to open your capx, and since it's full of third party plugin, it's a real pain (I don't want to install plugins)

    If you can't really get rid of them, try posting a screenshot of your event sheet.

  • aragon you should avoid posting the same question on different places. (it's not a likeable behavior). Moreover, your question is on a totally different subject.

    This current topic is a bug report on the interaction between function plugins, local variables and while loop. While you're asking something about php and AJAX mostly.

  • The speed of the platform behavior is always limited by the Max speed property.

    One way to make it work is to do something like:

    playerCollision: Is animation attack playing
        local number attackSpeed = 0
        local number defaultSpeed = 0
        playerCollision: [invert] Is mirrored
            ->System: set attackSpeed to 9000
        playerCollision: Is mirrored    
            ->System: set attackSpeed to -2000
        -> System: set defaultSpeed to playerCollision.Platform.MaxSpeed
        -> playerCollision: set Platform maximum speed to attackSpeed
        -> wait 0.2 seconds
        -> playerCollision: set Platform maximum speed to defaultSpeed

    Be carefull, since you probably didn't know about the max speed issue, you probably set the speed way to high since it was always clamped to max speed which default to 330...

  • Never really understood why (:

    Anyway I only ever use inclusion when I really need the same piece of code in 2 (or more) different event sheet, which is pretty rare since either I use one layout/event sheet for the whole game, or I use the same event sheet on every gameplay layout

  • About the start of layout issue, there's this rule to keep in mind:

    "Start of layout of included sheets always happen before the start of layout of the current event sheet even if it's placed after."

    For your other issue, I would need to see at least a screenshot of the conserned events.

  • About your dt issue, you can do an "every x second" this way:

    +Every ticks
       -> add dt to timer
    +timer >= x
       -> substract x from timer
       -> do things
  • Sprite: Set angle to self.Angle + dt*360/(24*60*60)

    should rotate the sprite a 360� per 24hours

  • Yeah random(a,b) gives you a random number in the [a;b[ range. For global variables, as soon as you nest them under an event or a group they become local variables and their scope is only in this event (and related sub-events) or group. Now, if you set your local variable as static, they will behave like global variables (meaning their value won't be reset at each tick) As far as boolean goes, inded you can't have boolean global variables. But you know, booleans are just 1 or 0 under the hood. If you really want to use TRUE and FALSE instead of number, you can still define them as constant of value 1 and 0.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • By the way InvaderX... You should use loops when you repeat things

    +On start of layout
        +repeat 14 times
            -> create Tree on layer 1 at (random(1024),random(1024))
        +repeat 10 times
            -> create Wall on layer 1 at (random(1024),random(1024))
  • Hm, the thing is, you're not really using Arrays here. You just put some instance variable on the array and use these.

    Every object can have instance variables. It's not really what arrays are for (:

    Also, I think that your expression could be simplified this way:

    newPrice = round(formerPrice * random(0.85,1.20))

  • The dictionnary object is quite simple, I even think it's simpler than the array object.

    It just associate a key and a value.

    if you do

    Add value 3 at key "myNumber"

    you can retrieve it by doing

    Dictionnary.Get("myNumber")

    The same way you do Array.At(anyNumber)

    But since the key is a string, you can do all kind of tricks by formating the key to fit your needs.

    Like:

    Add value "My awesome dialog here!" at key "arc_day_timeOfDay_place_theInteractive_characters_Objects_Items_Default_AutoDialog"

    if you do

    dictionnary.Get("arc_day_timeOfDay_place_theInteractive_characters_Objects_Items_Default_AutoDialog")

    it will return "My awesome dialog here!"

    So in a way you'll emulate a multi-dimensionnal structure.

    The only downside is that you don't know the size of each of the dimensions... (unless you keep track of them yourself (:... in an array for instance)

  • I don't remember what is my example but you can keep a list of sound, and pick randomly without repetition like that:

    +System: On Start of layout
       -> Array: set size to (0,1,1)
       -> Array: push back soundA.wav on X axis
       -> Array: push back soundB.wav on X axis
       -> Array: push back soundC.wav on X axis
       -> Array: push back soundD.wav on X axis
       -> ...
    
    +On whatever
       local number randomIndex = 0
       -> System: randomIndex = floor(random(Array.Width))
       -> Audio: play sound Array.At(randomIndex)
       -> Array: delete at index randomIndex)

    The delete function of the array object delete the value at the index and shrink the array by 1 to fill the gap. So the Array.Width will decrease until you played every sound in the list.

  • I can work it out without array I think, but it would be a real pain (tonnes of conditions)

    I think a good start is to have a kind of conversion table.

    cardConversion.At(0,0) = "ace"
    cardConversion.At(0,1) = "hearts"
    
    cardConversion.At(1,0) = "ace"
    cardConversion.At(1,1) = "diamonds"
    
    ...
    
    cardConversion.At(52,0) = "king"
    cardConversion.At(52,1) = "spades"

    What would you use that for?

    Well the idea is that you would have all the card images in 52 frames of a card sprite in exactly the same order.

    And thanks to this cardConversion array you'll be able to know the rank of the suit of any given card through it's animation frame.

    cardConversion.At(card.AnimationFrame,0) will give you the rank of the card

    cardConversion.At(card.AnimationFrame,1) will give you the suit of the card

    Now you can just lay down the starting position of the cards in the layout.

    And you'll just have to find a way to randomize the animation frame of each card without duplication.

    But it might become a pain to maintain the deck itself.

    So maybe yeah, an array just for the shuffling of every cards,

    Then you distribute the card in this shuffled array by changing the frame of the cards laid out, and deleting the value in the array each time (with the delete function so your array shrinks at the same time) and then you'll be left with your randomized starting cards plus a cool deck array to cycle in (:

    Then it's just a matter of coding the rules of the game.

    like if you drop a card on a given column, check that the rank or the last card of the column (highest Y position)is the current card's rank + 1 and that the suit is the other color (you can try another kind of conversion table to answer this question or work it out with just conditions)

    Then valid the move or not.

    Same kind of thing to move the card on the 4 suit slots on the top right.

    So yeah you'll need array and some bits of good knowledges of C2, but no complex math (:

    So yeah good luck

    (An yeah, power bumping makes you look like a jerk, and also often makes people not willing to answer you... So be carefull)

  • I think if you want better performances you should work with arrays not objects. Unless you're not using a grid based graph (?) otherwise array is probably the optimal datastructure.

    But to answer your question, the "foreach ordered" on top of looping over all instance, probably runs a sorting algorithm before (which behind the scene probably compare each instance with each other at some point so you have like a hidden nested loop).

    Maybe should just do a simple foreach like that:

    +on whatever
        local number lowest = 99999 
        local number lowestUID = -1
    
        + system: foreach object
        + object: variable < lowest
            -> system: set lowest to object.variable
            -> object: set lowestUID to object.UID
         
        + object: pick by UID lowesUID
            -> do whatever
  • Oh new version is already up!

    Alright I tested the capx I provided and my good old maze capx, all is working super fine thanks (:

    (that won't stop me from continuing to torture these functions though mwahahahah!)