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.

Physics Engine

I found this demo a long time ago back on .net
It was made by Sharktooth. I think he is Mr. Mo on this board now.

It's a physics engine where you can set the gravity, break, and push objects depending on their weight, and have objects float or sink in water.

Demo:
http://www.box.net/shared/la67c5q4g8

The demo has Near's test bed in it and an old version of the SDK.
The script doesn't work with the new SDK so i'm hoping that someone with ruby experience could update it.

Script: (you need the demo to make it work)
#==============================================================================
# ** Physics Engine
#==============================================================================
# Sharktooth
# Version 1
# 03.17.06
#==============================================================================
class Physics_Engine
  attr_accessor :eek:bjects
  attr_accessor :map_gravity
  #------------------------------------------------------------------------------
  #These are the terrain ids for friction.
  #------------------------------------------------------------------------------
  SOFT = 3 #any terrain thats soft surfaced.
  ROUGH = 2 #any terrain thats rough surfaced.
  SMOOTH = 1 #any terrain thats smooth surfaced.
  SINK_IN = 4 #Terrains like water.
  #------------------------------------------------------------------------------
  #Here you can setup the strength numbers for the boxes. There is a reason for why i did this.
  #Everything is esier this way. If you are making a game where it doesn't matter how strong the box
  #is to break it then leave everything 0.
  #The best thing to do is put your stongest weapon's attack power to the STRONGEST and the weakest
  #weapon's attack power to the WEAKEST. Same for the rest. Because that's how the box will break.
  #The formula is;
  #box_strength - weapons_strength
  #But of course, you can do what ever you want. Just set the WEAPONS_USED to true if you used my
  #suggestion.
  #If you aren't using my suggestion, then the formula will be;
  #box_strength - number_of_hits
  #so leaving it 0 or 1 will break the box on the first hit.
  #Leaving it 2 will break the box in the second hit.
  #Simple.
  #------------------------------------------------------------------------------
  STRONGEST = 0
  STRONGER = 0
  STRONG = 0
  WEAK = 0
  WEAKER = 0
  WEAKEST = 0
  WEAPONS_USED = false
  #------------------------------------------------------------------------------
  #Should the objects move by the player's strength(true) or not(false)?
  USE_STRENGTH = false
  #------------------------------------------------------------------------------
  #Script Initializes here. No need to edit further.
  #------------------------------------------------------------------------------
  def initialize
  @objects = {}
  @map_gravity = "Normal"
  @npc_weight = []
end

def sink_in
  return SINK_IN
end

def setup_actors
#Game actor 1
  $game_actors[1].weight = 135
  $game_actors[1].height =  256
  $game_actors[1].width = 256
#Game actor 2
  $game_actors[2].weight = 135
  $game_actors[2].height =  256
  $game_actors[2].width = 256
#Game actor 3
  $game_actors[3].weight = 135
  $game_actors[3].height =  256
  $game_actors[3].width = 256
#Game actor 4
  $game_actors[4].weight = 135
  $game_actors[4].height = 256
  $game_actors[4].width = 256
end

#----------------------------------------------------------------------------------------------------------------------
#Refreshes events list
#----------------------------------------------------------------------------------------------------------------------
  def refresh(event, list, character_name)
    @objects.delete(event.id)
      return if character_name == ""
      return if list == nil
      parameters = SDK.event_comment_input(event, 9, "Physics Object")
      return if parameters.nil?
          object = Physics_Object.new(event.id)
          @objects[event.id] = object
          @objects[event.id].event_id = event.id
          @objects[event.id].character_name = character_name
          default_setup(event.id)
          height = parameters[0].split
        @objects[event.id].height = height[1].to_i
          weight = parameters[1].split
          @objects[event.id].weight = weight[1].to_i
          width = parameters[2].split
          @objects[event.id].width = width[1].to_i
          type = parameters[3].split
          @objects[event.id].type = type[1].to_s
          floating = parameters[4].split
          @objects[event.id].floating = floating[1].to_s
          shape = parameters[5].split
          @objects[event.id].shape = shape[1].to_s
          breakable = parameters[6].split
          @objects[event.id].breakable = breakable[1].to_s
          item = parameters[7].split
          @objects[event.id].item = item[1].to_i
          trigger = parameters[8].split
          @objects[event.id].trigger= [trigger[1].to_i, trigger[2].to_i, trigger[3].to_i]
          if breakable?(event.id) != false
        @objects[event.id].strength = object_strength(event.id)
      end
          end
     
            def refresh_gravity(event, list, character_name)
      return if list == nil
      parameters = SDK.event_comment_input(event, 1, "Begin Gravity")
      return if parameters.nil?
          gravity = parameters[0].split
        @map_gravity = gravity[1].to_s
      end
     
      def refresh_npc(event, list, character_name)
      return if character_name == ""
      return if list == nil
      parameters = SDK.event_comment_input(event, 1, "Npc Weight")
      return if parameters.nil?
          weight = parameters[0].split
        @npc_weight[event.id] = weight[1].to_i
      end
