Skip to content

Automate image movements/effects and sounds over a period of time, useful for games.

Notifications You must be signed in to change notification settings

ippa/movie_maker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MovieMaker README

github.com/ippa/movie_maker/tree/master

DESCRIPTION

Automate image movements/effects and sounds over a period of time, useful for games.

What is it?

A rubylibrary to automate sprite movement/effects and sound over a timeline. Either Rubygame (SDL) or Gosu (OpenGL) does the heavy lifting for us when it comes to drawing on the screen. MovieMaker transparently supports both gamelibraries.

Use it for intros, ingame animations and simple “demos”. Namingconventions tries to follow Rubygame. It’s also easy extendable with own actions. Documentation about that comming as soon as someone wants it =).

Features:

Basic:

  • @movie = MovieMaker.new

  • @movie.resource(@sprite) - choose a resource (for now, a sprite) that following commands will apply on

Timeline methods

  • @movie.between(start_at, stop_at) - following actions are performered between start_at/stop_at (seconds in floats)

  • @movie.at(start_at) - following actions are performered once at start_at seconds into the movie

  • @movie.delay(delay) - pause timeline for delay seconds

  • @movie.during(time) - perform actions during time in seconds, starting right after the last action

  • @movie.then - perform next action after the last one finishes

Action modifying a resource + are influenced by the timeline methods

  • @movie.move() - move sprite to x,y coordinates

  • @movie.move_facing_direction() - move sprite to x,y coordinates, but also turn the sprite in that direction using angle

  • @movie.zoom(factor) - zoom height/width by factor (factor of 2 doubles the size, 0.5 makes it half the size)

  • @movie.rotate(angle) - rotates clockwise for angle degrees. Give negative angles to rotate counterclockwise.

  • @movie.fade_out - Fades to total transperency, only GOSU so far.

Actions modifying a resource

  • @movie.acceleration() - accelerates resource with the specified [x,y] offset. For example [-1,0] would make object accelerate left.

  • @movie.velocity() - sets static velocity specified [x,y] offset. For example [-1,0] would make object move left in a constant rate.

Actions doing a single thing

  • @movie.play_sound(sound) - Play sound-object

All commands are chainable for a clear and verbose way of building scenes. For example:

@movie.resource(@cat).move([0,100]).between(0,5).move([500,100]).rotate(360).then.during(4).move([500,600]).then.play_sound(@sound)

see samples/ dir for more examples.

Use it for:

Intros

Build up your game with a intro

ingame animations

You can make the movie play by calling update on it in your gameloop – just like you do with your rubygame sprites/spritegroups. Note - this remains to be tested in an example.

Simple demos for your local demoparty

Simple example

create your sprite (should include rubygames Sprites::Sprite):

@sprite = Sprite.new("sprite.png")

Sets up the movie, give it your initiated @screen-object and @background. MovieMaker supports autocreation of simple colored background as you can see bellow

movie = MovieMaker::Movie.new(:screen => @screen, :background => Color[:black])

1 sec (1000ms) into the movie, start moving the sprite from x/y: 0,0 (top left of the screen) during 9 seconds (until 10000ms into the movie), set the speed so it will reach position x/y 800,600.

@movie.resource(@sprite).move([0,0]).between(1,10).move([800,600])

Play the movie you’re created, blocks until it’s done

@movie.play

Chaining Simple example

movie_maker supports various chaining of actions, we could for example modify our last example like this: Between seconds 1-9, move the sprite across the screen,rotate it 360 degrees at the same time, and when it’s done, play a sound woff. Without the “.after.”-chaining the sound would have been played after 1 seconds, not 10.

@movie.resource(@sprite).move([0,0]).between(1,10).move([800,600]).rotate(360).then.play_sound(Sound["woff.wav"])

Gosu Example

Since Gosu has a different approach then rubygame a longer example is needed:

class MovieMakerWindow < Gosu::Window def initialize $screen = super(800, 600, false) # Make Surface & Sound behave like shortcuts to GOSUs Image & Sample require ‘gosu_autoload’ # Set our autoloading dirs for quick and easy access to images and samples Surface.autoload_dirs = [ File.join(“samples”, “media”), “media” ] Sound.autoload_dirs = [ File.join(“samples”, “media”), “media” ] @clock = ::Gosu::Clock.new @clock.target_framerate = 200

setup_movie end # # It’s there the movie gets created # def setup_movie @movie = Movie.new(:framework => :gosu, :screen => $screen) 0.upto(200) do |start| # x,y = 0,0 is default @star = Sprite.new(“star_5.png”) # all following actions are applied to this resource @movie.resource(@star) @movie.color( Color.new(100 + rand(155),rand(255),rand(255),rand(255)) ) @movie.zoom(0.2) @movie.between(start/10.0, start/10.0 + 2) @movie.velocity() @movie.acceleration([0, 0.05 + rand(0.1)]) @movie.rotate(angle = 90 * rand(10)) @movie.zoom(1.0 + rand(2.0)) @movie.fade_out.then.color(0x00FFFFFF) end end

# # Gosu calls update() automaticly # def update @tick = @clock.tick() if @movie.playing?(@clock.lifetime) @movie.gosu_update(@clock.lifetime) self.caption = “[framerate: #{@clock.framerate.to_i}] [Spriteupdates: #{@movie.updated_count}] [#{@clock.lifetime} : #{@movie.stop_at}]” else close end end # # Gosu calls draw() automaticly # def draw @movie.gosu_draw(@clock.lifetime) end end MovieMakerWindow.new.show # Initialize and show main gosu window (starts calling update/draw)

Requirements

Rubygame 2.3+ or Gosu 0.7.9+

License

Same as rubygame.

About

Automate image movements/effects and sounds over a period of time, useful for games.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages