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.

[Filled] Wind blowing effect push

VCA

Member

I need a script that causes the player to move (or sliding) in one direction or something, like if a strong wind was blowing. You can tell it which way to push the character slowly (or fast). Sorry if i didn't explained good enough. But if anyone knows anything about it, please tell me. Thanx in advance.
 
I made this real quick:
Code:
#==============================================================================

# ** Wind_Effect

#------------------------------------------------------------------------------

# SephirothSpawn

# Version 0.9

# 2009-02-26

#------------------------------------------------------------------------------

# $game_screen.blow_wind(direction, speed, distance, blow_events, anim, rect)

#

# direction: 1-Down Left, 2-Down, 3-Down Right, 4-Left, 6-Right, 7-Up Left,

#            8-Up, 9-Up Right

# speed: movement speed

# distance: number of tiles to travel

# blow_events: true to effect events, false to only effect player

# anim: animation id to be played on events

# rect: Area of be effected (Rect.new(x, y, width, height))

#==============================================================================

 

#==============================================================================

# ** Wind_Effect

#==============================================================================

 

class Wind_Effect

  #--------------------------------------------------------------------------

  # * Move Commands

  #--------------------------------------------------------------------------

  Move_Down     = RPG::MoveCommand.new(1)

  Move_Left     = RPG::MoveCommand.new(2)

  Move_Right    = RPG::MoveCommand.new(3)

  Move_Up       = RPG::MoveCommand.new(4)

  Move_L_Left   = RPG::MoveCommand.new(5)

  Move_L_Right  = RPG::MoveCommand.new(6)

  Move_U_Left   = RPG::MoveCommand.new(7)

  Move_U_Right  = RPG::MoveCommand.new(8)

  Move_Anim_On  = RPG::MoveCommand.new(31)

  Move_Anim_Off = RPG::MoveCommand.new(32)

  Dir_Fix_On    = RPG::MoveCommand.new(35)

  Dir_Fix_Off   = RPG::MoveCommand.new(36)

  #--------------------------------------------------------------------------

  # * Directions

  #--------------------------------------------------------------------------

  Directions = {

    1 => Move_L_Left, 2 => Move_Down,  3 => Move_L_Right,

    4 => Move_Left,   6 => Move_Right,

    7 => Move_U_Left, 8 => Move_Up,    9 => Move_U_Right

  }

  #--------------------------------------------------------------------------

  # * Blow Window

  #--------------------------------------------------------------------------

  def self.blow_wind(direction, speed = 2, distance = 1, blow_events = true,

        anim = 43, rect = Rect.new(0, 0, $game_map.width, $game_map.height))

    # Create Move Route

    move_route = RPG::MoveRoute.new

    move_route.repeat = false

    move_route.skippable = true

    # Insert the followng move commands (backwards)

    #  - Script: change_move_speed(speed)

    #  - Direction Fix On

    #  - Move Animation Off

    #  - <Move Direciton> * distance

    #  - Script&#058; restore_move_speed

    #  - Direciton Fix Off

    #  - Move Animation On

    move_route.list.insert(0, Move_Anim_On)

    move_route.list.insert(0, Dir_Fix_Off)

    move_route.list.insert(0, RPG::MoveCommand.new(45, ['restore_move_speed']))

    distance.times do

      move_route.list.insert(0, Directions[direction])

    end

    move_route.list.insert(0, Move_Anim_Off)

    move_route.list.insert(0, Dir_Fix_On)

    move_route.list.insert(0, RPG::MoveCommand.new(45, 

      ["change_move_speed(#{speed})"]))

    # If player within rect

    if self.within_rect?($game_player, rect)

      # Set Move Route

      $game_player.force_move_route(move_route)

      # Set Animation ID

      $game_player.animation_id = anim

    end

    # If blow events

    if blow_events

      # Pass through events

      for event in $game_map.events.values

        # If event within rect

        if self.within_rect?(event, rect)

          # Set Move Route

          event.force_move_route(move_route)

          # Set Animation ID

          event.animation_id = anim

        end

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Within Rect?

  #--------------------------------------------------------------------------

  def self.within_rect?(object, rect)

    if object.x.between?(rect.x, rect.x + rect.width)

      if object.y.between?(rect.y, rect.y + rect.height)

        return true

      end

    end

    return false

  end

end

 

#==============================================================================

# ** Game_Screen

#==============================================================================

 

class Game_Screen

  #--------------------------------------------------------------------------

  # * Blow Wind

  #--------------------------------------------------------------------------

  def blow_wind(*args)

    Wind_Effect.blow_wind(*args)

  end

end

 

#==============================================================================

# ** Game_Character

#==============================================================================

 

class Game_Character

  #--------------------------------------------------------------------------

  # * Change Move Speed

  #--------------------------------------------------------------------------

  def change_move_speed(speed = 3)

    @temp_move_speed = @move_speed

    @move_speed = speed

  end

  #--------------------------------------------------------------------------

  # * Restore Move Speed

  #--------------------------------------------------------------------------

  def restore_move_speed

    @move_speed = @temp_move_speed

  end

end

It forces a move route upon the player/events. Instructions are in the script heading. Let me know if you need any help.
 

VCA

Member

Can you show me an example of $game_screen.blow_wind(direction, speed, distance, blow_events, anim, rect) but can you show me an example with only this, moving to left, and it pushes you slowly. can you show me?
 

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