#----------------------------------------------------------------------------------------------------------------------
# default_setup
#----------------------------------------------------------------------------------------------------------------------
def default_setup(id)
    @objects[id].height = 256
    @objects[id].weight = 100
    @objects[id].width = 256
    @objects[id].type = "Soft"
    @objects[id].breakable = "No"
    @objects[id].shape = "Square"
    @objects[id].floating = "Land"
    @objects[id].item = nil
    @objects[id].broken = false
  end
 
  #---------------------------------------------------------------------------------------------------------------------- 
#Updates
#----------------------------------------------------------------------------------------------------------------------
  def update
    update_object_location
    update_event_location
    update_sinking?
    update_float
  end
#----------------------------------------------------------------------------------------------------------------------
#Updates States
#----------------------------------------------------------------------------------------------------------------------
  def update_sinking?
  for object in @objects.values
    event = $game_map.events[object.event_id]
  target = $game_map.terrain_tag(event.x, event.y)
if target == SINK_IN
event.opacity = 100 if object.floating == "No"
event.opacity = 255 if object.floating == "Yes"
  else
    event.opacity = 255
  end
  end
end


    def update_float
  for object in @objects.values
  step = $game_map.events[object.event_id].step_anime
  if @map_gravity == "No" or object.weight <= 0
  $game_map.events[object.event_id].step_anime = true  if object.weight < 500
else
  $game_map.events[object.event_id].step_anime = step
end
end
end

#----------------------------------------------------------------------------------------------------------------------
#Updates locations
#----------------------------------------------------------------------------------------------------------------------
    def update_event_location
    for event in $game_map.events.values
    for object in @objects.values
    objects = $game_map.events[object.event_id]
    if event.direction == 8
    if event.x == objects.x and event_upy(event.id)  == object_upy(object.event_id)
    calculate_event(object, event, 8)
    end
  elsif event.direction == 6
  if object_rightx(object.event_id) == event_rightx(event.id) and event.y == objects.y
    calculate_event(object, event, 6)
  end
elsif event.direction == 4
  if object_leftx(object.event_id) == event_leftx(event.id) and event.y == objects.y
    calculate_event(object, event, 4)
end
elsif event.direction == 2
  if event.x == objects.x and event_downy(event.id)  == object_downy(object.event_id)
    calculate_event(object, event, 2)
  end
  end
end
end
end

  def update_object_location
    for object in @objects.values
      event = $game_map.events[object.event_id]
    if $game_player.direction == 8
    if $game_player.x == event.x and $game_player.real_y  == object_downy(object.event_id) and Input.press?(Input::UP)
    calculate(object, 8)
    end
  elsif $game_player.direction == 6
  if $game_player.real_x== object_leftx(object.event_id) and $game_player.y == event.y and Input.press?(Input::RIGHT)
    calculate(object, 6)
  end
elsif $game_player.direction == 4
  if $game_player.real_x == object_rightx(object.event_id) and $game_player.y == event.y and Input.press?(Input::LEFT)
    calculate(object, 4)
  end
elsif $game_player.direction == 2
  if $game_player.x == event.x and $game_player.real_y  == object_upy(object.event_id) and Input.press?(Input::DOWN)
    calculate(object, 2)
    end
  end
end
end

