Can you have two worlds open at the same time ? And performance question


(Adam Edney) #1

Is there a way to save a world e.g. the player is in the options screen while the main game screen is paused?

The performance question is, I have a really big function which can take 0.2 of a second to process but is there away to keep the frame rate running while processing processing (I know it would take longer to process).

Thanks, Adam


(Jean) #2

For the first question, yes, just save the FP.world on a temporary variable before changing to the options world. When the player closes the options world, get back the value of the world that you saved on the variable.

For the second question, I don’t think that you can make a Thread inside FP, maybe divide better your code to run a little bit every frame?


(Adam Edney) #3

Thanks for the quick reply, I found this about memory threading http://www.bytearray.org/?p=4423 I will try this tomorrow


(Martí Angelats i Ribera) #4

What does that function do?

Maybe you can precalculate it while loading the game (before start playing). Also you may be able to do a bit every frame. You can also use Workers but remember that they won’t be syncronized with the game framerate.


(Zachary Lewis) #5

You’re playing a very dangerous game. FlashPunk was designed for single-thread execution, so I’m not sure how the library will react to this black magic.


(Adam Edney) #6

The function is for a card game, so its calculating the next move, so it takes a few milliseconds which stops the frame rate which doesn’t look great.


(Adam Edney) #7

I dont think its going to work, the Flex SDK doesn’t support workers in the same way as other SDK. Any suggestions in keeping the frame rate high when calculating?


(Zachary Lewis) #9

Break the calculation into multiple frames.

If your algorithm calculates every possible move and only keeps the current “best” move, this could take a long time. Instead of looping over all moves, only let your game check ten moves each frame. It’ll take more frames, but it won’t appear to lock up your game. Just throw up a little “thinking” animation, and it’ll look great.


(Adam Edney) #10

Yh I think I will break my code over lets say 30 frames then I can add a loading bar and there will be no lag for the gui. Thanks for the advice.

P.s is Flash Punk still getting developed or is it now complete?


(Martí Angelats i Ribera) #11

Also if you show us your algorithm we may be able to help you :smiley:

And FP is not being developed officially (if there is such a thing XD) but i’m trying to make a Beta version of a FP2 but it will take a few months to finish it.


(Adam Edney) #12

Thanks for the reply

Its not really possible to show you the code because its over 2500 lines long (that’s the problem). I will work on simplifying it tomorrow (I have a few ideas). One suggestion on FP2 (add a GUI frame work as I hate making my own (but im testing another GUI framework called ASDPC library which Im also trying out tomorrow after work)).


(Martí Angelats i Ribera) #13

Any idea can be posted in this thread (it’s mostly the list of features).