Fullscreen renderer sequence

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting. You may Image to help finance the hosting costs of this forum.
Post Reply
User avatar
Gambit37
Should eat more pies
Posts: 13772
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Fullscreen renderer sequence

Post by Gambit37 »

^^ Not sure you ever saw the above tutorial request?

Also, another one :) How can I create a sequence of fullscreen renderers that play in sequence, and each one fades frm one to the next after either (a) a period of time and/or (b) a mouse click?

For example, I'd like a sort of "attract" sequence that after a set amount of time on the title screen will then rotate through 2-3 screens in a sequence and then return to the title screen... I can string together a bunch of renderers one after the other which will work on a mouse click, but I can't work out how to set them to work automatically in sequence on a timer...?
User avatar
Sophia
Concise and Honest
Posts: 4307
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Fullscreen renderer sequence

Post by Sophia »

Gambit37 wrote:^^ Not sure you ever saw the above tutorial request?
I saw it. I haven't gotten around to it, yet, sorry.
Gambit37 wrote:How can I create a sequence of fullscreen renderers that play in sequence, and each one fades frm one to the next after either (a) a period of time and/or (b) a mouse click?
A non-nil return value from any of the functions called by a fullscreen renderer will end it.
There is a helpful click function called EXIT_ON_CLICK that will handle the mouse clicks, and you can do the timing in an update function, which is called 5 times a second, the same rate as DSB's game timer.

Here is code to display gfx.full_screen_graphic for 30 seconds, or end it early if the user clicks.

Code: Select all

function my_graphics_timer()
   gt_timer = gt_timer + 1
   if (gt_timer > 5*30) then
      return true
    end
end

gt_timer = 0
dsb_fullscreen(gfx.full_screen_graphic, EXIT_ON_CLICK, my_graphics_timer, false, true)
User avatar
Gambit37
Should eat more pies
Posts: 13772
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Fullscreen renderer sequence

Post by Gambit37 »

Aha, right, thank you. I saw that the fullscreen renderer had an update_func but I still wasn't sure how that would work. I keep having this mental block that the renderer "locks up" the running of the rest of the game, so I forget it's doing stuff every tick anyway!
User avatar
ian_scho
High Lord
Posts: 2807
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

Re: Fullscreen renderer sequence

Post by ian_scho »

Gambit37 wrote:I keep having this mental block that the renderer "locks up" the running of the rest of the game, so I forget it's doing stuff every tick anyway!
My pseudo-code is from the 0.40 version, so things may have changed somewhat:

Code: Select all

    -- During an event, pause the planet.
    dsb_lock_game(LOCK_MONSTERS)
    dsb_lock_game(LOCK_MOVEMENT)
    dsb_lock_game(LOCK_INVENTORY)
    dsb_lock_game(LOCK_CONDITIONS)
    dsb_lock_game(LOCK_MAGIC)

    -- The full-screen renderer will run until any of its associated functions returns something other than false or nil. 
    dsb_fullscreen(
        PARM Draw Function for each frame,
        PARM Click Function,
        PARM Update Function, called each 'game tick'. It takes no parameters,
        PARM Mouse cursor (== true to show the yellow cursor)
    )

    -- End.  Let the world move on.
    dsb_unlock_game(LOCK_MONSTERS)
    dsb_unlock_game(LOCK_MOVEMENT)
    dsb_unlock_game(LOCK_INVENTORY)
    dsb_unlock_game(LOCK_CONDITIONS)
    dsb_unlock_game(LOCK_MAGIC)
User avatar
Sophia
Concise and Honest
Posts: 4307
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Fullscreen renderer sequence

Post by Sophia »

I would like to clarify that this is pseudo-code explaining what is going on.
You do not need to actually lock anything, because the game logic does not advance while in dsb_fullscreen.
User avatar
ian_scho
High Lord
Posts: 2807
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

Re: Fullscreen renderer sequence

Post by ian_scho »

Sophia wrote:the game logic does not advance while in dsb_fullscreen.
I never knew this! Thanks for clarifying.
Post Reply