#----------------------------------------------------------------------------------------------------------------------
#Moves object
#----------------------------------------------------------------------------------------------------------------------
def calculate(object, dir)
if USE_STRENGTH == false
  diff = player_weight - object.weight
#=============================
#Difference
#=============================
if diff  >= 1
f = friction(object.event_id)
case @map_gravity
when "Normal"
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
speed = player_speed
when "Low"
diff = (player_weight) - (object.weight - 110)
distance = ((((diff/8) - f) + player_speed/2)*0.40).round #6
speed = player_speed - 1
when "No"
distance = 501
speed = player_speed - 2
when "High"
diff = (player_weight + 60) - object.weight
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
end

elsif diff < 1
  case @map_gravity
when "Normal"
return
when "Low"
diff = (player_weight) - (object.weight - 110)
if diff <= 0
  return
elsif diff >= 1
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
speed = player_speed - 1
end
when "No"
distance = 501
speed = player_speed - 2
when "High"
return
end
end
#============================
#IF Weight less then equals 0
#============================
if object.weight <= 0
diff = player_weight - object.weight
f = friction(object.event_id)
case @map_gravity
when "Normal"
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
speed = player_speed
when "Low"
diff = (player_weight) - (object.weight - 150)
distance = ((((diff/8) - f) + player_speed/2)*0.40).round #6
speed = player_speed - 1
when "No"
distance = 501
speed = player_speed - 2
when "High"
diff = (player_weight + 60) - object.weight
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
end
end

elsif USE_STRENGTH == true

 
end
move(object, dir, distance, speed)
end
#----------------------------------------------------------
#CALCULATE EVENT MOVEMENT
#-------------------------------------------------------
def calculate_event(object, event, dir)
return if !event or !dir or !object or !event.character_name or !@objects or !event_weight(event.id)
if USE_STRENGTH == false
  diff = event_weight(event.id) - object.weight
#=============================
#Difference
#=============================
if diff  >= 1
f = friction(object.event_id)
case @map_gravity
when "Normal"
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
speed = event.move_speed
when "Low"
diff = (player_weight) - (object.weight - 110)
distance = ((((diff/8) - f) + player_speed/2)*0.40).round #6
speed = event.move_speed - 1
when "No"
distance = 501
speed = event.move_speed - 2
when "High"
diff = (player_weight + 60) - object.weight
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
end

elsif diff < 1
  case @map_gravity
when "Normal"
return
when "Low"
diff = (player_weight) - (object.weight - 110)
if diff <= 0
  return
elsif diff >= 1
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
speed = event.move_speed - 1
end
when "No"
distance = 501
speed = event.move_speed - 2
when "High"
return
end
end
#============================
#IF Weight less then equals 0
#============================
if object.weight <= 0
  diff = event_weight(event.id) - object.weight
f = friction(object.event_id)
case @map_gravity
when "Normal"
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
speed = event.move_speed
when "Low"
diff = event_weight(event.id) - (object.weight - 150)
distance = ((((diff/8) - f) + player_speed/2)*0.40).round #6
speed = event.move_speed - 1
when "No"
distance = 501
speed = event.move_speed - 2
when "High"
  diff = (event_weight(event.id) + 60)- object.weight
distance = ((((diff/8) - f) + player_speed/2)*0.40).round
end
end

elsif USE_STRENGTH == true

 
end
move(object, dir, distance, speed)
end

#================================
#Movments
#================================
  def move(object, dir, distance, speed)
if object.shape == "Round"
direct = rand(4) + 1
else
direct = 1
end
if object.shape == "Triangle"
direct = rand(3) + 1
else
direct = 1
end
object_moved(object)
event = $game_map.events[object.event_id]
event.physics_path = false
event.set_path(dir, distance, direct, speed)
end
#============================= 
#calculates friction
#============================= 
def friction(id)
  friction = get_terrain(id) - get_type(id)
  if friction < 1
    return 0
  else
    return friction
  end
end
#=============================
#These are to make my life esier.
#=============================
def player_speed
    return $game_player.move_speed
end

def player_weight
  return $game_party.actors[0].weight
end

def player_width
    return $game_party.actors[0].width
end

