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 / delay for delete sprites

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th May 2015 21:35
Hi.

I have agk v1 and made a game. but when I want remove a level and load another level, images and sprites delete with delay. my image size are 652KB and think this is not normal for a little game. already i had this problem with another projects but today decide ask this question why occur this happen? while I seen several games even large games, but anyone no have delay for go to next level or exit game. this problem is relate to AGk?

thanks.
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 29th May 2015 22:55
Can you provide some sample code which illustrates the delay?

Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 30th May 2015 06:45
Quote: "Can you provide some sample code which illustrates the delay?"


yes.

this is my code for reset the game:



this is another code for start the game:

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th May 2015 17:46 Edited at: 30th May 2015 17:49
All games have delays when deleting one level and creating another. But they hide it with simple tricks.

At the end of a level you often see your score, or a "Well done!" image for example. then it might say "Get Ready!" and start the next level. This is a diversion while they unload one level and load the next one. It probably took 5 - 10 seconds to show you these images and your score but you were distracted from what was actually happening.

It's called "Smoke and Mirrors". Magicians use smoke and mirrors to hide their actions and make it look like magic.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 30th May 2015 18:04 Edited at: 30th May 2015 18:09
Quote: "This is a diversion while they unload one level and load the next one."


how can do it while level 1 is show?

I think Smoke and Mirrors happen automatically in other game engines.

I need understand it.

Thanks.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 30th May 2015 20:12
Quote: "I think Smoke and Mirrors happen automatically in other game engines."
- Personally I consider AppGameKit to be more of a language than a game engine. You can write a game engine with it, and you can write your "Smoke and Mirrors" with it. That's why I like it.

For example:
Load a "Next Level" sprite, make it big enough to fill the whole screen. Set its depth so it draws on top of everything else, then do all you level stuff behind it. The user will just see the "Next Level" image. Animate it, add music and special effects if you like.

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 30th May 2015 20:28
Quote: "- Personally I consider AppGameKit to be more of a language than a game engine. You can write a game engine with it, and you can write your "Smoke and Mirrors" with it. That's why I like it."


I like it too because is easy to use.

Quote: "For example:
Load a "Next Level" sprite, make it big enough to fill the whole screen. Set its depth so it draws on top of everything else, then do all you level stuff behind it. The user will just see the "Next Level" image. Animate it, add music and special effects if you like."


Problem is when I try load next level sprites behind a another sprite, for Moments Pause the game and this good not seem for commercial game.this problem is same for delete old images and sprites before load new sprites.
Jambo B
14
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 31st May 2015 01:06 Edited at: 31st May 2015 01:35
To prevent the delay where it looks like the game has frozen, you could delete the objects as part of the main loop, a few at a time, rather than doing them all at once and holding up the main thread. That way, you could be updating the animation on your 'next level sprite' while the deletes (and the loads/creates) kind of happen in the background.

A timer variable, set at the start of the deletes and then read at the end, would let you know how long the deletes had taken, and you'd then know how much longer to display the 'next level sprite' for, once the deletes/loads/creates were done.

I guess that would be part of the Smoke and Mirrors effect.

I really like that description of it, BTW!

Apart from the Operating System nicking time from your running prog (e.g. virus checker scanning), the only thing that should cause a freeze, stutter, or slow framerate is the code taking too long to get to the next Sync() command, for whatever reason.

Hope this helps,

James
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st May 2015 10:43
Thanks all for help. I think understood fix delay for my current game. but for other games if there is any problem I ask in new topic.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st May 2015 11:25
In my tutorial in the June newsletter, you will see an example of what Jambo B is talking about. It is a different situation, but I needed to do several things over a few frames to stop the game stalling.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 31st May 2015 11:46
ok, I wait for it.

Thanks BatVink.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jun 2015 06:28
@BatVink

I don't seen your tutorial in June newsletter.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Jun 2015 10:41 Edited at: 9th Jun 2015 15:08
It's here.

I use a "State Machine" to take the screenshot over 4 frames. you can do teh same when deleting/loading resources. e.g

Frame 1 - delete sounds
Frame 2 - Delete Sprites
Frame 3 - Delete Images
Frame 4 - Load new Sounds
Frame 5 - Load new images
Frame 6 - Create new sprites

This is just an example. you do whatever is best for your situation.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Jun 2015 13:49
Ok, Thanks.

I ask if there was a problem.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jun 2015 14:56
Only delete stuff if you have to, re-use sprites as much as possible, and avoid using deleteall commands - you should really know what sprites etc your using, so take control over them.

Even if it means you don't auto-assign media ID's, deleting everything should only be done if absolutely necessary, it's slow and just using your own ID's means you only need to step through them and delete them, or disable them. Delete all may well have to step through the entire scope of sprites - you might use sprite ID 1, and sprite ID 10,000, that means 10,000 iterations... but what I'm saying is that there are other things that have to happen in the background when using delete all or auto-id's, things that your probably better off looking after yourself.

Say for example your player sprite is sprite 99, GUI elements and other permanent sprites are 1 to 98 say - you could make everything else sprites 100+ and you would know to delete sprites 100 to whatever, leaving the permanent sprites alone.

One small note on Batvinks suggestion... always delete sprites before images - if you were throwing an old chair on a bonfire, you would make sure someone isn't sitting in it first - I don't like the idea of sprites existing that relate to an image that no longer exists.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Jun 2015 15:10
Quote: "One small note on Batvinks suggestion... always delete sprites before images"


Well spotted. I have edited my post. Although the chair analogy isn't entirely accurate, sometimes I'd be tempted not to check the chair first

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-04-19 07:40:29
Your offset time is: 2024-04-19 07:40:29