AllanR's Forum Posts

  • Alon

    in the sample I made, there were only 3 fields for the characters: total_slots, Active_slots, and CharacterName. So with only a few fields like that, it would probably be easiest to set 3 global variables after choosing the character. And then set the player's character from the global variables.

    if the player was picking a team of characters, then an array would be a good option.

    to use a hidden sprite to hold the selected character's variables, you would have to make that sprite a global object (in the Object Type Properties). Then it would still exist on each additional layout...

    I just tested that idea out, and actually, that would be a good way to do a team of characters too - easier to work with then an array.

  • Alon

    I would use instance variables on the character - much easier to keep track of how many a character can have, and how many they do have.

    I put the Used_slot animation in the Active_Slot sprite, and renamed it Orb. Then there is only one type of object to worry about, and you can tell its status by what animation it is playing. The orb has an instance variable telling which character it belongs to.

    at the start of the layout, it creates all the slots for each character, and makes the correct number active...

    https://www.rieperts.com/games/forum/orbs.c3p

  • yeah, that tells php to insert the correct control characters...

  • Fengist

    newline is essentially a variable for the control character that causes a line break. So when the text is read from the jason, it only sees the characters the spell newline, not the actual control character (which is Hex 0D or something like that)...

    so, when you assign the text, you need to use Replace.

    Set Text.Text to Replace(jsontext, "newline", newline)

  • john Cutter

    impossible to say without seeing your code...

    I wouldn't think the image size would be a problem.

    those are well hidden eggs! I found 8 before I decided I should get back to work...

  • klabundee

    to do a nice 3d flip like your image shows, then newt is correct - and I am pretty sure I have seen an example (probably by ROJOhound) on how to do it a couple years ago.

    another cheap effect you can do is adjust the width down to nothing, then bring it back up to the card width. It doesn't look as nice, but takes very little processing power, and no plugins...

    and if you do it fast enough, it is hard to tell the difference.

    https://www.rieperts.com/games/forum/cardflip.capx

    my sample has a deck of cards from a tutorial I saw years ago that has a nice shuffle example and other ideas to get you started on a card game... not sure if the tutorial still exists or not.

  • you can also use "Set Vector X" to do a dash (it is limited by the max speed, so you would also have to increase max speed for the duration of the dash).

    platform can do just about anything and handles a lot of the work for you. You can turn off gravity, change the angle of gravity, and lots of other things to achieve whatever you want...

  • Sofa_King

    another comment is why do you need to re-shuffle the temp array, when the act of picking 4 answers randomly from the larger array already puts them in a random order?

    if you still have trouble. make sample file with the json data, the 20 item array, the temp array, and the 4 text answer fields. It is much easier to help when we have something to work with - and seeing the actual data can quite often lead to suggestions you might not have considered.

    To me, the top image in your first post looks like it should already be giving you a shuffled result, and it deletes the picked answer so you shouldn't get duplicates.

  • Sofa_King

    he is subtracting one in the first event because arrays are zero based... so if the array has a width of 10 (10 values stored in the array), then those entries will be numbered 0 to 9.

    the routine starts with the LAST entry in the array and picks a random entry up to that point in the array and swaps the values. And then does the second last one, etc...

    so at the end of the loop, each value in the array has had a chance to be swapped at least once.

    the tempValue variable is a text variable, so it will work with text values.

    if you don't have the -1 as shown, you could end up swapping with a value outside the array limits - which would probably give you a zero value.

    to walk through the logic: (for an array with 10 items)

    the first time the loop runs, loopindex will be zero, so randomindex will be int(random(10-0))

    note that random will pick a number up to, but NOT including the limit you give it, so in this case it will pick a number between 0 and 9.9999... and then take the integer portion (to give you a number between 0 and 9).

    then it sets tempValue to the last entry in the array (which is 10-0-1), and then swaps that value with the randomly picked entry.

    then the loop repeats, loopindex will be 1, so randomindex will be a number between 0 and 8, and the second last entry (10-1-1) is swapped with that.

    repeat, loopindex will be 2, randomindex will be 0 to 7, swap with (10-2-1) or 7th entry

    The final time the loop runs, loopindex will be 9, so randomindex will be 0, and it will swap with itself (10-9-1).

    This guaranties that every item in the array has had a chance to swap with another position in the array.

    EDIT: just looked at your shuffle code, and the reason it was not working is that "pick" could choose the same value multiple times, and that would result in loopindex getting overwritten in the array, and then you would also have at least other array value never getting set. You would have to use a method that must pick a unique value. (the tutorial you linked to put 4 values in a temp array, and then deleted the picked value each time through the next loop so it could not be picked again).

  • jobel

    I did that version a few weeks ago when someone was trying to make a large universe... so I thought I would try to make a system that was infinite but could have different space regions ready to scroll on to the screen based on where you were.

    that is why I added the Z key to zoom out, and the C key to show solid colors so he could see how the tiles rotated under you...

  • You do not have permission to view this post

  • jobel

    I was working on a sample when oosyrag and newt made their suggestions - and came up with something very similar.

    I dont remember a spaceship behavior, but my sample works the way I think a spaceship should without any shake at max speed...

    https://www.rieperts.com/games/forum/spacebackground2.capx

  • jogibaer5000

    event 4 refers to all instances. so they all will add 2 to their Y position.

    if you want to have them move in different directions, you have to decide what the rules are for their movement, and then set up a way to tell each one what it needs to do, and there are many ways to do that.

    you could give them Bullet behavior and give each one a random angle and bullet speed when they are created. Or you could give them each an instance variable that tells them what type of object they are, and make rules for each type. you could loop through them using a For Each loop and always have the first instance do one thing, the second something else, etc...

    I adjusted your sample slightly to give them each a random X and Y speed.

    there are lots of other ways - you just have to get your head around all the various ways to "Pick" the instances so you can tell each one what to do...

    https://www.rieperts.com/games/forum/movesprites.capx

  • Alon

    I would definitely put them in a family.

    A global variable is fine, but you can also check EnemyFamily.Count any time you need to know how many there are as well.

    I usually try to keep the number of global variable down to as few as possible. I use instance variables and built in features like .Count, and .PickedCount, etc...

    it helps keep things organized.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I didn't see your sample file, so I am guessing, but when you use Create Object, the new instance does not get added to C2's internal list of objects until the next top level event after the event that created it. That means that it can not be picked or referenced in other functions until then.

    (Calling a function looks like it is on a different top level event, but the function is really just extending the event that calls it, and functions don't remember any picked objects).

    you can pick a new object by its UID, so if you have to call another function to do something to the object, you have to pass the UID as a parameter, and use that to pick it. Using instance variables, or anything else wont work immediately after the object was created.

    adding a "Wait 0 seconds" tells C2 to not execute actions after the wait until the end of the current tick - and by then new instances are available to be pick using all the other normal methods.