The Maddog's Forum Posts

  • Having spent hours looking around the forum for a way to make a tiled Background play a sequence of images, I have been forced to use sprite's. In my game I have designed in such a way that the entire game randomly teraforms itself based on a global randomising number.

    I have flocks of birds, trees, grass with leaves that rustle in the wind. I have lakes of water and mountain ranges that appear from meteorites. I have a day and night, a season system and a wind system with weather effects.

    But my number 1 limitation is having to use many many sprite's. To be able to have a way to use Tiled Backgrounds would be a huge improvement in overall performance.

    My game is being designed purely for the PC as I do not believe that phones will be able to handle such a huge amount of sprite's at any given time.

    I also have some issues as well.

    Each tree has a variable called TargetScale. This is set to 1. When a tree spawns, it's scale is set to 0.1 (sapling) overtime the sapling will grow into a tree. Now when the tree's TargetScale becomes 1, the tree will continue to grow. However I have a compare variable that checks if Greater than or = to 1 set scale to 1. The tree will grow to 1.01 but in a blink resize itself back to 1 and so on. Now I cannot figure out a way of preventing that from happening as disabling the grow function will disable all the other trees from growing.

    Is there a way please?

  • So you're saying that I basically don't need to worry about having 1000s of sprites ?

    Also I cannot find any documentation on the sprite sheet at all.

    Thank you both for your replys.

  • Such an old thread, however is the only thing that I have found that could answer my question. I have 1000s of grass sprites around my map of which have 20 frames each to sway in the wind. The lag is unbearable, I cannot continue. The only way around this is to use Tiled Backgrounds. But I cannot due to not being able to animate them.

    I think I have found the solution here, but I do not understand your instructions Yann as I am still very young in Construct3. This problem of animating tiled backgrounds is the only thing stopping me from purchasing a personal license. It's preventing me from finishing my game. I could really use some help on this and I am stumped as to why they have not allowed us to actually animate our tiled backgrounds. It is such a vital feature that is lacking.

    I do hope you can reply, in the mean time I am going to try and replicate what you have said and try get something working.

    I have a math counter of which depending on the number spawns a sprite. This sprite has 20 frames of grass swaying in the wind. During the game depending on how much it rains, the weather and season new grass will spawn, at any time there can be 1000s, but the lag is unbearable and not possible. The only way that I can fix this lag is to find a way to have tiled backgrounds do exactly what the sprite is doing, minus the lag of course!

    nah you're doing it wrong

    first you don't use dt in the wait as it's already in seconds

    seconds don't create and destroy but toggle visibility

    third, well you might have the free version, but I'd use families to make things more code friendly (:

    Also I would use a timer variable something like

    Global number speed = 5 //frame by second
    Global number t=0 //timer variable
    Global number frameCount=3 //number of "frame" for the effect
    Every tick 
      -> add to t speed*dt
      -> tiledbg1: set invisible
      -> tiledbg2: set invisible
      -> tiledbg3: set invisible
    int(t)%frameCount = 0
      -> tiledbg1: set visible
    int(t)%frameCount = 1
      -> tiledbg2: set visible
    int(t)%frameCount = 2
      -> tiledbg3: set visible
    [/code:1x009smv]
    
    With family (myTiledBG), I would add a family variable named 'frame' of type number and manually set for each tiledBG in the family a number repr?senting the frame. 
    And then in event it would look like
    [code:1x009smv]Global number speed = 5 //frame by second
    Global number t=0 //timer variable
    Global number frameCount=3
    Every tick 
      -> add to t speed*dt
      -> myTiledBG: set invisible
    myTiledBG.frame = int(t)%frameCount
      -> myTiledBG: set visible[/code:1x009smv]
    
    As for perf, well, there shouldn't be any difference with animated sprite. That's more or less what they do, swapping texture. But yeah you'd have a little bit more object to handle, if it's less than let say 50 frames it should be ok.Yann2012-06-26 21:59:11
    
  • Hi all again,

    I have a map which randomly generates grass around the map depending on the season ingame. However having over 1000 sprites on a layer is insane.

    I've been told to achieve this by using Tiled Backgrounds. However, my grass was made using photoshop and animated and exported as a PNG sequence using After Effects. Now, I have just found out that I cannot animate a Tiled Background.

    Is there a way ? I cannot use Sprites, the game will lag.

    How can I achieve this please ? The grass sways in the wind and has 20 frames, it can be done via Sprites but having over 500 of these as well as having them animate is just absolutely insane. There must be a way, I am smashing my head on my keyboard, please help.

    Thank you all for reading and I hope a solution can be found.

  • Highly recommend using Tiled Backgrounds for this instead of a sprite. Depending exactly how many of these sprite's you intend on spawning that is.

    But assuming that you intend on filling your entire layout, then I'm afraid that using sprite's is the wrong way to go about it.

    I have a game of where overtime the actual layout teraforms itself depending on the season in the game. I was spawning 100s of sprite's but after hitting 500 I got worried. 100% CPU usage, stuttering FPS but only 13MB RAM usage ?? ... So I came here and I was told and taught how to achieve the exact same thing but this time using a Tiled Background instead of a sprite so I did just that.

    Last night I had 1000s and thousands of Tiled Backgrounds and my FPS stayed at 60, my CPU 3-5% but my RAM was still 13.

    Use Tiled Background for this.

  • Wow, that method right there is the way to go for free users. That's what I like best about Construct is how you can make almost anything work in many different ways.

    If sprite isn't overlapping tiled background then spawn and move on. If overlapping tiled background then don't spawn and move on. Could use this method for rocks and lakes too.

    I have a GlobalVariable set to 0. Every 1 second this number get's changed to a random number between 0-100. If it's <=5 then the group that spawns the grass is toggled once. But obviously I couldn't do this due to not knowing how to target a single instance of the silly tiled background.

    So thanks again, you have been of much help!

  • oosyrag, thank you for your reply.

    Unfortunately it requires the non free edition of which I do fully intend to buy in a couple days. I will give this method a try and reply back here.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I need lots and lots of the same duplicated Tiled Background to randomly appear around my entire map. (Grass)

    However when the grass spawns on or overlaps itself, unlike the sprite I cannot delete the object. This is a big problem, I can destroy the Tiled Background but doing this destroys them all. Also I cannot find a way to target just that 1 instance of that Tiled Background.

    How can I check to see if the Tiled Background is overlapping another Tiled Background and then destroy that 1 Tiled Background.

    Of course I could use Sprites but having a 1000 sprites is laggy and simply not logical.

    Thank you for your help.

    ibb.co/n7fCAo

  • Hello,

    I have a global variable called Coins

    When I right click I spawn an instanced object

    When I right click I subtract 5 coins from the global variable Coins

    The trouble is I can right click as many times as I want and it keeps subtracting coins and placing the objects down.

    How can I prevent this ? Basically what I want is that when the global variable of coins is less than or equal to XX don't subtract anymore coins from the global variable and certainly don't spawn another wall ...

    Thanks!