def player_height
    return $game_party.actors[0].height
  end
 
  def event_weight(id)
  if @objects[id] == nil
    return @npc_weight[id]
  elsif @objects[id] != nil
    return @objects[id].weight * $game_map.events[@objects[id].event_id].move_speed
    end
  end
 
  def object_rightx(id)
return (@objects[id].width/2) + $game_map.events[id].real_x
end

def object_leftx(id)
return $game_map.events[id].real_x - (@objects[id].width/2)
end

def object_downy(id)
return (@objects[id].height/2) + $game_map.events[id].real_y
end

def object_upy(id)
return $game_map.events[id].real_y - (@objects[id].height/2)
end
#=============================
  def event_rightx(id)
return 256 + $game_map.events[id].real_x
end

def event_leftx(id)
return $game_map.events[id].real_x - 256
end

def event_downy(id)
return 256 + $game_map.events[id].real_y
end

def event_upy(id)
return $game_map.events[id].real_y - 256
end

def broken(id)
return true if @objects[id].broken == true
return false if @objects[id].broken == false
end

#============================= 
#gets object type
#============================= 
  def get_type(id)
      case @objects[id].type
    when "Smooth"
      return 5
    when "Soft"
      return 10
    when "Rough"
      return 15
    when "Sticky Smooth"
      return 10
    when "Sticky Soft"
      return 15
    when "Sticky Rough"
      return 20
    end
  end
#============================= 
#gets terrain type
#============================= 
  def get_terrain(id)
    event = $game_map.events[id]
    terrain = $game_map.terrain_tag(event.x, event.y)
    if terrain == SOFT
    return 5
    elsif terrain == SMOOTH
    return 10
    elsif terrain == ROUGH
    return 15
  elsif terrain == 0
    return 5
  elsif terrain == SINK_IN
    return 30
    end
    end
#============================= 
#gets object shape
#============================= 
  def shape?(id)
  return @objects[id].shape
  end
#============================= 
#BREAKABLE
#============================= 
  def breakable?(id)
  case @objects[id].breakable
  when "No"
    return false
  end
  return true
  end

  def object_strength(id)
  case @objects[id].breakable
  when 'Strongest'
  return STRONGEST
  when 'Stronger'
  return STRONGER
  when 'Strong'
  return STRONG
  when 'Weak'
  return WEAK
  when 'Weaker'
  return WEAKER
  when 'Weakest'
  return WEAKEST
  end
  end
 
  def update_breakables(event, weapon)
    object = @objects[event.id]
  return if breakable?(object.event_id) == false
    actor = $game_actors[0]
    if WEAPONS_USED == true
    # object.strength -=
    else
      object.strength -= 1
    end
    if object.strength <= 0
      break_object(object)
    end
  end
 
    def object_moved(object)
    event = $game_map.events[object.event_id]
        case object.trigger[0]
        when 5
          event.erase
        when 6
          print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if object.trigger[1] == 0
          $game_switches[object.trigger[1]] = true
          $game_map.need_refresh = true
        when 7
          print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if object.trigger[1] == 0
          if object.trigger[2] == 0
            $game_variables[object.trigger[1]] += 1
            $game_map.need_refresh = true
          else
            $game_variables[object.trigger[1]] = object.trigger[2]
            $game_map.need_refresh = true
          end
        when 8
          value = "A" if object.trigger[1] == 1
          value = "B" if object.trigger[1] == 2
          value = "C" if object.trigger[1] == 3
          value = "D" if object.trigger[1] == 4
          print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if value == 0
          key = [$game_map.map_id, event.id, value]
          $game_self_switches[key] = true
          $game_map.need_refresh = true
          when 9
          get_item(@objects[object].item) if object.item != nil
        end
    return
  end

    def break_object(object)
      event = $game_map.events[object.event_id]
        case object.trigger[0]
        when 0
          event.erase
        when 1
          print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if object.trigger[1] == 0
          $game_switches[object.trigger[1]] = true
          $game_map.need_refresh = true
        when 2
          print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if object.trigger[1] == 0
          if object.trigger[2] == 0
            $game_variables[object.trigger[1]] += 1
            $game_map.need_refresh = true
          else
            $game_variables[object.trigger[1]] = object.trigger[2]
            $game_map.need_refresh = true
          end
          event.character_name = object.character_name + '_broken'
        when 3
          value = "A" if object.trigger[1] == 1
          value = "B" if object.trigger[1] == 2
          value = "C" if object.trigger[1] == 3
          value = "D" if object.trigger[1] == 4
          print "EVENT " + event.id.to_s + "Trigger Not Set Right ~!" if value == 0
          key = [$game_map.map_id, event.id, value]
          $game_self_switches[key] = true
          $game_map.need_refresh = true
          event.character_name = object.character_name + '_broken'
          when 4
          event.physics_path = false
          object.broken = true
          event.through = true
          event.character_name = object.character_name + '_broken'
        end
          get_item(object.item) if object.item != nil
          @objects.delete(event.id)
    return
  end
 
  def get_item(item_id)
    $game_party.gain_item(item_id, 1)
    return
  end
 
