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 / Crosswords - DeleteText being slow

Author
Message
Felis Astrum
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Melbourne
Posted: 1st Nov 2012 11:01
Salutations! I've been working on a crosswords game and it's going well (about 95% complete) but I've been running into a wall with DeleteText slowing things down. The problem is like this:

Each square has a couple of sprites and a text element. When clearing the level the game becomes extremely slow and I found that the problem lies in DeleteText.
I've used a few different approaches to clearing the text but it's generally something like this:



Clearing the sprites using this method happens instantly so it's not the number of squares that's an issue, just the text. I've tried separating it into a loop for each text element so I could see what's going on and it's just in the middle section (approximately IDs 1200 to 1600) that it becomes slow. Then it speeds up again.

No matter what I try, it still takes the same amount of time. If you can help me figure this out, you will become my new favourite person.

I'm new. I bring cats for all.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Nov 2012 13:25 Edited at: 1st Nov 2012 13:26
What's the average size (roughly) of each text object? If it's a crossword puzzle I assume 1 character per text object. If you let AppGameKit allocate the numbers for you does the speed increase (I can't think of reasons why it would however)?

Text deletion is pretty snappy on this end, 10,000 "Hello"s deleted in under a second, however I'm on a powerful machine and using Tier 2 C++.

Run this and tell me what you get. (I've written this on a mac so I haven't tested it).

E.g


The number displayed is the number of seconds it took to delete the 1000 text objects. The sync will increase the time taken but I imagine your syncing each loop anyway.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Nov 2012 13:49
Perhaps you don't need to delete them? Just change the text string to "" or make the text not visible between games?


this.mess = abs(sin(times#))
Felis Astrum
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Melbourne
Posted: 1st Nov 2012 15:30
Thanks to you both for the help
Quote: "Perhaps you don't need to delete them? Just change the text string to "" or make the text not visible between games?"

I tested what happens when I don't delete them but I'm a bit reluctant to do that, not just because I feel the need to clean up after myself, but because when exiting the game it churns through deleting them at that stage instead.

Hodgey, I played a bit with the code above; the crossword uses one character per text string but I found that the length doesn't make any difference.
What does however, is using my custom font maps. When I ran the code as is, it took 0.05 seconds. But when I included the font maps, it appeared to crash. I reduced it to 500 and it took about... 8.5 minutes. *jazz hands*
If I don't include the extended font map it's faster, but still takes 94 seconds, which kind of reflects what I mentioned in my previous post, that it gets to a mysterious point where it slows right down (then eventually speeds up again).

I've been using a couple of different font maps without any issue, they load and display fine. Admittedly, I haven't conformed exactly to the layout guidelines- I lined up the letters instead of putting them in a grid, but I don't know if that makes any difference.

I'd try setting the font maps as the default font, but for some reason that's stopped working. When I tried a month or two ago it worked, I may have been using the previous version of AppGameKit at the time, I don't know.

I'm new. I bring cats for all.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 1st Nov 2012 16:35
Thanks for the detailed timings, it allowed me to narrow it down to the image deleting for text objects. I've made some changes for the next version that should speed it up.
Felis Astrum
12
Years of Service
User Offline
Joined: 27th Sep 2012
Location: Melbourne
Posted: 2nd Nov 2012 07:23
Excellent Thanks Paul, looking forward to giving it a go.

I'm new. I bring cats for all.

Login to post a reply

Server time is: 2024-11-24 01:23:59
Your offset time is: 2024-11-24 01:23:59