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.

Picture commands

I've looked around and seen that there isn't a 'good' way of opening .avi files in RPG Maker XP, but there have been ideas of using frame by frame pictures. this is all wonderful but that leaves for events to be very very cluttered with show picture: xxx1.bmp wait 1f delete picture 1, show picture: xxx2.bmp, rinse and repeat.

So the idea of simply making a script that could parse out the name of the pictures related to each frame.
Example: Frame one could be Intro-1.bmp, F2 could be Intro-2.bmp.
The parsing script would copy the name up to the '-', then say maybe we could increment which number to load in a repeat. Then we could maybe set maximum number to signal the total frames. If there were 60 frames in said video, after it's hit its 60th frame, the loop would end.
I apologize if this makes no sense, but for example:


Total_Frames = 60
IMG Load: Intro-1.bmp
#parse the image name up to the "-", store info somewhere

Loop (while imgload < 59):
IMG Load: (saved info data) ++ 1; #<- this will search for the next image number
Wait 1;
Remove Image
end loop

Or of that effect. I've worked with C++ a long while back, but i'm out of the loop. I apologize if what i said seems like a bunch of junk.

anyway, I'm quite sure something to this effect could be scripted. I'm just not sure how. Any help please?
 
Here, this doesn't need to parse the image name, you only input the first part ("Intro-"), and it will add the suffix as it cycles.
It will stop cycling when it cannot find a file with the next suffix.
I also added an option to control the speed, because without it, it goes pretty fast.
This returns to Scene_Map when finished. (I assumed). If you want something else, or to control where it goes, let me know.

Code:
# Scene_Animate
#
# Call this scene to animate a series of images
#
# $scene = Scene_Animate.new("filename")
#
# where 'filename' is the basename of the images.
#
# EXAMPLE:
#
#   Scene_Animate.new("MyPic")
#
# will animate MyPic1.png, MyPic2.png, MyPic3.png, etc...
# until a file is not found.
#
# filename suffixes start with 1
#
# To control the speed, set @anim_speed to the number of frames to wait before
# loading the next image in the sequence.
##############################################################################
class Scene_Animate
  def initialize(filename)
    #set speed. number of frames to pause on one image
    @anim_speed = 5
    @filename = filename
  end
  def main
    @picsprite = Sprite.new
    @picsprite.bitmap = Bitmap.new(640,480)
    @suffix = 1
    Graphics.transition
    count = 0
    loop do
      Graphics.update
      Input.update
      count += 1
      if count == @anim_speed
        @picsprite.bitmap = RPG::Cache.picture(@filename + @suffix.to_s) rescue nil
        if @picsprite.bitmap == nil
          break
        end
        @picsprite.update
        @suffix += 1
        count = 0
      end
    end
    @picsprite.dispose
    $scene = Scene_Map.new
  end
end

Be Well

Ref: Ricoman_Title
 
Good question. I don't see any lag on my PC. (remember, I added the speed control because it was going too fast.)

[ edit ] I assume you were testing with a speed of 1

What if we cache all of the bitmaps first, then display them. There will be a little lag at the beginning, but the animation might run smoother.

Code:
# Scene_Animate
#
# Call this scene to animate a series of images
#
# $scene = Scene_Animate.new("filename")
#
# where 'filename' is the basename of the images.
#
# EXAMPLE:
#
#   Scene_Animate.new("MyPic")
#
# will animate MyPic1.png, MyPic2.png, MyPic3.png, etc...
# until a file is not found.
#
# filename suffixes start with 1
#
# To control the speed, set @anim_speed to the number of frames to wait before
# loading the next image in the sequence.
##############################################################################
class Scene_Animate
  def initialize(filename)
    #set speed. number of frames to pause on one image
    @anim_speed = 0
    @filename = filename
  end
  def main
    @picsprite = Sprite.new
    @picsprite.bitmap = Bitmap.new(640,480)
    @suffix = 1
    loop do
      Graphics.update
      @picsprite.bitmap = RPG::Cache.picture(@filename + @suffix.to_s) rescue nil
      if @picsprite.bitmap == nil
        break
      end
      @suffix += 1
    end
    Graphics.transition
    @suffix = 1
    count = 0
    loop do
      Graphics.update
      Input.update
      if count == @anim_speed
        @picsprite.bitmap = RPG::Cache.picture(@filename + @suffix.to_s) rescue nil
        if @picsprite.bitmap == nil
          break
        end
        @picsprite.update
        @suffix += 1
        count = 0
      else
        count += 1
      end
    end
    @picsprite.dispose
    $scene = Scene_Map.new
  end
end

Give that a shot
 
Yes, I used a wait of 1.
This one does make the animation run smoother. I'm trying to make the animations run at a smooth rate for most PC's. On my desktop, it did in fact run fast. I see this will be a problem though because there doesnt seem to be a form of common ground on speed. What seems fast on your PC was terribly slow on mine. This causes a problem when/if I distribute a game using this feature.

More or less - filling the cache with all images can be very strenuous on a 'not so modern' pc. Would there be a way to maybe cache the next X amount of images ahead of the current frame, while still playing?
 
You could cache the first image before the loop, then in each loop cache the next image & display the current image. But I don't think that will help since the processor is still doing the same amount of work. The images need to be cached ahead of time to have any effect.
If you're not using too many of these animations, you do the caching earlier, like in Scene_Title, or even before.

I wonder if we wrote the "bitmaps" array out to a file, or even a cache with only one series of images for a single animation, then when we need the images pre-loaded, just dump that file to either the "bitmap" array, or directly back to the cache?
I'll experiment with it.

Anyone else got a brilliant idea??? :scruff:

Be Well
 
ah, right. i wasnt fully thinking there.

I have tossed around the idea of making a 'film strip' type animation. Link all the related images into just 1 big file, then have it scroll in such a direction to replicate a film. with that option I might be able to make an animation play at a set speed no matter how fast the cpu. (unless its just really really archaic....).

The problem with img lagging in this current method is that if one were to play a sound file to try to sync with the happenings on the 'film', it would clearly go off course, and would be a big mess of ew. This new idea may fix that problem.
I could tinker with that.

ATM I'm using my notebook which, quite frankly, has the specs of a 98 model high end pc at best... :(

I should try to study up on my programming and take up a bit of ruby, methinks.

Thank you for your help though, it was very useful =)
 

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