#--------------------------------------------------------------------------
# * End Class
#--------------------------------------------------------------------------
end
#--------------------------------------------------------------------------
# *Scene Title
#--------------------------------------------------------------------------
  class Scene_Title
    #--------------------------------------------------------------------------
    alias st_pe_scene_title command_new_game
    #--------------------------------------------------------------------------
    def command_new_game
      $physics = Physics_Engine.new
      st_pe_scene_title
    end
#--------------------------------------------------------------------------
# * End Class
#--------------------------------------------------------------------------
end

  #============================================================================
  # * Scene Map
  #============================================================================
 
  class Scene_Map
    #--------------------------------------------------------------------------
    alias st_pe_scene_map_update update
    #--------------------------------------------------------------------------
    def update
      $physics.update
      st_pe_scene_map_update
    end
#--------------------------------------------------------------------------
# * End Class
#--------------------------------------------------------------------------
end

  #============================================================================
  # * Game_Actor
  #============================================================================
  class Game_Actor < Game_Battler
  attr_accessor :height
  attr_accessor :width
  attr_accessor :weight
    #--------------------------------------------------------------------------
    alias st_pe_game_actor_setup setup
    #--------------------------------------------------------------------------
    def setup(actor_id)
    @height = 1
    @width = 1
    @weight = 1 #in pounds
      st_pe_game_actor_setup(actor_id)
    end
