Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Keeping up speed in AGK, some tips.

Author
Message
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 20th Jun 2013 21:26 Edited at: 20th Jun 2013 21:28
Hi all. This is a little video I have done to help people with keeping a good frame rate in AGK. I hope it helps some of you out, and possibly injects your current, or future projects with more oomph!



For the people I'm teaching to suck eggs, my apologies

Oh if you get a blurry screen, up the quality. It should go up to 1080p at highest. You may have to go to youtube for it to work, I'm not entirely sure.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Jun 2013 21:55 Edited at: 20th Jun 2013 22:16
Good tip for beginners. I've been using clone sprite quite a fair bit, but it is nice to see an actual comparison on how big a difference it can make.

I did one quit comparison awhile ago between cloning many sprites for a tile map versus just drawing one sprite multiple times. I had 176 tiles on the screen and didn't notice any performance difference, but my frame rates seem locked at 60 no matter what. Never thought much about it until, but I just looked for vsync commands. Now to see where my apps really stand!


I typed up option 3 and ran it to see what I'd get. I had to make a small change to the loading because I don't have your image, so I used the following instead:



Average frame rates were actually over 2200 when I wasn't taking screenshots.


Attachments

Login to view attachments
RickV
TGC Development Director
24
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 21st Jun 2013 07:34
Hi DVader,

Lovely tutorial, I have shared this across our AppGameKit social feeds.

Cheers,

Rick

Financial Director
TGC Team
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 21st Jun 2013 12:13 Edited at: 21st Jun 2013 16:11
Thanks Rick, glad you like it! Never done one before so wasn't sure how it would go, as I just winged it ( the recording) so to speak.

Phaelax, Yeah I was getting a lot higher frame rates when not recording also My image, btw is simply a blank 1024x1024 image for the animated frames, and a 32x32 image for the first test. I'm not actually using it in this, but added the code in to show how to do it. It would work, if I were to add some actual art though You must have a faster video card than mine though, I was getting 1000+ odd frames at best.

I've made a very rubbish image to use with the code if people want to try it, just to show it is using an image, and a different frame for each (not that I have altered the frames image) For the single image I just use a 32x32 of a single frame from it.

Here is the code also, to save you having to pause the video and type it.


Attachments

Login to view attachments
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 22nd Jun 2013 00:52
This might be a mistake on my part, but I thought transparency was set to 0 by default. I remember having to set it to 1 in order for my objects to use alpha, but I might have been setting it to 0 for all my objects beforehand without remembering

swis
Joined: Tue Dec 16th 2008
Interstellar
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 22nd Jun 2013 04:38
AGK defaults to using a transparency, according to the manual. As most sprites tend to use it, that seems the best way for things to work. Although using the alpha doesn't slow it down much compared to inefficient/efficient image use,as my example shows.

You may be thinking of creating sprites yourself using getimage(), as that tends to need you to set an alpha, when making a sprite from it.

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 22nd Jun 2013 06:19
You know, I think I was thinking of 3D objects. It would be odd for them to be backwards as far as the standard here, but it is much less common to have a translucent 3D model.

swis
Joined: Tue Dec 16th 2008
Interstellar
Lost Dragon
14
Years of Service
User Offline
Joined: 22nd Aug 2010
Location:
Posted: 22nd Jun 2013 06:26 Edited at: 22nd Jun 2013 06:30
Option1 makes the application crash for me with "uncaught exception".

The other two options work ok.

Forget that. I fixed it. Neat demo. Thanks.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 22nd Jun 2013 22:43 Edited at: 22nd Jun 2013 22:48
@ Swisssolo, yupp 3D objects are in reverse, which again makes sense, as you say, most models will be solid, not translucent.

@ Lost Dragon, uncaught exception? Not sure what was causing that, was it an image thing? If you tried using the image I put up in example 1, it would either take forever, or crash I would imagine. Example 1 needs a small image, so the big one I posted above would not be good. You have fixed it which is good, but in case anyone else has the problem, it would be nice to know what it was. Glad you like the demo!

Lost Dragon
14
Years of Service
User Offline
Joined: 22nd Aug 2010
Location:
Posted: 22nd Jun 2013 22:57
Yes, I skimmed the post and used the wrong image for option 1. When I replaced it with a proper one everything was fine.

Silly me.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 23rd Jun 2013 01:57
Ah, your not a programmer unless you have made at least 10000+ mistakes in the past, maybe more. Nature of the beast Thought it would be the image, but nice to confirm it!

nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 23rd Jun 2013 06:01
Nice post DVader. I felt compelled to try some benchmarking on some particle functions I'm rewriting and I got some interesting results.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 23rd Jun 2013 08:04
Had a look at your topic, and posted a reply. Thanks for watching my video (if you did of course). It would be interesting to see how a direct comparison of draw line and scaled sprites compare. As I say in your thread, I imagine the best comparison would be one draw line call compared to one sprite call, as opposed to what looks like 5 draw line calls compared to one sprite call. If you need thick beefy lines, I think sprites will win every time.

haliop
User Banned
Posted: 24th Jun 2013 04:05
TDavid
11
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 24th Jun 2013 16:14 Edited at: 24th Jun 2013 17:10
Thanks for the tutorial.

A question though: is the clone sprite function making any difference performance wise? You didn't mention it in the video, did you? Since the transparency is turned off in option 3, it's difficult to tell if there's a difference between using createsprite and clonesprite.

edit: okay, I tested your code myself.

To represent how a device would have to struggle with fill rate, I increased the size of the sprite from 10 to 20 so that they overlap each other (maybe a bit too much).

With transparency on for both option 2 and 3, the difference in performance is 2% in favor of option 3. With such a small difference, it might also be my computer getting used to sprite rotation.

With transparency off on option 3, however, the performance boost is 31%. Of course, the more the sprite overlap, the bigger the boost.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 24th Jun 2013 21:29
I didn't notice a vast difference with clone sprite, that's why I didn't really cover it. Your results sound about right though, it was fractionally faster with clone sprite than it was without.

haliop
User Banned
Posted: 27th Jun 2013 05:13 Edited at: 27th Jun 2013 08:34
edit: deleted as it makes no sense...

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 30th Jun 2013 13:36
Halipop ? What made no sense? Was it a question? I will try to answer any questions about this subject.
Just as an extra, obviously this isn't the only thing you can do for speed increases in AppGameKit, but I felt it gave the largest increase of any of the options. You can disable the clearcolor command for more speed also, and update and sync yourself, or just make sure that the entire screen is filled with sprites or even a single sprite, so that the smearing effect is not seen. It can increase speed, just not as much as ensuring your draw calls are low. Of course both will give you an impressive speed boost. Keeping loops to a minimum will also help, massive loops, and particularly loops within loops can slow the game down significantly.

Login to post a reply

Server time is: 2024-11-24 15:35:58
Your offset time is: 2024-11-24 15:35:58