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 / Very Low performance

Author
Message
Poliedro
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 21st Mar 2012 19:48
Please help... I'm making a code and i have a big problem.
All begin in good way 60fps but in a few seconds, performance down gradualmente until 8fps or less.

What am i doing wrong? Also, i uploaded the exe too. Thanks

CODE:


--------------------------
Doing Something

Attachments

Login to view attachments
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 21st Mar 2012 22:27
Quote: "Function DrawGems()
imgGems = LoadImage("gems.png") //Load gems
for y = 0 to ARRAYX-1
for x = 0 to ARRAYY-1
if GridArray[x,y] <> 0 and MatchArray[x,y] > 0
sprGems = CreateSprite(imgGems) //Create a sprite with gems
SetSpriteAnimation(sprGems, 48, 48, 6)
SetSpriteSize (sprGems, 5, -1) //width 40% of screen
SetSpritePosition (sprGems, GetSpriteWidth(sprGems)*x+5, GetSpriteHeight(sprGems)*y+5)
SetSpriteFrame (sprGems, MatchArray[x,y])
Endif
Next x
Next y
EndFunction"


Don't load image every loop. Load it once as a global image.

MarcoBruti
13
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 22nd Mar 2012 13:17
I had a similar problem with my pinball application. FPS goes down to 5 FPS. I opened a parallel thread ("Big performance problems..."). Read it if you like.
I had no image loading in a loop, but I did a stupid mistake with arrays. Let me know if the problem persists after removing the load image in the loop.
Poliedro
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 22nd Mar 2012 17:51
Problem is persists after loading image as global out of do..loop.
Marco... please advice me. thanks

--------------------------
Doing Something
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 22nd Mar 2012 18:57
You are also creating new sprites each loop too in DrawGems();
Quote: "sprGems = CreateSprite(imgGems)"


You need to get all your loading and creating done before the loop starts.
MarcoBruti
13
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 22nd Mar 2012 19:04
I generally prefix each CreateSprite commands with a check

Moreover I advice you to do a troubleshooting sessions disabling all function call, and enabling one by one, identifying the function that produces the performance degradation.
Then, inside that function, disable all instrunction, and enable one by one.
This should let you identify the bug.
With pinball I did that.
Poliedro
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 22nd Mar 2012 19:34
Marl is in good way... i have a code from DBPRO

Function DrawSprites()
for y = 0 to ARRAY_X-1
for x = 0 to ARRAY_Y-1
if GridArray(x,y) <> 0 and MatchArray(x,y) > 0
Paste Image 7, Grid.l+x*Grid.Width+1, Grid.t+y*Grid.Height+1
Paste Sprite gema, Grid.l+x*Grid.Width+1, Grid.t+y*Grid.Height+1
Set Sprite frame gema, MatchArray(x,y)
Endif
Next
Next
EndFunction

How can i adapt this code to load? Something similar to paste sprite? How can i create sprites out of main loop?

Thank you so much to all

--------------------------
Doing Something
Poliedro
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 22nd Mar 2012 19:37
Quote: "Moreover I advice you to do a troubleshooting sessions disabling all function call, and enabling one by one, identifying the function that produces the performance degradation.
Then, inside that function, disable all instrunction, and enable one by one.
This should let you identify the bug.
With pinball I did that."


I identified sprite creation into main loop as guilty of low performance, but i dont know i must do to solve it.

--------------------------
Doing Something
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 22nd Mar 2012 23:35
In AppGameKit you don't paste sprites in the same way, they are created and turned on and off as needed.

Under where you have.



put something like


Then change DrawGems() to something like


This is just the change to this function, I have not checked the rest of the program.
Poliedro
12
Years of Service
User Offline
Joined: 21st Mar 2012
Location:
Posted: 23rd Mar 2012 07:34
Run smoothly 60fps... Now, i understand concept.
Create sprites and set to invisibility.

Marl thank u so much.

--------------------------
Doing Something
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 23rd Mar 2012 10:19
You don't need Global Dim Array[] as all arrays are global anyway.

My signature is NOT a moderator plaything! Stop changing it!

Login to post a reply

Server time is: 2024-11-23 05:09:16
Your offset time is: 2024-11-23 05:09:16