#--------------------------------------------------------------------------
# * End Class
#--------------------------------------------------------------------------
end

  #============================================================================
  # â–  Physics_Object
  #============================================================================
  class Physics_Object < Game_Character
  attr_accessor :event_id
  attr_accessor :height
  attr_accessor :weight
  attr_accessor :width
  attr_accessor :speed
  attr_accessor :type
  attr_accessor :floating
  attr_accessor :shape
  attr_accessor :breakable
  attr_accessor :item
  attr_accessor :trigger
  attr_accessor :strength
  attr_accessor :broken
  attr_accessor :character_name
 
    def initialize(object_id)
    @character_name = nil
    @event_id = 0
    @height = 1
    @width = 1
    @weight = 1 #in pounds
    @type = nil
    @floating = nil
    @shape = nil
    @breakable = nil
    @item = nil
    @trigger = []
    @strength = 0
    @broken = false
    @object_id = object_id
  end
 
  #--------------------------------------------------------------------------
    def id
      return @object_id
    end
    #--------------------------------------------------------------------------
  #End class here
  end
  #============================================================================
  # â–  Game Event
  #============================================================================
 
  class Game_Event < Game_Character
  attr_accessor :eek:pacity
  attr_accessor :through
  attr_accessor :prelock_direction
  attr_accessor :step_anime
  attr_accessor :character_name
  attr_reader    :page
  attr_reader    :map_id
    #--------------------------------------------------------------------------
    alias st_pe_game_event_refresh_set_page refresh_set_page
    #-------------------------------------------------------------------------
    def jump_to(dir, far)
      return if jumping?
    if dir == 2
      jump(0, far)
    elsif dir == 8
      jump(0, far * -1)
    elsif dir == 6
      jump(far, 0)
    elsif dir == 4
      jump(far * -1, 0)
    end
  end
 
    def name
      return @event.name
    end
    #--------------------------------------------------------------------------
    def id
      return @id
    end
    #--------------------------------------------------------------------------
    def refresh_set_page
      st_pe_game_event_refresh_set_page
      $physics.refresh(self, @list, @character_name)
      $physics.refresh_gravity(self, @list, @character_name)
      $physics.refresh_npc(self, @list, @character_name)
    end
  end
 
    #============================================================================
  # * Scene Load
  #============================================================================
 
  class Scene_Load < Scene_File
    #--------------------------------------------------------------------------
    alias st_pe_scene_load_read_data read_data
    #--------------------------------------------------------------------------
      def read_data(file)
      st_pe_scene_load_read_data(file)
      $physics = Marshal.load(file)
    end
  end
  #============================================================================
  # * Scene Save
  #============================================================================
 
  class Scene_Save < Scene_File
    #--------------------------------------------------------------------------
    alias st_pe_scene_save_write_data write_data
    #--------------------------------------------------------------------------
    def write_data(file)
      st_pe_scene_save_write_data(file)
      Marshal.dump($physics, file)
    end
  end
 
    #============================================================================
  # * Game_Character
  #============================================================================
    class Game_Character
    #--------------------------------------------------------------------------
    alias st_pe_game_character_initialize initialize
    alias st_pe_game_character_update update
    alias st_pe_game_character_passable? passable?
    #--------------------------------------------------------------------------
    attr_accessor :physics_path
    attr_accessor :x                        # map x-coordinate (logical)
    attr_accessor :y                        # map y-coordinate (logical)
    attr_accessor :real_x                  # map x-coordinate (real * 128)
    attr_accessor :real_y                  # map y-coordinate (real * 128)
    attr_accessor :step_anime

    #--------------------------------------------------------------------------
    def initialize
      st_pe_game_character_initialize
      @physics_path = false
      @pe_steps_forward = 0
      $physics.setup_actors
    end
    #--------------------------------------------------------------------------
    def update
      physics_path
      st_pe_game_character_update
    end

    def brake(character)
      @character_name = character
    end
   
    def set_path(dir, distance, random, speed)
      return if $physics.objects[self.id].broken == true
      return if not passable?(@x, @y, dir)
    @pe_original_steps = distance
    @pe_steps_forward = distance
    @pe_steps_backward = 0
    @physics_path = true
    @pe_random = random
    @pe_dir = dir
    @speed = speed
    physics_path
  end
   
    def physics_path
    return if moving?
    if @pe_steps_forward == 0 and @pe_steps_backward == 0 or @physics_path == false
    @pe_random = 0
    @pe_dir = 0
      @physics_path == false
      return
    end
#starts to move the event.
#forward at direction.
=begin
    for i in 0...$physics.objects.size
  next if $physics.objects == nil
  next if i == self.event_id
    case @pe_dir
when 2
if @y + 1 == $physics.objects.y and @x == $physics.objects.x
    @pe_steps_backward = 0
    @pe_steps_forward = 0
end
when 4
if @x - 1 == $physics.objects.x and @y == $physics.objects.y
    @pe_steps_backward = 0
    @pe_steps_forward = 0
end
when 6
if @x + 1 == $physics.objects.x and @y == $physics.objects.y
    @pe_steps_backward = 0
    @pe_steps_forward = 0
end
when 8
if @y - 1 == $physics.objects.y and @x == $physics.objects.x
    @pe_steps_backward = 0
    @pe_steps_forward = 0
end
    end
  end
