AllanR's Recent Forum Activity

  • sebastiangohhy

    I just happened to make a log system for a project I am working on last night.

    I have a global text variable called Log.

    at every point in the event sheet where I want to add something to the log I do a "System > Add to Global variable Log" and add NewLine & "whatever text to add"

    Then at the end you can do what ever you want with the results: display it, save it, send it to a database, etc

  • Set the Text objects Text field to something like:

    "a=" & SpriteA.count & ", b=" & SpriteB.count & ", c=" & SpriteC.count

  • 99Instances2Go ha, we were definitely thinking along the same lines. You must have a really nice laptop!

    HessamoddinS

    I just added another optimization that I was thinking about adding to the first version - limiting how many sprites it checks per tick.

    this version bumps the sprite count up to 300, but only checks 5 per tick. So, it takes a whole second for them all to have a turn looking for connections - but because there are so many, most of them will already have the connection made to them. Since it checks the same number every tick, there is no jerkiness.

    it runs very smoothly on my computer, cpu is under 50% as reported by C2 (but Windows says it really is only about 27%). If you watch really closely you can occasionally see where a connection should have been made but didn't get checked in time. But since there are so many other connections going on, I doubt anyone would ever notice.

    http://www.rieperts.com/games/forum/DotEffect2.capx

    if you play with the SpriteCount and CheckPerTick variables, keep SpriteCount an even multiple of CheckPerTick, otherwise some will never get checked, or it may even go into an infinite loop or something...

  • HessamoddinS

    You got me curious, so I tried a completely different approach...

    instead of comparing every sprite to every other sprite, I used a larger sprite "detector" to find sprites within 50px of the active sprite.

    plus I found a number of other ways to reduce the work it has to do every tick:

    • only look for close sprites 4 times a second
    • simplified the dictionary look-up
    • only calculate distance once per line per tick
    • don't update the text object every tick

    now it hits 60 fps, and averages around 15 to 20% cpu

    you can take a look at my code here: http://www.rieperts.com/games/forum/DotEffect.capx

    Then I though it would be fun to make one sprite "sick" and see how long it takes to spread. So, press x on the keyboard to turn a random sprite red, then any time it connects to another sprite, that one gets infected and turns red too. (it doesn't take very long!)

    press the space bar to turn them all back to black. (And then press x again to start another wave of zombie sprites)

  • pikazho

    Just took a look at your code, and the only big problem I see is that you are setting a text object every tick. That causes major trouble on mobile. Instead, only update the text object when the distance changes. Better yet, use a sprite font... although, with only one text object being rarely updated (only when it needs to change) you will probably not see much difference.

  • Just tried on my old iPhone 5, and it seemed pretty smooth to me (got a distance of 70 on my second try).

    What you see is pretty much what you get with an HTML game on a phone that is a couple years old. Make sure your OS is as up-to-date as possible. One of the biggest disadvantages of HTML is that it can only use one core of a cpu. So, while things have improved over the last few years (because cpu's are getting so much better), it still takes a lot of low level optimization to make a game run smoothly on mobile.

  • Just read how you wanted two arguments per username...

    The first version I made would only keep the arguments from the first time the username appears.

    I wasn't sure if there was some other method you would want to use to decide which arguments to save if the username appears multiple times in the original text file, so I made a new version that compares the arguments if the username is found and keeps the lowest values... (This gives the results you asked for in the first post).

    http://www.rieperts.com/games/forum/split_userdata2.capx

  • vila4480

    you are very close to how I would do it...

    just use tokenat again to split the username from the other argument...

    see my example:

    http://www.rieperts.com/games/forum/split_userdata.capx

  • willmonteirofx

    I was going to say I made an angry bird demo a couple years ago - but then I noticed the link was to that message thread, and lamar's capx was based on my example...

    so, the only thing I will add is that if you want the dots to fade out like in the image you made at the beginning of this thread, then add an action at event 4 (Draw dotted line) that says:

    Dot5 > Set opacity to (DotCount-loopindex) / DotCount * 100

    and you may want to reduce the DotCount global variable to 40 or less. Otherwise they will always know they are going to get a basket!

  • helena

    well, I walked through it and didn't see any smoking guns. I was remotely concerned that the camera could get to the player before the last tile timers finished their fade-in (and then the fade-in group is getting deactivated - I though that might lock a tile in a state that prevents it from being destroyed). But I ran a test, and that would not be a problem.

    I notice you set the MapArray to mapwidth+1 but the Random and Temp arrays are only mapwidth. Any chance there is a rogue tile in the data being imported?

    The only way I could get a tile to fail to fade out was if it did not pass the overlap test at event 92. If the collision map for one of the animations (on a less common tile does not have a point inside the x+16, y+16 spot you are checking, then it will not get removed. So check collision maps, and origin points - I routinely accidentally click somewhere I shouldn't and change an origin (and not notice) , or forget to make one of the animations match all the others...

    For debugging purposes, I would zoom the layout scale out so you can see the whole map at the start of the fade out group, and show a live tile count in a debug text box so you know for sure whether the tile count is not getting "less than or equal to 1" to satisfy event 94. Or if maybe some other strange combination of events is happening somewhere else (like somehow disabling the fade out group before it gets finished). The fact that it happens rarely certainly makes it harder to track down - but there always is a logical explanation.

  • Try Construct 3

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

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

    well, hard to say without seeing more of the code, but if the event isn't running then the tile count isn't getting down low enough to trigger it.

    which would indicate the timer is never getting started for one or more tiles. The most likely cause of that would be a glitch in your RandomTileArray, or a problem with the overlapping, or a tile not where it is supposed to be.

  • HessamoddinS

    the way I usually do what you want is to put the sprite in a family. Then you can compare an instance to the family

    spritefamily.x > sprite.x would then pick all the instances with an x greater than the one you are interested in

    and then you can do a for each spritefamily to compare them individually to sprite... or whatever else you want.

AllanR's avatar

AllanR

Member since 21 Nov, 2013

Twitter
AllanR has 23 followers

Trophy Case

  • 11-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

20/44
How to earn trophies