Ruskul's Recent Forum Activity

  • Hey ,

    I read around and can't figure it out. How do I have an image as my signature?

  • 1. I need a language that gives me a solid foundation of programming and doesn't give me any bad habits when migrating to harder languages such as C++.

    Start with c++ if that is your goal. The idea of learning on language to learn another is a bit of a waste of time and a bit of a round about.

    Nothing wrong with c# though. Visual studio is a great ide, c# is not closer to c++ simply because it has c in its name. It is closer than python though.

    Python is super easy but... idk. I don't like python or javascript. I like strict typing, if you know what that is... and that leads to better dev practices if you are wanting to move to c++

  • There are many ways to go about it but... for the most basic way:

    What I would do is get the angle from the npc to the player.

    You can then set the npc frame to round(angle/45). Set frame 0 to be facing east, frame 1 to be facing south east and so on.

    Does this make any sense?

  • Hello,

    Is there away of knowing how many objects have been included in the sol? For example A overlaps B. How many B exist in SOL?

    I Have a character that can break blocks but I don't want him to break more than 1 at a time.

    My thought was that if he overlaps more than 1 then I select the one closest to him, otherwise I can simply destroy the one he overlaps. Similar would be if Mario jumped and hit 2 brick blocks and broke them both at the same time, which I don't want. Only one.

    Thanks

  • newt - For sure, if I understand what you mean by setting up a variable comparison, I do that lots now. conditions = set variable to 1. After that check the variable, if it is 1 then do stuff, or similar setups.

    My biggest trouble is that I've noticed you need* "for each family loop"s with multiple function calls for scaleability. When functions are used as a design element to make your game scalable and manageable. For example, in my game, every dynamic object affected by world forces (gravity, wind, etc) is in a family called characters. The player, bullets, enemies, etc, are all in this family and this family must call 3-4 functions minimum but may call more. If you only have a few characters, no problem, but for every function I add, I exponentially impact my performance. Knowing this, I design more around less function calls. I'll see what my performance is in the end before taking drastic measures though

  • Ashley - but why would anyone need that?

    I didn't provide a capx because it hinges on my explanation... Which if its supposed to work like that... but I don't understand... why would anyone need that? Its not like they couldn't just select it from the panel? And a properly optimized tilemap usually won't have a whole lot of continuity as far as tile relations go.

    I've attached some gifs that illustrate the problem a little better than words can.

    In this first gif, I begin by creating a slope. I want this slope to repeat for a while but there is no good way to select a larger shape, so I build it block by block for the most part.

    https://www.dropbox.com/s/l1dhtl55qx9b1 ... p.gif?dl=0

    The real kicker comes when I want another slope, that looks the same... or perhaps that I need to move the slope over by 2 blocks... I can't. But if shift click drag copied from the tilemap and not the source, the built in tilemap becomes... well, usable. For example:

    https://www.dropbox.com/s/sgydlsj4s2b9p ... s.gif?dl=0

    I remember Tokinsom having talked alot about this a while back, and I recal alot of people getting excited over simply shift right click copy, which is super handy, but its handiness exponentially grows with dragging. Being able to rotate and flip these selections is the ultimate tile mappers tool. But I know for one thing Tokinsom wanted to be able to copy from the map not the source when he mentioned drag copying...

    Again... I don't understand the need to copy from the source, unless you have a rather redundant source image.

  • Your test includes things like comparing adding 1 to a variable to adding 1 to a variable in a function. That's exactly the kind of a test that basically just measures the overhead of a function. Functions already pretty much do the minimum work they can do, I'm not sure there's any obivous way to speed them up, but that's not to say they're slow. But I guess you might want to avoid them in long loops and such.

    For sure, I was basically looking at function overhead, comparing using functions vs not using them. I was curious though... would there be a way to create event sheet references? Sometimes a function only makes sense from a readability people thinking sort of way if that makes sense. Sometimes functions make sense from a program design standpoint. Would there be a way to have event sheet functions that are only in the event sheet?

    For example:

    If (object.A overlaps Family.Tilemaps) && (object.A.bool == Family.Tilemaps.bool)

    ----Do this, do that, push out of solids, bla, bla, bla, bla.

    If (object.A overlaps Family.SolidBlocks) && (object.A.bool == Family.SolidBlocks.bool)

    ----Do this, do that, push out of solids, bla, bla, bla, bla 20 actions.

    If (object.A overlaps Family.MobileBlocks) && (object.A.bool == Family.MobileBlocks)

    ----Do this, do that, push out of solids, bla, bla, bla, bla.

    REpeat for a few more condistions

    The above can be split into functions, and is preferable for readability and making changes to what happens, But in a game with many itterations through this, the function adds overhead. Whats more the function isn't needed, just a convenience for later editing. If there was an editor side function that could be called that would inline the events on export so that no overhead was created, that would be preferable.

    At the same, the only reason this pattern exists is because there are no combo or/ands in a condition tree. But that is a separate topic. (why is this?)

    for example : (A over B && A.x == b.x) || (A over C && A.x == C.x) || so on...

  • newt jayderyu megatronx Ashley,

    I should be clear, the actual time it takes construct 2 to execute a function can be up to 5x longer than another action single action. Just the calling of the function. (You may say, well of course you would never simply just call a function, but that is not true, (dynamics switch replacements may call functions that don't exist and other cool function uses may call a blank function)). As Ashley pointed out, a tiny thing can execute fast, and even though the functions take longer than that, they are still fast. Compared to a simple event like adding 1 to a variable, calling a function and doing nothing is quite a bit slower.

    Its nothing I would worry about, unless you are like me, where in my project I had been willy nilly splitting everything out into functions. I was never repeating code. But usually, a function can require much more than simply calling it. You must construct its name in a dynamic system, pass it a parameter (usually a uid) pick the object by uid once in the function, and finnaly do what needs done. Usually another function is called where you pass parameters and then use the return value. Thus functions are in functions. Its something that happens alot in programming.

    Now if you are doing this everywhere and only doing a few things in each function (maybe 2-3 conditions, 2-5 actions), you are really decreasing performance relative to the alternative. If you are doing many more things, like running an entire ai tree from one function call, the function use is irrelevant and has basically 0 impact on performance (unless you need to call it 1000 times a tick, but still, you probably have other worries at that point in terms of performance)

    I have attached a capx that hopefully demonstrates the problem. The capx shouldn't be too hard to understand so if a test doesn't make sense, just read the events in the relevant group or ask me. I chose 1000 cycles every tick arbitrarily. I would say, in a decent sized project, it is easy to expect to be doing at least that much work every tick, but it really depends right?

    For the most part, If you do everything in javascript that you can, and use the event system to wire everything together performance will be great. and has been my dev method for the last year. I once made a collision detection algorithm in construct, it was around 2,000 events. I thought it would be fun lol. The java script version barely has an impact while the event based version took a chunk of cpu to run eveyrtick. I think this is to be expected...

    Anyway, I like to create tests just to see what takes time and what doesn't, it has helped me to determine when and where I should put things in javascript rather than events. I also am master and chief at prematurely optimizing, but its my favorite part about coding. If I am in a hurry I don't fiddle too much with it lol.

    https://www.dropbox.com/s/0xhwlwrwq9b1xtx/EventTypePerformanceTest.capx?dl=0

  • Or just make global object with boo's. I am actually finding this much more comfortable then if I'd have to scan trough globals and locals.

    Well, I must admit I do that as well. lol. In large projects its no good to use global variables. There are too many of them and no way to organize them. But I would like to use local variables. They are a bit more meaningful than saying set TempObject.TempBoolean to false

  • R0J0hound - I will look into that. Thanks.

  • Howdy,

    I've been playing around with event based procedual terrain generation and I noticed something interesting.

    A function impacts performance up to 5x more than another simple event call (calling function vs Adding to avariable, for example). The more you do within the function the less that becomes in relation. But if you call a function simply to perform 1-2 events, just copying and pasting those 1-2 events saves mucho cpu time, if you do this many times.

    I'm not sure why the performance hit is so great, but once a game is all done and made, if you have performance issues you may try replacing function calls with the code. This makes your code base unmaintainable and awful to look at but you can gain a bit of performance by doing it. This should only* be considered if you are struggling with performance and have eliminated other bottlenecks. Obviously if you have 1000 physics based objects, you may find that reducing function calls is a waste of time in the grand scheme of things.

    Better yet, use the event system only to tie scripts together. Do everything else in scripts. That saves over 9000, a whopping 500% to 1000 points more . Ya..

    I often like to make dynamic function call systems in placement of switch statements (as construct has none) and event driven dispatch systems, but this may not be as efficient as simply going through a giant condition list.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The feature to change at runtime doesn't exist, so logically one would look for other ways to simulate the effect..

    Thats the confirmation I was looking for. I thought it may exist in the sdk but I couldn't find it, thought I would check.

    There are plenty of reasons to want to change polygons directly rather than having transforms control them. More from a procedural standpoint, trying to avoid editor side work. Its not something that is needed* but that would be nice.

    Rotating combined with resizing works to an extent to solve the problem but again requires more programming work, at least in the sense I need to do some trig to ensure proper placement rotation and stretching.

Ruskul's avatar

Ruskul

Member since 23 Nov, 2013

Twitter
Ruskul has 2 followers

Trophy Case

  • 11-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x6
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies