Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

berka's Video script II reloaded!

berka's Video script II reloaded!


Version: 1.2 # updated 25/02/2009
By: berka

Introduction
This is my ultimate version of video script. I saw that there are so many questions about the video scripts. I tried to make it as simple as possible.

Features
-fullscreen mode
-audio settings
-video resizing
-advanced video types support
-use is easier
-choice of the scene back
-film can be launched in a script or in an event

Screenshots
none

Demo
the demo

Script
Code:
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#                            -  Game_Film II - reloaded ^^

#  par berka

#                          www.rpgmakervx-fr.com                                          

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#  Rgss 1&2                  v 1.2

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#                          -Utilisation-

# write in an event, "call script" command

#

# #minimum required:

# [film]                    # essential !

# film = myfilm.avi         # or mpg... name of file to read

#

# #optional configuration, order doesn't matter

# Put 4 coordinates or none!

# x = 12                    # horizontal position

# y = 1                     # vertical position

# w = 150                   # film resizing: width

# h = 150                   # film resizing: height

# 

# full = true               # fullscreen or not

# vol = 750                 # between 0 & 1000 audio volume

# bass = 999                # between 0 & 1000 basses volume

# aig = 250                 # between 0 & 1000 trebble volume

# ret = Scene_Map           # return to Scene_XXX when the films ends

# #commands:

# key B to quit, C to pause the film 

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

 

class Game_Film

  def initialize(hash)

    hash.has_key?(:film) ? film=hash[:film] : return 

    hash.has_key?(:x) ? @x=hash[:x]+" " : @x="0"

    hash.has_key?(:y) ? @y=hash[:y]+" " : @y="0"

    hash.has_key?(:w) ? @w=hash[:w]+" " : @w=""

    hash.has_key?(:h) ? @h=hash[:h]+" " : @h=""

    hash.has_key?(:vol) ? @vol=hash[:vol]+" " : @vol="1000"

    hash.has_key?(:bass) ? @bass=hash[:bass]+" " : @bass="1000"

    hash.has_key?(:aig) ? @aig=hash[:aig]+" " : @aig="1000"

    hash.has_key?(:pos) ? @pos="at pos #{hash[:pos].to_i*1000} " : @pos="at pos 0 "

    @ret='$scene='<<hash[:ret]<<'.new' if hash.has_key?(:ret)

    @full=hash[:full] if hash.has_key?(:full) 

    @full&&dim_ecran !=[640,480] ? @plee="fullscreen " : @plee=""

    @type=" "

    @type=" type mpegvideo" if File.extname(film)==(".mpg"||".mpeg")

    @type=" type avivideo" if File.extname(film)==".avi"

    @nom='./Films/'+film 

    (p "fichier #{@nom} non trouvé";return) if !FileTest.exist?(@nom)

    @film=Win32API.new('winmm','mciSendString','ppll','v')

    lecture

  end

  def handle

    jeu="\0"*256 

    ini=Win32API.new('kernel32','GetPrivateProfileStringA','pppplp', 'l')

    ini.call('Game','Title','',jeu,255,".\\Game.ini")

    return Win32API.new('user32','FindWindowEx','llpp','l').call(0,0,nil,jeu.delete!("\0"))

  end

  def lecture

    v,t,status,pause=version,Time.now," "*255,false

    @film.call("open #{@nom} alias FILE#{@type} style child parent "+handle.to_s,0,0,0)

    @film.call("put FILE window at #{@x}#{@y}#{@w}#{@h}",status,255,0)

    @film.call("setaudio File volume to #{@vol}",status,255,0)

    @film.call("setaudio File bass to #{@bass}",status,255,0)

    @film.call("setaudio File trebble to #{@aig}",status,255,0)

    @film.call("play FILE #{@plee} notify",status,255,handle)

    loop{sleep(0.1) 

      Input.update 

      @film.call("status FILE mode notify",status,255,0)

      break if status.unpack("aaaa")=="stop".split(//)||Input.trigger?(Input::B)

      if Input.trigger?(Input::C) 

        if !pause;@film.call("pause FILE notify",status,255,handle);pause=true

        else;@film.call("play FILE #{@plee} notify",status,255,handle);pause=false

        end      

      end

      (t=maj(t))if v=='xp'}

    @film.call("close FILE notify",0,0,handle) 

    @ret.nil? ? $scene=Scene_Map.new : eval(@ret)

  end

  def dim_ecran

    lw=Win32API.new('user32','GetSystemMetrics','i','i')

    return lw.call(0),lw.call(1)

  end

  def maj(t)

    (Graphics.update;return Time.now)if t.sec<=Time.now.sec-9||t.min !=Time.now.min

    return t

  end 

end

Dir.open("./Films") rescue Dir::mkdir("./Films",0777) 

class Game_Interpreter;def eval(script);cmd_eval(script);end;end#rmvx

class Interpreter;def eval(script);cmd_eval(script);end;end#rmxp

def cmd_eval(script)

  if script.include?("[film]")

    hash={}

    script.gsub!("[film]"){}

    list=script.split("\n")

    list.each{|e|e.gsub!(" "){};f=e.split("=");hash[f[0].to_sym]=f[1] if !f[1].nil?}

    Game_Film.new(hash)

  else;return Kernel.eval(script)

  end

end

def version;FileTest.exist?('./Data/scripts.rvdata') ? 'vx': 'xp';end

def call_film(script)

  version=='vx' ? i=Game_Interpreter : i=Interpreter

  i.new.cmd_eval(script) 

end

Instructions
puts this script above main and run the game first: a Videos directory will be created !
then add your videos files into.
and call the video with an event (call script) like this:

FAQ
example in an event's call script command
Code:
[film]

film = test.avi

aig = 999

bass = 0
in a script:
Code:
script=<<__END__

 

[film]

film=test.avi

ret=Scene_Map

full=false

 

__END__

call_film(script)

Compatibility
I really don't know !

Credits and Thanks
Corwin & squall for the basic video script

Terms and Conditions
Free for using, but I need credits. Do not post this script anywhere without my permission !

enjoy,
berka
 
Cool script, i was testing it a moment ago but im not sure if the sound works as i only got a non sound one. I hope it can also run other video files extension aside from .avi, really rocks. :haha:
 
sorry, I think I do not understand your issue...

does the video hang ?
you have any sound ?
the video des not play fluently ?
What is your file's format ?
 
mmm, berka, I know this man.....
wait a minute ! you'r berka, isn' it ?
well.. I'll speak french with you, this'll be easy.
berka mon ami ! c'est moi Yagami, de rmxpstudio !
Ton script est cool, tu sais. Bah, pour moi j'ai testé la démo, et ça marche trés bien.
 
Insert this below the video script:

Code:
begin

  film = {

    # Name of video file

    :film => 'Name.avi',

    # Video Dimensions & Posiiton

    :x => 'x',

    :y => 'y',

    :w => 'width',

    :h => 'height',

    # Volume, Bass & Trebble

    :vol => 'vol',

    :bass => 'bass',

    :aig => 'treb',

    # For full screen

    :full => true

  }

  Game_Film.new(film)

end

I am not really familiar with this script, but that should be all you need to do.


@berka: Shouldn't that instance be @aig?
Code:
     @film.call("setaudio File trebble to #{@bass}",status,255,0)

I could be wrong.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top