Magistross's Forum Posts

  • No problem! I'm interested to see how you implement what I just provided you though, if you're not too shy about it!

  • As a side note, the XML can indeed be loaded inside the official XML plugin. Just tried it !

  • Ok, so you indeed need a function that checks neighboring cells, but you also need another one that will find you a random spot for a particular enemy type. First, the checking function.

    Then, it might be a good idea to keep a list of each location of type of tiles. Best place to do it would be when you create your "cleaned copy". Now HOW to do it is another question. I would use multiple instances of a two-dimensional array. First, create the arrays.

    Each array has a size of (0,2,1) and it will expand as we fill them.

    Then add this when you create your cleaned copy, just under the line 13 in your events screenshot, as a sub-event of line 11. You might also want to set cave.CurValue to 1 in line 13 too, and not just in your cleaned copy.

    Afterwards, when you want to spawn your enemies, all you have to do to pick a location, is get a random position in the correct CellTypePos array, and pop it, so it doesn't get picked again.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • blackhornet However, he'll need a group of events per weapon type, and that's what he wanted to avoid with his function.

  • Maybe you could use a Dictionary along with the ship in a container (or if the ship is a unique instance, just a plain Dictionary).

    On collision with PowUpSpeed

    --- Call "WeaponLeveling" ("Speed")

    On function "WeaponLeveling"

    \_Dictionary Key Function.Param(0) & "XP" >= 100

    ---Set Dictionary Key Function.Param(0) & "XP" to Dictionary.Get(Function.Param(0) & "XP") - 100

    ---Set Dictionary Key Function.Param(0) & "Level" to Dictionary.Get(Function.Param(0) & "Level") + 1

    ...

    etc.

    That would simulate reference passing, and most likely work as you intended.

  • Tried encasing the Array.At() in int() functions ? Maybe that'll force the calculation on numbers.

  • I still can't grasp exactly your need. A function that check neighboring cells and return its "type" is dead easy to do, but obviously you want more. Maybe you could draw another diagram?

  • It's still tough to determine what you want exactly. Care to elaborate a bit more ?

  • It seems I misread his need, I stopped at the first sentence, while what he wants is to remove duplicate "words" from a string as explained further. It's definitely not the same thing. I fear using a single RegexReplace won't quite cut it. What could work is to use "lookaround" to create a match if a word doesn't appear more than once. Then you can concatenate all matches in a loop.

    Since Javascript only support lookahead, it will have the drawback of losing the original order in which words appear, only the last occurrence of a word will create a match. Only the first occurrence would have been matched if lookbehind was supported... that's too bad if original order is needed. For the sake of showcasing the power of Regex, here's how to do it :

    Matching pattern : (\b\w+\b)(?!.*\b\1\b)

    Flags : g

    capx

  • Since OP asked for a Regex, here's how to do it :

    Matching pattern : (?:(\w)(?:\1)*)

    Flags : g

    Substitution pattern : $1

    See the witchcraft in action in this capx.

    Note that the (\w) in the matching pattern can be changed to something else to accommodate for accentuated letters and other symbols. Replacing it by (.) will ensure that any character can only be found once consecutively, except for the newline character. (You'd have to use ([\s\S]) to include it.)

  • I changed the logic a bit, is it more like how you want this to be ?

    https://dl.dropboxusercontent.com/u/700 ... Timer.capx

  • How is your terrain data represented, is it an array, or a tilemap ?

  • Off the top of my head I'd say that you should create a function a receive a point (x,y), and it returns the state of that particular tile in the array. If tile is empty, and have obstacles to the left, top and right, then return 1... do so for all your combination, and then use that function whenever you need to test a particular tile.

  • I had a go at it. You indeed need a For Each (ordered) but only for picking the Object2 with the minimal Y coordinate.

    Objects stop flashing if the overlap cease to be, dunno if it's what you wanted but it made more sense to me that way !

    https://dl.dropboxusercontent.com/u/700 ... Timer.capx

  • striimix I believe that the tilemap would still be best especially if all tiles are the same, fewer draw calls would be issued. We should probably do a comparative test just to see if any difference would be noticeable.

    edit: Just did it, I can't profile on my current computer since I'm at work and don't have a license there... <img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarrassed"> but it does seem to run with a steadier and higher FPS. If anything, it's far less convoluted event-wise and much more easier to edit the level design with a tilemap !

    https://dl.dropboxusercontent.com/u/700 ... lemap.capx