Few technical questions for you folks

0 favourites
  • 9 posts
  • Hello, I'm MoonQuake, first post here! Yay.

    Glad to meet you all! :)

    I've been working on a game with C2 and have been wandering the forums and made quite a lot of searches.

    I am still looking for a few technical answers mainly regarding performance and game optimization.

    Here goes (mainly applies to platformer and physics):

    <font color=blue>

    Should've mentioned that I read the Performance tips page many times, and I still got these questions! :)</font>

    1) By default, are sprites and tiled background objects calculated if they are off-screen? <font color=blue>You know, are they in memory, using CPU/GPU resources? This is a question often asked mainly because we can't find the answer by searching for it and because that's the first thing you want to know when it comes to optimization on an engine you don't know well. Example: are the calculation done for a physics object that is off-screen? That object would not be rendered, but still be active.

    </font>

    2) If a sprite is checking for collision on a physics object, does it do it for every instance of that object (off and on-screen) and every frame? Or just when it touches something? Also, is it better to have the moving sprite do the coll checking or the non-moving phys object? <font color=blue>So I guess a collision check between two objects is as expensive whatever the type of object with C2. It matters simply if there are many instances of these objects? </font>

    3) When a physic object is toggled immovable, does it still consume as much CPU cycles than when it's movable? Like just visually frozen? <font color=blue>What if I was to stack 20 physics objects off-screen at the end of a level. Wouldn't it be better for me to set them Immovable while off-screen? So that their physics calculations aren't done during the whole level but only when visible at the end when toggled Movable? </font>

    Here's a star for making it this far in my post: <font size="6">*</font>

    4) Sorry for not knowing anything about that subject (didn't search for it yet): can you use particles with physics collisions, and if so, is it better to use that rather than just Spawn another object multiple times upon breaking an object? <font color=blue>Any way to achieve that efficiently with C2 without using physics on sprites or particles? :)</font>

    5) Tiled background objects: same as a large sprite with bounding box collision performance-wise? Or do they behave differently?

    <font color=blue>Let me rephrase: if I use a large sprite (512x512px) and set that sprite with a bounding box coll, is it the same performance-wise as a large tiled background object of 512x512px? If not, what is the difference in performance? Like "TB are rendered twice as fast because of this and that". :)</font>

    6) Where do I put bits of coding I see on the forum sometimes? Does this require a plug-in or just a licensed version of C2?

    <font color=blue>e.g.: if (player.x - spearman.x) && (Distance(player.x,player.y,spearman.x, spearman.y) >= 30) > 0 --> spearman.x += 1; set mirrored.</font>

    You just got 2 stars!<font size="6">**</font>

    7) Is there a game in existence that make decent use of physics released on Android made with the awesome C2?

    For that answer: <font size="6">***</font> and you got a Perfect score!!!

    Many many thanks <font color=blue>Ashley</font>! :D

    MQ

  • First of all check out performance tips in the manual.

    1) Sprites are not rendered if offscreen. (This is asked a lot, and I'm not sure why! How is it possible to actually render an offscreen sprite? Why would any engine even attempt that?)

    2) Generally this is not important to performance

    3) Generally this is not important to performance

    4) You cannot control the Particles object with physics. You shouldn't even attempt it with sprites, because it is an extremely inefficient thing to do. See the performance tips article.

    5) Tiled backgrounds are always more efficient than grids of sprites (see the performance tips article). Apart from that there is generally no important performance difference.

    6) What bits of coding are you talking about?

    7) I'm not sure, because our Android support is still in beta so there probably aren't many games published with it. How about Save Komo?

  • Updated first post with blue text.

    Thanks a lot for the answers, Ashley.

  • You're kind of barking up the wrong tree. Most of the things you mentioned are not important considerations for performance. Everything important is mentioned in the 'Performance Tips' article, and everything not mentioned in the article is generally not important.

    See the blog post Optimisation: don't waste your time.

    1) Offscreen objects are still processed by the CPU (it would be very annoying if they paused whenever they went offscreen). However, it's kind of irrelevant because most games spend 90% of their time drawing the screen, so even if they were not processed at all there would probably not be any performance increase. So you could make a much bigger difference focusing elsewhere.

    2) Collisions have to be checked every frame, but far apart objects can be discarded almost instantaneously. Only semi-overlapping objects which have a collision test take a lot of CPU, but as per #1, it probably wouldn't improve performance even if you didn't make the collision check at all. So you could make a much bigger difference focusing elsewhere.

    3) Inactive physics objects automatically stop processing (they enter sleep mode), so generally you don't have to worry about this.

    4) Just fake it with another behavior like Bullet with gravity, and don't use any collisions.

    5) I think the case you mentioned would be absolutely identical either way.

    6) I don't recognise that language - I'm not sure where you got it from!

  • Thanks again for the replies, Ashley.

    I'm used to working on large scale projects, so I care about every little 1% optimization I can get... espacially when all these 1%'s add up to 10% faster framerate in the end. It has become an OCD for me. :)

    That bit from 6) is from the "How do I" section on the scirra forums:

    scirra.com/forum/forum_posts.asp

    I've often seen people use that type of language and am still wondering where they use it. Felt like it was used in some sort of advanced coding mode in C2.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • #6 is just pseudo code. I often use pseudo code to portray how to do something instead of a capx file or a screenshot of events.

  • On your 6th question, that's not a language I recognise, but it's just a logical sentence with some Construct terms thrown in; plain text it reads:

    if (player.x - spearman.x) && (Distance(player.x,player.y,spearman.x, spearman.y) >= 30) > 0 --> spearman.x += 1; set mirrored.

    IF (the SUM of the player's x position take away the spearman's x position) AND (the sum of the player's x/y and spearmen's x/y is GREATER THAN OR EQUAL TO 30) is GREATER THAN 0 THEN set the spearman's x position to 1, mirrored.

    To the best of my knowledge, I haven't done logic for years. Hopefully someone more knowledgeable can elaborate?

    As for inputting it, it was my understanding that whenever you read code laid out like that you simply translated it into the event sheet.

  • This very example is pretty awful actually.

    It is indeed pseudo-code, but coming more from a "real language", it is not the most appropriate/most used for C2 on the forums.

    Still, you could "translate" this pseudo code into this event sheet :

    https://dl.dropbox.com/u/36472942/construct/forumhelp/PseudoCode2Events.PNG

    <img src="https://dl.dropbox.com/u/36472942/construct/forumhelp/PseudoCode2Events.PNG" border="0">

    But it's really not a good example of C2's pseudo code used on the forums.

    Generally, people precise what the object type/condition used is/are.

  • Ah, I understand. Faster than typing it as a sentence. Thanks guys.

    I will most likely come back with more interrogations in the near future.

    MQ

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)