- Pokémon Essentials Version
- v17.2 ➖
Hey everyone! Do you remember the RGSS FmodEx extension ?
Today I'll share the RGSS Gif extension that allows your game to read Gif file from Memory or from the disc.
In order to use the script you'll need different things :
- The RGSS Linker dll : https://github.com/NuriYuri/RGSS-Linker/raw/master/RGSS Linker.dll
- The RGSS Gif dll : https://github.com/NuriYuri/RGSS-Linker/raw/master/RGSS Gif.dll
- Having the RGSS104E.dll renamed as your primary RGSS Library. (Otherwise the RGSS Linker won't load)
- The Following scripts :
If you want informations about the GifReader here is a little doc :
Create a new GifReader.
If from_memory is false (or not set), it'll load the gif from its filename
If from_memory is true, it'll load the gif using the filename variable as its contents.
It'll return the width of the Gif image.
It'll return the height of the Gif image.
It'll return the current frame the Gif reader draw to the bitmaps.
The current frame the Gif reader will draw to the bitmaps will be value.
It'll return the number of frame the Gif contains.
It'll update the Gif reading process and if the frame change, it'll draw it in the bitmap.
It'll draw the current frame in the bitmap.
It'll change the time added to the internal gif counter to ms_time (in ms).
If your game runs at 40 frame per second, write : Yuki::GifReader.delta_counter = 25
If your game runs at 60 frame per second, write nothing or write : Yuki::GifReader.delta_counter = 16
Voilà :) Don't forget the credits. Feel free to use it on anything that runs RGSS 1.
Today I'll share the RGSS Gif extension that allows your game to read Gif file from Memory or from the disc.
In order to use the script you'll need different things :
- The RGSS Linker dll : https://github.com/NuriYuri/RGSS-Linker/raw/master/RGSS Linker.dll
- The RGSS Gif dll : https://github.com/NuriYuri/RGSS-Linker/raw/master/RGSS Gif.dll
- Having the RGSS104E.dll renamed as your primary RGSS Library. (Otherwise the RGSS Linker won't load)
- The Following scripts :
RGSS Linker Script
Code:
# Module that contains common private method of Objects
module Kernel
unless @RGSS_Linker #>To avoid the RGSS Reset problem
@RGSS_Linker = {:core => Win32API.new("RGSS Linker.dll","RGSSLinker_Initialize","p","i")}
Win32API.new("kernel32","GetPrivateProfileString","ppppip","i").call("Game","Library",0,lib_name = "\x00"*32,32,".//Game.ini")
raise LoadError, "Failed to load RGSS Linker." unless(@RGSS_Linker[:core].call(lib_name)==1)
lib_name = nil
module_function
# Loads an RGSS Extension written with the RGSS Linker.
# @author Nuri Yuri
# @param module_filename [String] the name of the dll file that contains the extension.
# @param module_function [String] the name of the C function that loads the extension.
def load_module(module_filename, module_function)
return ::Kernel.load_module(module_filename, module_function) if self != ::Kernel
return if @RGSS_Linker[module_filename]
mod = @RGSS_Linker[module_filename] = Win32API.new(module_filename, module_function, "", "")
mod.call
end
end #>unless @RGSS_Linker
end
The RGSS Gif extension loading script
Code:
load_module("RGSS Gif.dll","InitGif")
Yuki::GifReader.delta_counter = 25
The GifSprite wrapper
Code:
# GifSprite class, read Gifs
# @author Luka S.J. (wrapper)
class GifSprite < Sprite
# Set the gif to the sprite
# @param filename [String] the gif filename or if from_memory = true, the contents of the gif file
# @param from_memory [Boolean] if the Gif is read from Memory
def setGif(filename, from_memory = false)
@reader = Yuki::GifReader.new(filename)
self.bitmap = Bitmap.new(@reader.width,@reader.height)
end
# Update the bitmap surface of the sprite with the current gif frame
# @return [Yuki::GifReader] the gif reader
def update
@reader.update(self.bitmap)
end
end
If you want informations about the GifReader here is a little doc :
Code:
reader = Yuki::GifReader.new(filename, from_memory)
If from_memory is false (or not set), it'll load the gif from its filename
If from_memory is true, it'll load the gif using the filename variable as its contents.
Code:
reader.width
Code:
reader.height
Code:
reader.frame
Code:
reader.frame = value
Code:
reader.frame_count
Code:
reader.update(bitmap)
Code:
reader.draw(bitmap)
Code:
Yuki::GifReader.delta_counter = ms_time
If your game runs at 40 frame per second, write : Yuki::GifReader.delta_counter = 25
If your game runs at 60 frame per second, write nothing or write : Yuki::GifReader.delta_counter = 16
Voilà :) Don't forget the credits. Feel free to use it on anything that runs RGSS 1.
- Credits
-
Enterbrain - RGSS
Microsoft - GDI+
@Nuri Yuri - RGSS Linker, RGSS Gif (C++)
Additionnal credits :
@Luka S.J. - The GifSprite wrapper (if used)