Few technical questions for you folks

Discuss game development design and post your game ideas

Post » Sun Jul 15, 2012 2:09 am

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):

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


1) By default, are sprites and tiled background objects calculated if they are off-screen? 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.

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? 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?

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? 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?

Here's a star for making it this far in my post: *

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? Any way to achieve that efficiently with C2 without using physics on sprites or particles? :)

5) Tiled background objects: same as a large sprite with bounding box collision performance-wise? Or do they behave differently?
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". :)

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?
e.g.: if (player.x - spearman.x) && (Distance(player.x,player.y,spearman.x, spearman.y) >= 30) > 0 --> spearman.x += 1; set mirrored.

You just got 2 stars!**

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

For that answer: *** and you got a Perfect score!!!

Many many thanks Ashley! :D

MQMoonQuake2012-07-16 04:27:30
B
3
Posts: 6
Reputation: 587

Post » Sun Jul 15, 2012 7:53 pm

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?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Mon Jul 16, 2012 4:28 am

Updated first post with blue text.

Thanks a lot for the answers, Ashley.
B
3
Posts: 6
Reputation: 587

Post » Mon Jul 16, 2012 2:21 pm

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!
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Mon Jul 16, 2012 8:09 pm

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:
http://www.scirra.com/forum/forum_posts.asp?TID=51980&KW=spearman%2Ex&PID=327171&title=a-problem-of-solids#327171

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.
B
3
Posts: 6
Reputation: 587

Post » Mon Jul 16, 2012 8:30 pm

#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.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Mon Jul 16, 2012 8:36 pm

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.
Mr E Bear2012-07-16 20:37:38
B
49
S
14
G
3
Posts: 540
Reputation: 5,611

Post » Tue Jul 17, 2012 8:44 pm

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


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.
Kyatric2012-07-17 20:46:40
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Wed Jul 18, 2012 12:45 pm

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

B
3
Posts: 6
Reputation: 587


Return to Game Development, Design & Ideas

Who is online

Users browsing this forum: No registered users and 0 guests