=end
  if not passable?(@x, @y, @direction)
  if @pe_steps_forward == 0
    @pe_steps_forward = @pe_steps_backward
    @pe_steps_backward = 0
  else
    @pe_steps_backward = @pe_steps_forward
    @pe_steps_forward = 0
    end
  end
 
    if not passable?(@x, @y, @direction) and $physics.map_gravity == "No"
  if @pe_steps_forward == 0
    @pe_steps_forward = 1
    @pe_steps_backward = 0
  else
    @pe_steps_backward = 1
    @pe_steps_forward = 0
    end
  end

    if not passable?(@x, @y, @direction) and $physics.map_gravity == "Low" or $physics.map_gravity == "High"
  if @pe_steps_forward == 0
    @pe_steps_forward = @pe_steps_backward - 1
    @pe_steps_backward = 0
  else
    @pe_steps_backward = @pe_steps_forward - 1
    @pe_steps_forward = 0
    end
  end

  if @pe_steps_forward == (@pe_original_steps * 0.70).round or @pe_steps_backward == (@pe_original_steps * 0.50).round
    @speed -= 1
  elsif @pe_steps_forward == (@pe_original_steps * 0.50).round or @pe_steps_backward == (@pe_original_steps * 0.30).round
    @speed -= 1
  elsif @pe_steps_forward == (@pe_original_steps * 0.30).round or @pe_steps_backward == (@pe_original_steps * 0.10).round
    @speed -= 1
  elsif @pe_steps_forward == (@pe_original_steps * 0.10).round or @pe_steps_backward == (@pe_original_steps * 0.10).round
    @speed -= 1
  end
 
  @move_speed = @speed
  if @pe_steps_forward != 0 
    case @pe_dir
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
    end
    @pe_steps_forward -= 1
  end
#backward at a direction.
if @pe_steps_backward != 0  and @pe_steps_forward == 0
case @pe_dir
when 2
case @pe_random
when 1
move_up
when 2
move_upper_left
when 3
move_upper_right
when 4
move_up
end
when 4
case @pe_random
when 1
move_right
when 2
move_upper_right
when 3
move_lower_right
when 4
move_right
end
when 6
case @pe_random
when 1
move_left
when 2
move_upper_left
when 3
move_lower_left
when 4
move_left
end
when 8
case @pe_random
when 1
move_down
when 2
move_lower_left
when 3
move_lower_right
when 4
move_down
end
    end
    @pe_steps_backward -= 1
  end
  #end def
  end
 
      def passable?(x, y, d)
      for object in $physics.objects.values
    terrain = $game_map.terrain_tag(self.x + (d == 6 ? 1 : d == 4 ? -1 : 0), self.y + (d == 2 ? 1 : d == 8 ? -1 : 0))
  if terrain == $physics.sink_in and self.id == object.event_id and $physics.objects[self.id].floating != "Land"
    return true
  end
  end
  st_pe_game_character_passable?(x, y, d)
end

  #Class ends here.
end

#==============================================================================
# â–  Action Battle System
#==============================================================================
  class ABS
 
  def update_physics_engine2
@mash_bar = 0
for object in $physics.objects.values
actor = $game_party.actors[0]
event = $game_map.events[object.event_id]
if facing?($game_player, event) and in_range?($game_player, event, 1)
@mash_bar = 0
  hit_event(event, $data_weapons[actor.weapon_id].animation2_id)
  $physics.update_breakables(event, $data_weapons[actor.weapon_id])
end
end
end

#End class here!
end
  #============================================================================
  # * Scene Map
  #============================================================================
  class Scene_Map
    #--------------------------------------------------------------------------
    alias st_pe_scene_map_update3 update
    #--------------------------------------------------------------------------
    def update
      st_pe_scene_map_update3
    $ABS.update_physics_engine2 if Kboard.keyboard($R_Key_F) 
    end
  #============================================================================
  # *End Class
  #============================================================================
  end


screenshot
http://img.photobucket.com/albums/v134/adriantalens/Final%20FantasTREE/dd.png[/img]
This still frame is kind of pointless. Try the demo.
 
Dadevster":8whfoiqp said:
When I pushed the rock into the lorry thing there was an error message.
It's still a great script though!

Just saying there was an error wonn't help. You need to post exactly what the error said if you want someone to try and fix it.
 
Nice Script :)

Anyway, there's an error when change to other scene in demo.

I don't think it's from this script though, but if it needs SDK that may be the cause of this bug. That'll be bad.
(Not sure, because there're plenty of scripts in there)
 
baniff":3eqntrwa said:
Dadevster":3eqntrwa said:
When I pushed the rock into the lorry thing there was an error message.
It's still a great script though!

Just saying there was an error wonn't help. You need to post exactly what the error said if you want someone to try and fix it.
 

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