Skip to main content

News

Topic: Question about SetRenderScript() (Read 1807 times) previous topic - next topic

Question about SetRenderScript()
Does running stuff through SetRenderScript mean you can't use FlipScreen() any longer, even if they're not using the SetRenderScript function?

Meaning to blit everything, you'll have to run it all through SetRenderScript?

Re: Question about SetRenderScript()
Reply #1
When the map engine runs, a part of what it does is call FlipScreen (well, not exactly the same function, but close enough). You can't really use FlipScreen when the map engine is running anyway, at least not to the same effect as when it isn't. It's done for you, so that the map itself renders every frame.

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Question about SetRenderScript()
Reply #2
Yeah. But you can make the renderscript into some kind of rendering array in which you keep pushing and removing things you want to render. You have all freedom. :)

Consider these two cases:
  • You're not running the map engine. You need to properly take care of controlling the frame rate, updating and blitting your stuff and flipping the screen.
  • You're running the map engine. It takes care of flipping the screen for you, so you just put render commands in the renderscript.

    That's just how it is. Of course, you could be doing this:
  • You're running the map engine, but you've gone in some closed loop in your own code, meaning the map engine isn't updating by itself any more until it escapes your loop. You can do whatever you like with the rendering, like in the first case.
    But that just complicates so much and basically makes you do a lot more work to keep things working in the map engine.

Re: Question about SetRenderScript()
Reply #3

When the map engine runs, a part of what it does is call FlipScreen (well, not exactly the same function, but close enough). You can't really use FlipScreen when the map engine is running anyway, at least not to the same effect as when it isn't. It's done for you, so that the map itself renders every frame.


So, FlipScreen is basically for things like Title-Menus
and stuff that goes on before the Map is even running, correct?

Because what I'm trying to do now is just create a simple menu
that lays over what's going on and pauses the game.
However, I think that it's being conflicted with the SetRenderScript() since FlipScreen() is called.

Now that I think of it in perspective about Title-Menus and stuff, Davince's comment makes ALOT of sense now.

. . .

So what about if I want to use the GrabImage() function?
Running it through SetRenderScript() wouldn't be the same because the Map is still running right?

Is there a way to draw a pause-menu with the map in the background through SetRenderScript()?
Example from previous projects anyone know of, or where/how I would start?

Looking through the API right now, has nothing about pausing the Map.
I see GetMapEngine(), ExitMapEngine(), IsMapEngineRunning(), UpdateMapEngine().
  • Last Edit: July 07, 2013, 07:46:15 pm by Vakinox

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Question about SetRenderScript()
Reply #4
Quote
So, FlipScreen is basically for things like Title-Menus
and stuff that goes on before the Map is even running, correct?

Not quite. You can stop the map engine in its tracks and do some things in the middle.

If you want the game to pause, it's fine to get into some closed loop, like in the third bullet point mentioned. The map engine will only continue once it exits that loop (it's when you actually need the map to continue as normal that this situation would be suboptimal... But not in a case where you're doing other stuff over a pic of the map or while the map engine was still running, anyway). So something like this very simple, very crappy example:

Code: (javascript) [Select]
function MyTitleScreen() {
  while (true) {  //Map engine is paused while in this loop... or rather, it doesn't even get the chance to continue, Sphere being stuck here...
    RenderMap();  //Display the last known picture of the map
    font.drawText(100, 100, "Game Title!");  //Drawn on top of that picture
    //Other drawing stuff maybe
    FlipScreen();  //Now put it on the screen
 
    if (GetKey()) break;  //Break out of the loop and continue the map engine if any key is pressed
    //Keep loopin' otherwise!
  }
}

And then in some place, you invoke MyTitleScreen(). Not as a render script, but as a regular function call.

On a side note, UpdateMapEngine() manually updates the map engine, so you can make the stuff that was happening on the map still update during that closed-off loop. You'll mostly notice it with animated tiles and persons if you do that.

Edit: updated.
  • Last Edit: July 07, 2013, 06:35:26 pm by DaVince

Re: Question about SetRenderScript()
Reply #5
Awesome, that worked bro!
Good explanation.