cadin / panels

Build interactive comics for the Playdate console.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make panels useable in another project as a separate library

unbelievableflavour opened this issue · comments

Panels is currently only useable for only using panels. Please make it so that I can call panels at any moment in a game. and close it at any moment so that it can be used for cutscenes!

Can you explain more about how you would expect this to work?

So ofcourse it all depends on if this is within project scope or not, and I completely understand if it's not and then you can close this. But what I am trying to do is use Panels for cutscenes.
Currently when Panels is imported, it overwrites the playdate.update() function with the one from Panels. It would be cool if this was optional so you could manually call the playdate.update() from Panels manually from your project only when needed.

So for instance my update would look something like.

function playdate.update()
    if isRunningPanels then
        Panels.Update() -- a custom update function for Panels.
        return
    end

   -- otherStuff not related to panels.

end

function startPanels()
   isRunningPanels = true
   Panels.Start(myPanelsData)
end

function stopPanels()
   isRunningPanels = false
   Panels.Stop() -- a new Stop function for Panels that closes the Panels app, to continue the game or app.
end

Then when I want to start running Panels; I would call startPanels()
Then when I want to stop running Panels; I would call stopPanels()

Let me know if you need more explanation or if this is enough + if this is in scope or completely out of scope of the project. Would be really cool to be able to use Panels within games and apps.

Thanks for the info.
As you noted, Panels comics are meant to be their own standalone game. I'm considering this out of scope for now, but may come back to it later. Feel free to continue to add comments here if you have more thoughts about it.

Some notes:

How would the game know when to stop Panels?

  1. Set callbacks to notify the game when each sequence is complete.
    The game would halt the comic and resume the gameplay when the desired sequence is reached.
  2. A mode where Panels quits automatically after completing the comic (instead of returning to the menu).
    In this mode, the game would set just the comicData for the current cut scene, start Panels and wait for it to complete. Probably still need a callback in this mode to know when to resume gameplay.

Menus

When used for cutscenes Panels wouldn't add the Credits or Chapters options to the system menu.
Would have to provide an alternate way for games to display the Panels credit & link since it currently appears in the Credits menu.

Start & Stop

Panels.stop() is probably not needed. You'd just stop calling Panels.update() once your game gets the callback that the cutscene is complete.

Most of what happens in start() is creating the system menus etc. which also wouldn't be needed. Perhaps you invoke the cutscene with a different method that also signals Panels to use cutscene mode.

Panels.start(data) creates a standalone game as it does now, and Panels.startCutscene(data) starts a comic in cutscene mode.

@unbelievableflavour @simjnd
I added cutscene support in a temporary dev branch: panels/cutscene-support

The way this works is instead of calling Panels.start(), you call Panels.startCutscene(data, callback) where data is the comicData for the entire cutscene and callback is a function in your game that will be called when the cutscene finishes.
While the cutscene is running (until your callback is called) call Panels.update() from your main Playdate update loop.
When the cutscene completes, simply stop calling Panels.update().

It's up to you to keep track of when a cutscene is running (and which one to start) in your main game code.

I created a very simple example of how this works: panels-cutscene-example
In this game you use the arrow keys to move a box around, and press the A button to trigger a cutscene and move to the next "level".

The main caveat is that input handlers and button callbacks in your main game may continue to get triggered while the cutscene is active unless you code around that in your main game (see example).

Let me know if this will work for your use case, or if you'd need some other functionality I haven't thought of.

panels_with_cotton
Here is an example of it working with Cotton! very cool

Very cool.

Ideally the transition between game and comic would be less abrupt somehow, but I think that might have to be up to the game (like wipe or fade to a blank screen before starting the comic). Let me know if you think there's something I can do on my end to make that easier.

Also, I'll eventually be merging that change into the main branch at which point you might need to update your wiki.

Yeah, the transition is completely up to the game dev. Let me know when you merge this into master. I'll update it immediately after :)

I was also thinking. That it might be nice to move the cutscenes stuff into a separate library since the use is completely different. There might be a lot of stuff now that will never be used when you use Panels only for cutscenes.

Or is that everything still necessary?

It's mostly all still needed except for the parts that do the menus for chapters, credits, etc.

Maybe just keep it together then for now. Easier to manage.

This change is now merged into the main branch and released as v1.1

Thnx, updated docs to use master. So you can remove the branch!