It is currently Thu Nov 21, 2019 12:51 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Best practice for game intro, ingame movie playback.
PostPosted: Wed Aug 13, 2014 7:48 am 
Offline
User
User

Joined: Fri Mar 11, 2005 6:24 pm
Posts: 49
Location: Toronto
Hi,

What's the best practice to play video in the beginning of a 2D game and in between levels? Do I have to open a new screen for the movie, and then close it and open a new screen for the game(play) itself? Once the video is done, how do I jump automatically to the (let's say) main game loop? The Movie.pb example plays the movie once and then I have to manually close the window. Is there any command to detect that the movie is done, or do I have to give the exact length of the movie manually and make it stop after the time is up?

For example, I have an intro for Waponez II and I want to play it before the game starts. What's the best practice to do that? Code please!

Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Best practice for game intro, ingame movie playback.
PostPosted: Wed Aug 13, 2014 9:00 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Apr 15, 2013 12:22 pm
Posts: 519
Hmm, you´re asking for code, here´s code:

Code:
InitMovie()
mov = LoadMovie()
PlayMovie(mov, ScreenID())
Repeat
  ExamineKeyboard()
  RenderWorld()
  FlipBuffers()
Until KeyboardReleased(#PB_Key_Esc) Or MovieStatus(mov) = 0       ;I´m not sure with that, a finished movie isn´t documented.
FreeMovie(mov)


There is another possibility. You copy each frame of your movie and fill a sprite with it (I´m interested in this solution, too).
Or is it possible to use a movie in a materialscript?

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Best practice for game intro, ingame movie playback.
PostPosted: Wed Aug 13, 2014 1:39 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:34 pm
Posts: 918
Location: Canada
One of the coolest features that was removed in 5.20LTS for some reason was the ability to render your movie frames to a sprite and then manipulate it like any other sprite.
Sure would be nice if this was put back in... or at least something very similar.

_________________
Image Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Best practice for game intro, ingame movie playback.
PostPosted: Wed Aug 13, 2014 1:41 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5856
Location: Wales, UK
...you could perhaps display a regular window playing the movie?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Best practice for game intro, ingame movie playback.
PostPosted: Wed Aug 13, 2014 6:03 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 796
Location: Denmark
Perhaps something like this?

Code:
InitSprite():InitKeyboard():InitMovie()

Declare.i DoMovie()
Declare.i DoGame()
Declare.i DoMovie2()

OpenWindow(0, 0, 0, 1024, 768, "Game/movie", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768, 0, 0, 0, #PB_Screen_SmartSynchronization)


Procedure.i DoMovie()
  Protected mov.i, Done.i
  Done = 0
  mov = LoadMovie(#PB_Any, "E:\1.avi")
  ResizeMovie(mov, 0, 0, 1024,768)
  PlayMovie(mov, ScreenID())
  Delay(1000)  ;<---delay To make sure, that moviestatus isn't 0 right away

  Repeat
    Repeat:ev = WindowEvent():Until ev = 0
   
    If MovieStatus(Mov) <= 0
      done = 1
    EndIf
   
  Until done = 1
  FreeMovie(mov)
  ProcedureReturn 0
EndProcedure

Procedure.i DoGame()
 
  Repeat
    ClearScreen(0)
    StartDrawing(ScreenOutput())
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawText(100,100,"Game Screen",$FF00FF)
    StopDrawing()
   
    Repeat:ev = WindowEvent():Until ev = 0
   
    ExamineKeyboard()
   
    FlipBuffers()
   
    If KeyboardReleased(#PB_Key_Space)
      ret = DoMovie2()
    EndIf
   
  Until KeyboardPushed(#PB_Key_Escape)
 
EndProcedure

Procedure.i DoMovie2()
  Protected mov.i, Done.i
  Done = 0
  mov = LoadMovie(#PB_Any, "E:\2.avi")
  ResizeMovie(mov, 0, 0, 1024,768)
  PlayMovie(mov, ScreenID())
  Delay(1000)  ;<---delay To make sure, that moviestatus isn't 0 right away

  Repeat
    Repeat:ev = WindowEvent():Until ev = 0
   
    If MovieStatus(Mov) <= 0
      done = 1
    EndIf
   
  Until done = 1
  FreeMovie(mov)
  ProcedureReturn 0
EndProcedure

ret = DoMovie()
DoGame()

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 7/10, Intel 6800K, Gtx 970, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Best practice for game intro, ingame movie playback.
PostPosted: Wed Aug 13, 2014 10:00 pm 
Offline
User
User

Joined: Fri Mar 11, 2005 6:24 pm
Posts: 49
Location: Toronto
Thanks guys! I appreciate it!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye