Arena RPG Maker
Olá, visitante!
Seja bem-vindo ao fórum Arena RPG Maker, caso queira aprender sobre criação de jogos, está no fórum certo. Esperamos que possa aprender tanto quanto possa nos ensinar aqui.

Atenciosamente,
Equipe Arena RPG Maker.
Arena RPG Maker
Olá, visitante!
Seja bem-vindo ao fórum Arena RPG Maker, caso queira aprender sobre criação de jogos, está no fórum certo. Esperamos que possa aprender tanto quanto possa nos ensinar aqui.

Atenciosamente,
Equipe Arena RPG Maker.
Arena RPG Maker

Estamos de volta o/ ... Ou não.Eu amo a -Dark
Doações para o fórum abertas, clique aqui e saiba mais.
Últimos assuntos
» Ainda temos gente aqui?
Arcthunder Pixel Movement EmptyQui 25 Nov 2021, 14:04 por Halt

» [Dúvida] Como tirar a porcentagem de esquiva
Arcthunder Pixel Movement EmptySex 19 Nov 2021, 17:14 por Halt

» Pokémon Genesis Online! (PGO)
Arcthunder Pixel Movement EmptyQua 05 Jul 2017, 18:08 por Lexar

» Tileset Converter to MV
Arcthunder Pixel Movement EmptySex 12 maio 2017, 14:07 por Douggi

» Pack Resources, Sprites e etc
Arcthunder Pixel Movement EmptyQua 23 Dez 2015, 12:30 por raydengv

» Download RPG Maker 2003 + RTP em português
Arcthunder Pixel Movement EmptyTer 22 Dez 2015, 11:14 por ::KimMax::

» Fantasy Art Online
Arcthunder Pixel Movement EmptyDom 18 Out 2015, 18:42 por daviih123

» Você vai ter medo do Nerve gear?
Arcthunder Pixel Movement EmptySáb 25 Jul 2015, 17:02 por Kirito-kun

» O Barato é louco
Arcthunder Pixel Movement EmptySáb 27 Jun 2015, 16:26 por Halt

» Download RPG Maker 2000 + RTP em português
Arcthunder Pixel Movement EmptyQui 21 maio 2015, 20:28 por Wismael


Você não está conectado. Conecte-se ou registre-se

Ver o tópico anterior Ver o tópico seguinte Ir para baixo  Mensagem [Página 1 de 1]

1Arcthunder Pixel Movement Empty Arcthunder Pixel Movement Sáb 20 Out 2012, 17:54

lordiuri

lordiuri
Membro - semi experiente
Membro - semi experiente
A pedido da DeadEnd tou posstando esse script do Khas

Arcthunder Pixel Movement
by Khas Arcthunder

Introdução:
Pixel Movement é um script que converte o movimento dos personagens (jogador, eventos e veiculos) de Tiles (quadradinhos do mapa) para “Pixeis” (por isso o nome Pixel Movement, parece que os passos são pixeis). Porém esse script só existia para RMXP, até agora. O Arcthunder Pixel Movement foi desenvolvido para integrar perfeitamente o jogador ao mapa, ajustando também colisões com objetos.

Caracteristicas:
- Passos por Pixel
- 8 direções (jogador e eventos)
- Plug and Play
- Sistema de colisão avançada
- Lag-free
- Funciona com os balcões do jogo
- Sistema de loading para carregar os mapas
- Afeta eventos e veiculos também
- Colisão pode ser ajustada para cada evento
- E muito mais…

Instruções:
Há instruções na própria demo.

Screenshot:
[Tens de ter uma conta e sessão iniciada para poderes visualizar esta imagem]

Vídeo:


Script:
Código:
#-------------------------------------------------------------------------------
# * Arcthunder Pixel Movement
#-------------------------------------------------------------------------------
# * Por Khas Arcthunder (nilokruch@live.com)
# * Versão: 1.0 BR
# * Lançada em: 21/07/2011
#
#-------------------------------------------------------------------------------
# * Nota do autor
#-------------------------------------------------------------------------------
# Obrigado por escolher os scripts Arcthunder. Se você achar algum bug, avise
# nos tópicos oficiais por favor (tópicos criados por mim - Khas)
#
# Você pode encontrar mais scripts e updates (em português ou inglês) em:
# http://arcthunder.host.org/
#
# Se você gostou dos meus scripts e quer ajudar, qualquer quantia que doe
# será apreciada. Por favor, visite http://arcthunder.host.org/ para doar.
#
#-------------------------------------------------------------------------------
# * Termos de uso
#-------------------------------------------------------------------------------
# Você deve dar crédito a Khas se estiver usando algum script Arcthunder;
# Todos os scripts Arcthunder estão sob licença Creative Commons;
# Todos os scripts Arcthunder são para projetos não comerciais, se você precisar
# em seu projeto comercial, envie um email para [Tens de ter uma conta e sessão iniciada para poderes visualizar este link] com o pedido;
# Todos os scripts Arcthunder são para uso pessoal, você pode usar e editar para
# uso no seu projeto, porém você não pode postar nenhuma versão modificada sem
# a minha permissão
#
#-------------------------------------------------------------------------------
# * Instruções
#-------------------------------------------------------------------------------
# 1. Como usar
# Coloque o Arcthunder Pixel Movement nos scripts adicionais. Este script afeta
# o movimento do jogador, dos eventos e dos veiculos do game.
#
# 2. Sistema Physics
# Para que este script funcione corretamente, há um sistema chamado Physics.
# Este sistema irá carregar todos os mapas de Pixel no inicio do jogo e irá
# salvar os dados num arquivo chamado "Khas Physics.rgss2a". Você deve
# atualizar o arquivo se fizer alguma modificação em algum mapa do jogo.
#
# Há duas maneiras de atualizar o sistema Physics:
# a. Delete o arquivo "Khas Physics.rgss2a"
# b. Configure Force_Physics_Update = true
#
# Quando terminar seu projeto e ele estiver pronto para enviar para outras
# pessoas, lembre-se de deletar o arquivo "Khas Physics.rgss2a" antes
# de encriptar o projeto! O sistema Physics irá criar um novo arquivo atualizado
# automaticamente quando o jogador jogar pela primeira vez.
#
# 3. Comandos de eventos (Colocados em comentarios no evento)
# Você talvez queira colocar algum comando especial em algum evento, há dois:
#
# a. [collision X]
# Esse comando modifica a colisão do evento para X
#
# b. [forcedefaultcmd]
# Esse comando força o evento a seguir o movimento padrão do RMVX
#
# 4. Comandos de eventos (Por chamar script)
# Você pode chamar alguns comandos para o jogador ou para eventos
#
# character.centralize(x,y)
# Esse comando centraliza o personagem em x,y.
#
# character.px
# Esse comando retorna a coordenada Pixel X
#
# character.py
# Esse comando retorna a coordenada Pixel Y
#
# character.pixel_passable?(px,py)
# Esse comando verifica a passagem em px,py
#
#-------------------------------------------------------------------------------
# * Incompatibilidades
#-------------------------------------------------------------------------------
# O Arcthunder Pixel Movement é incompativel com
# 1. Mapas em Loop
# 2. Modificações pesadas em Game_Character, Game_Player and Game_Event
# 3. Scripts Anti-Lag
# 4. Action Battle Systems (Um ABS compativel está sendo produzido! Arcthunder ABS!)
#
#-------------------------------------------------------------------------------
# * Configuração
#-------------------------------------------------------------------------------
module Pixel_Core
 
  # Mapas de pixel movement (ID)
  # Exemplo:
  # Maps = [1,3,4,5,6,7]
  Maps = [1,2,3]
 
#-------------------------------------------------------------------------------
# * Atualização do sistema Physics
#-------------------------------------------------------------------------------
 
  # Forçar a atualização do sistema Physics quando iniciar?
  # Se você selecionar essa opção como "false" você terá que deletar o arquivo
  # manualmente para atualizar o sistema Physics.
  Force_Physics_Update = true
 
#-------------------------------------------------------------------------------
# * Sistema de multiplicação de comandos
#-------------------------------------------------------------------------------
 
  # Multiplicar comandos de Evento? (essa opção multiplica os comandos pela
  # constante Pixel, é recomandado que a deixe desativada e multiplique
  # manualmente para obter os melhores resultados)
  Multiply_Commands = false
 
  # Comandos a serem multiplicados (ID)
  Commands = [1,2,3,4,5,6,7,8,9,10,11,12,13]
 
#-------------------------------------------------------------------------------
# * Configurações de Pixel (OUTRAS CONFIGURAÇÕES PODEM TRAVAR SEU JOGO!!!!)
#-------------------------------------------------------------------------------

  # Axis [x plus, y plus, width, height]
  # Default: [0,0,0.75,0.75]
  # True Pixel: [0.25,0.25,0.25,0.50]
  Axis = [0.25,0.25,0.25,0.50]
 
  # Bush axis [x plus, y plus, width, height]
  Bush_Axis = [0.5,0.75,0.0,0.0]
 
  # Counter axis [x plus, y plus, width, height]
  Counter_Axis = [0.25,0.25,0.25,0.25]
 
  # Pixel constant (32/Pixel must be an integer!) - Best setting: 4
  Pixel = 4
 
  # Tile divisor (256/Tile must be an integer!) - Best setting: 0.25
  Tile = 0.25
 
  # Default collision range (must be an integer!)
  Collision = 3
 
  # Trigger range (direction => [x,y])
  Trigger_Range = {2=>[0,2],4=>[-2,0],6=>[2,0],8=>[0,-2]}
 
  # Counter range
  Counter_Range = {2=>[0,3],4=>[-3,0],6=>[3,0],8=>[0,-3]}
 
  # Vehicle Range (gettin on or off vehicles)
  Vehicle_Range = {2=>[0,3],4=>[-3,0],6=>[3,0],8=>[0,-3]}
end

#-------------------------------------------------------------------------------
# * End of setup part
#-------------------------------------------------------------------------------

class Game_Character
  include Pixel_Core
  attr_accessor :px
  attr_accessor :py
  attr_accessor :collision
  alias apm_initialize initialize
  alias apm_moveto moveto
  alias apm_jump jump
  alias apm_update_bush_depth update_bush_depth
  alias apm_force_move_route force_move_route
  alias default_mr move_right
  alias default_ml move_left
  alias default_mu move_up
  alias default_md move_down
  alias default_mur move_upper_right
  alias default_mul move_upper_left
  alias default_mlr move_lower_right
  alias default_mll move_lower_left
  def initialize
    apm_initialize
    if (Maps.include?($game_map.map_id) rescue false)
      @x = @x.to_f
      @y = @y.to_f
      @pixel = true
    else
      @pixel = false
    end
    @px = (@x*Pixel).to_i
    @py = (@y*Pixel).to_i
    @collision = Collision
  end
  def moveto(x,y)
    @pixel = Maps.include?($game_map.map_id)
    apm_moveto(x,y)
    if Maps.include?($game_map.map_id)
      @x = @x.to_f
      @y = @y.to_f
    end
    @px = (@x*Pixel).to_i
    @py = (@y*Pixel).to_i
  end
  def update_bush_depth
    if @pixel
      if object? or @priority_type != 1 or @jump_count > 0
        @bush_depth = 0
      else
        bush = $physics[$game_map.map_id][@px,@py,4] == 1
        if bush and not moving?
          @bush_depth = 8
        elsif not bush
          @bush_depth = 0
        end
      end
    else
      apm_update_bush_depth
    end
  end
  def move_down(t=true)
    @pixel ? pixel_md(t) : default_md(t)
  end
  def move_up(t=true)
    @pixel ? pixel_mu(t) : default_mu(t)
  end
  def move_left(t=true)
    @pixel ? pixel_ml(t) : default_ml(t)
  end
  def move_right(t=true)
    @pixel ? pixel_mr(t) : default_mr(t)
  end
  def move_upper_right
    @pixel ? pixel_mur : default_mur
  end
  def move_upper_left
    @pixel ? pixel_mul : default_mul
  end
  def move_lower_right
    @pixel ? pixel_mlr : default_mlr
  end
  def move_lower_left
    @pixel ? pixel_mll : default_mll
  end
  def pixel_mr(turn_ok)
    if pixel_passable?(@px+1,@py)
      turn_right
      @x += Tile
      @px += 1
      @real_x = (@x-Tile)*256
      increase_steps
      @move_failed = false
    else
      turn_right if turn_ok
      check_touch(@px+1, @py)
      @move_failed = true
    end
  end
  def pixel_ml(turn_ok)
    if pixel_passable?(@px-1,@py)
      turn_left
      @x -= Tile
      @px -= 1
      @real_x = (@x+Tile)*256
      increase_steps
      @move_failed = false
    else
      turn_left if turn_ok
      check_touch(@px-1, @py)
      @move_failed = true
    end
  end
  def pixel_mu(turn_ok)
    if pixel_passable?(@px,@py-1)
      turn_up
      @y -= Tile
      @py -= 1
      @real_y = (@y+Tile)*256
      increase_steps
      @move_failed = false
    else
      turn_up if turn_ok
      check_touch(@px, @py-1)
      @move_failed = true
    end
  end
  def pixel_md(turn_ok)
    if pixel_passable?(@px,@py+1)
      turn_down
      @y += Tile
      @py += 1
      @real_y = (@y-Tile)*256
      increase_steps
      @move_failed = false
    else
      turn_down if turn_ok
      check_touch(@px, @py+1)
      @move_failed = true
    end
  end
  def pixel_mur
    pixel_mu(true)
    pixel_mr(true)
  end
  def pixel_mul
    pixel_mu(true)
    pixel_ml(true)
  end
  def pixel_mlr
    pixel_md(true)
    pixel_mr(true)
  end
  def pixel_mll
    pixel_md(true)
    pixel_ml(true)
  end
  def pixel_passable?(px,py)
    return false unless $game_map.pixel_valid?(px,py)
    return true if @through or debug_through?
    return false if $physics[$game_map.map_id][px,py,0] == 0
    return false if collision?(px,py)
    return true
  end
  def collision?(px,py)
    for event in $game_map.events.values
      if (event.px - px).abs <= event.collision && (event.py - py).abs <= event.collision
        next if event.through || event == self
        return true if event.priority_type == 1
      end
    end
    if @priority_type == 1 && !$game_player.in_airship?
      return true if ($game_player.px - px).abs <= @collision && ($game_player.py - py).abs <= @collision
    end
    return false
  end
  def check_touch(px,py)
  end
  def force_move_route(mr)
    apm_force_move_route(mr)
    multiply_commands
  end
  def multiply_commands
    return unless @pixel
    return unless Multiply_Commands
    return if @move_route.list.empty?
    new_route = []
    for cmd in @move_route.list
      if Commands.include?(cmd.code)
        Pixel.times do
          new_route << cmd
        end
      else
        new_route << cmd
      end
    end
    @move_route.list = new_route
  end
  def centralize(fx=@x.to_i,fy=@y.to_i)
    cx = @x - fx
    cy = @y - fy
    tx = (cx/Tile).to_i
    ty = (cy/Tile).to_i
    ty.times do; (cy > 0 ? pixel_mu(false) : pixel_md(false)); end
    tx.times do; (cx > 0 ? pixel_ml(false) : pixel_mr(false)); end
  end
  def move_random
    if @pixel
      case rand(8)
        when 0;  pixel_mu(false)
        when 1;  pixel_md(false)
        when 2;  pixel_ml(false)
        when 3;  pixel_mr(false)
        when 4;  pixel_mur
        when 5;  pixel_mul
        when 6;  pixel_mlr
        when 7;  pixel_mll
      end
    else
      case rand(4)
        when 0;  move_down(false)
        when 1;  move_left(false)
        when 2;  move_right(false)
        when 3;  move_up(false)
      end
    end
  end
  def move_type_toward_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if sx.abs + sy.abs >= 20
      move_random
    else
      if @pixel
      move_toward_player
      else
        case rand(6)
        when 0..3; move_toward_player
        when 4; move_random
        when 5; move_forward
        end
      end
    end
  end
  def move_toward_player
    sx = distance_x_from_player
    sy = distance_y_from_player
    if @pixel
      unless sy == 0
        sy > 0 ? pixel_mu(true) : pixel_md(true)
      end
      unless sx == 0
        sx > 0 ? pixel_ml(true) : pixel_mr(true)
      end
    else
      if sx != 0 or sy != 0
        if sx.abs > sy.abs
          sx > 0 ? move_left : move_right
          if @move_failed and sy != 0
            sy > 0 ? move_up : move_down
          end
        else
          sy > 0 ? move_up : move_down
          if @move_failed and sx != 0
            sx > 0 ? move_left : move_right
          end
        end
      end
    end
  end
  def move_away_from_player
    sx = distance_x_from_player
    sy = distance_y_from_player
    if @pixel
      unless sy == 0
        sy < 0 ? pixel_mu(true) : pixel_md(true)
      end
      unless sx == 0
        sx < 0 ? pixel_ml(true) : pixel_mr(true)
      end
    else
      if sx != 0 or sy != 0
        if sx.abs > sy.abs
          sx > 0 ? move_right : move_left
          if @move_failed and sy != 0
            sy > 0 ? move_down : move_up
          end
        else
          sy > 0 ? move_down : move_up
          if @move_failed and sx != 0
            sx > 0 ? move_right : move_left
          end
        end
      end
    end
  end
  def jump(xp,yp)
    apm_jump(xp,yp)
    @px = @x*Pixel
    @py = @y*Pixel
  end
end

class Game_Player < Game_Character
  alias apm_get_on_vehicle get_on_vehicle
  alias apm_get_off_vehicle get_off_vehicle
  def get_on_vehicle
    @pixel ? pixel_gov : apm_get_on_vehicle
  end
  def get_off_vehicle
    @pixel ? pixel_offv : apm_get_off_vehicle
  end
  def pixel_offv 
    if in_airship?
      return unless pixel_airdocs?(@px,@py)
    else
      fx = @px+Vehicle_Range[@direction][0]
      fy = @py+Vehicle_Range[@direction][1]
      return unless pixel_walk?(fx,fy)
    end
    $game_map.vehicles[@vehicle_type].get_off
    if in_airship?
      @direction = 2
    else
      jump(Vehicle_Range[@direction][0]*Tile,Vehicle_Range[@direction][1]*Tile)
      @transparent = false
    end
    @vehicle_getting_off = true
    @move_speed = 4
    @through = false
    @walking_bgm.play
    make_encounter_count
  end
  def pixel_gov
    fx = @px+Trigger_Range[@direction][0]
    fy = @py+Trigger_Range[@direction][1]
    if ($game_map.boat.px - fx).abs <= $game_map.boat.collision && ($game_map.boat.py - fy).abs <= $game_map.boat.collision
      return false if $physics[$game_map.map_id][@px+Vehicle_Range[@direction][0],@py+Vehicle_Range[@direction][1],1] == 0
      jump(Vehicle_Range[@direction][0]*Tile,Vehicle_Range[@direction][1]*Tile)
      @vehicle_getting_on = true
      @vehicle_type = 0
      @walking_bgm = RPG::BGM::last
      $game_map.boat.get_on
      return true
    elsif ($game_map.ship.px - fx).abs <= $game_map.ship.collision && ($game_map.ship.py - fy).abs <= $game_map.ship.collision
      return false if $physics[$game_map.map_id][@px+Vehicle_Range[@direction][0],@py+Vehicle_Range[@direction][1],2] == 0
      jump(Vehicle_Range[@direction][0]*Tile,Vehicle_Range[@direction][1]*Tile)
      @vehicle_getting_on = true
      @vehicle_type = 1
      @walking_bgm = RPG::BGM::last
      $game_map.ship.get_on
      return true
    elsif ($game_map.airship.px - fx).abs <= $game_map.airship.collision && ($game_map.airship.py - fy).abs <= $game_map.airship.collision
      $game_player.centralize($game_map.airship.x,$game_map.airship.y)
      @vehicle_getting_on = true
      @vehicle_type = 2
      @through = true
      @walking_bgm = RPG::BGM::last
      $game_map.airship.get_on
      return true
    end
    return false
  end
  def pixel_walk?(px,py)
    lvt = @vehicle_type
    @vehicle_type = -1
    result = pixel_passable?(px,py)
    @vehicle_type = lvt
    return result
  end
  def pixel_airdocs?(px,py)
    return false if $physics[$game_map.map_id][px,py,3] == 0
    return false if collision?(px,py)
    return true
  end
  def pixel_passable?(px,py)
    return false unless $game_map.pixel_valid?(px,py)
    return true if @through or debug_through?
    case @vehicle_type
    when 0
      return false if $physics[$game_map.map_id][px,py,1] == 0
    when 1
      return false if $physics[$game_map.map_id][px,py,2] == 0
    when 2
      return true
    else
      return false if $physics[$game_map.map_id][px,py,0] == 0
    end
    return false if collision?(px,py)
    return true
  end
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    if @pixel
      case Input.dir8
        when 1; pixel_mll
        when 2; pixel_md(true)
        when 3; pixel_mlr
        when 4; pixel_ml(true)
        when 6; pixel_mr(true)
        when 7; pixel_mul
        when 8; pixel_mu(true)
        when 9; pixel_mur
      end
    else
      case Input.dir4
        when 2;  move_down
        when 4;  move_left
        when 6;  move_right
        when 8;  move_up
      end
    end
  end
  def update_encounter
    return if $TEST and Input.press?(Input::CTRL)
    return if in_vehicle?
    if @pixel
      @encounter_count -= ($physics[$game_map.map_id][@px,@py,4] == 1 ? 2 : 1)
    else
      @encounter_count -= ($game_map.bush?(@x, @y) ? 2 : 1)
    end
  end
  def collision?(px,py)
    for event in $game_map.events.values
      if (event.px - px).abs <= event.collision && (event.py - py).abs <= event.collision
        next if event.through
        return true if event.priority_type == 1
      end
    end
    return false
  end
  def check_touch(px,py)
    return false if $game_map.interpreter.running?
    result = false
    for event in $game_map.events.values
      if (event.px - px).abs <= event.collision && (event.py - py).abs <= event.collision
        if [1,2].include?(event.trigger) && event.priority_type == 1
          event.start
          result = true
        end
      end
    end
    return result
  end
  def pixel_th?(t)
    return false if $game_map.interpreter.running?
    result = false
    for event in $game_map.events.values
      if (event.px - @px).abs <= event.collision && (event.py - @py).abs <= event.collision
        if t.include?(event.trigger) && event.priority_type != 1
          event.start
          result = true if event.starting
        end
      end
    end
    return result
  end
  def pixel_tt?(t)
    return false if $game_map.interpreter.running?
    result = false
    fx = @px+Trigger_Range[@direction][0]
    fy = @py+Trigger_Range[@direction][1]
    for event in $game_map.events.values
      if (event.px - fx).abs <= event.collision && (event.py - fy).abs <= event.collision
        if t.include?(event.trigger) && event.priority_type == 1
          event.start
          result = true
        end
      end
    end
    if !result && $physics[$game_map.map_id][fx,fy,5] == 1
      fx += Counter_Range[@direction][0]
      fy += Counter_Range[@direction][1]
      for event in $game_map.events.values
        if (event.px - fx).abs <= event.collision && (event.py - fy).abs <= event.collision
          if t.include?(event.trigger) && event.priority_type == 1
            event.start
            result = true
          end
        end
      end
    end
    return result
  end
  def check_touch_event
    return false if in_airship?
    return (@pixel ? pixel_th?([1,2]) : check_event_trigger_here([1,2]))
  end
  def check_action_event
    return false if in_airship?
    return true if (@pixel ? pixel_th?([0]) : check_event_trigger_here([0]))
    return (@pixel ? pixel_tt?([0,1,2]) : check_event_trigger_there([0,1,2]))
  end
end

class Game_Event < Game_Character
  alias apm_event_initialize initialize
  alias apm_setup setup
  def initialize(m,e)
    apm_event_initialize(m,e)
    setup_collision
  end
  def setup_collision
    @collision = Collision
    unless @list.nil?
      for value in [Tens de ter uma conta e sessão iniciada para poderes visualizar este link]
        next if @list[value].code != 108 && @list[value].code != 408
        if @list[value].parameters[0].include?("[collision ")
          @list[value].parameters[0].scan(/\[collision ([0.0-9.9]+)\]/)
          @collision = $1.to_i
        end
      end
    end
    @force_dc = false
    return unless @pixel
    unless @list.nil?
      for value in [Tens de ter uma conta e sessão iniciada para poderes visualizar este link]
        next if @list[value].code != 108 && @list[value].code != 408
        if @list[value].parameters[0] == ("[forcedefaultcmd]")
          @force_dc = true
        end
      end
    end
  end
  def check_touch(px,py)
    return if $game_map.interpreter.running? || $game_player.in_vehicle?
    if @trigger == 2 && ($game_player.px - px).abs <= @collision && ($game_player.py - py).abs <= @collision
      start if not jumping? and @priority_type == 1
    end
  end
  def setup(n)
    apm_setup(n)
    unless @page.nil?
      setup_collision
      multiply_commands unless @force_dc
    end
  end
  def move_random
    if @force_dc
      case rand(4)
        when 0; pixel_md(true)
        when 1; pixel_ml(true)
        when 2; pixel_mr(true)
        when 3; pixel_mu(true)
      end
    else
      super
    end
  end
  def pixel_mr(turn_ok)
    if @force_dc
      if pixel_passable?(@px+Pixel,@py)
        turn_right
        @x += 1
        @px += Pixel
        @real_x = (@x-1)*256
        increase_steps
        @move_failed = false
      else
        turn_right if turn_ok
        check_touch(@px+1, @py)
        @move_failed = true
      end
    else
      super(turn_ok)
    end
  end
  def pixel_ml(turn_ok)
    if @force_dc
      if pixel_passable?(@px-Pixel,@py)
        turn_left
        @x -= 1
        @px -= Pixel
        @real_x = (@x+1)*256
        increase_steps
        @move_failed = false
      else
        turn_left if turn_ok
        check_touch(@px-1, @py)
        @move_failed = true
      end
    else
      super(turn_ok)
    end
  end
  def pixel_mu(turn_ok)
    if @force_dc
      if pixel_passable?(@px,@py-Pixel)
        turn_up
        @y -= 1
        @py -= Pixel
        @real_y = (@y+1)*256
        increase_steps
        @move_failed = false
      else
        turn_up if turn_ok
        check_touch(@px, @py-1)
        @move_failed = true
      end
    else
      super(turn_ok)
    end
  end
  def pixel_md(turn_ok)
    if @force_dc
      if pixel_passable?(@px,@py+Pixel)
        turn_down
        @y += 1
        @py += Pixel
        @real_y = (@y-1)*256
        increase_steps
        @move_failed = false
      else
        turn_down if turn_ok
        check_touch(@px, @py+1)
        @move_failed = true
      end
    else
      super(turn_ok)
    end
  end
end

class Game_Map
  alias apm_initialize initialize
  alias apm_setup setup
  def initialize
    apm_initialize
    @pixel_w = 0
    @pixel_h = 0
  end
  def setup(id)
    apm_setup(id)
    @pixel_w = Pixel_Core::Pixel*@map.width
    @pixel_h = Pixel_Core::Pixel*@map.height
  end
  def pixel_valid?(px,py)
    return (px >= 0 && px < @pixel_w && py >= 0 && py < @pixel_h)
  end
end

class Game_Vehicle < Game_Character
  alias apm_set_location set_location
  alias apm_sync_with_player sync_with_player
  def set_location(m,x,y)
    apm_set_location(m,x,y)
    if Maps.include?(m)
      @x = @x.to_f
      @y = @y.to_f
      @pixel = true
    else
      @pixel = false
    end
    @px = (@x*Pixel).to_i
    @py = (@y*Pixel).to_i
  end
  def sync_with_player
    apm_sync_with_player
    @px = $game_player.px
    @py = $game_player.py
  end
end

class Khas_Physics
  Axis = Pixel_Core::Axis
  Bush_Axis = Pixel_Core::Bush_Axis
  Pixel = Pixel_Core::Pixel
  Tile = Pixel_Core::Tile
  Counter_Axis = Pixel_Core::Counter_Axis
  def initialize
    @maps = {}
    @passages = load_data("Data/System.rvdata").passages
    run
  end
  def run
    size = []; phase = 0
    for i in 0...Pixel_Core::Maps.size
      size << (100*i)/Pixel_Core::Maps.size
    end
    warn = Sprite.new
    warn.bitmap = Bitmap.new(192,32)
    warn.y = 376
    for id in Pixel_Core::Maps
      warn.bitmap.clear
      warn.bitmap.draw_text(32,0,160,32,"Loading... #{size[phase]}%")
      Graphics.update; Graphics.wait(5)
      map = load_data(sprintf("Data/Map%03d.rvdata", id))
      @maps[id] = Table.new(map.width*Pixel,map.height*Pixel,6)
      for x in 0...(map.width*Pixel)
        for y in 0...(map.height*Pixel)
          @maps[id][x,y,0] = process_point(x*Tile+Axis[0],y*Tile+Axis[1],map,0x01)
          @maps[id][x,y,1] = process_point(x*Tile+Axis[0],y*Tile+Axis[1],map,0x02)
          @maps[id][x,y,2] = process_point(x*Tile+Axis[0],y*Tile+Axis[1],map,0x04)
          @maps[id][x,y,3] = process_point(x*Tile+Axis[0],y*Tile+Axis[1],map,0x08)
          @maps[id][x,y,4] = bush_point?(x*Tile+Bush_Axis[0],y*Tile+Bush_Axis[1],map)
          @maps[id][x,y,5] = counter_point?(x*Tile+Counter_Axis[0],y*Tile+Counter_Axis[1],map)
        end
      end
      phase += 1
    end
    warn.bitmap.clear
    warn.bitmap.draw_text(32,0,160,32,"Loading... 100%")
    Graphics.update; Graphics.wait(20)
    warn.bitmap.dispose; warn.dispose
    warn = nil
    Graphics.update
  end
  def process_point(x,y,map,flag)
    return 0 unless (x >= 0 && x < map.width && y >= 0 && y < map.height)
    return 0 unless free_tile?(x.to_i,y.to_i,map,flag)
    return 0 unless free_tile?((x+Axis[2]).to_i,y.to_i,map,flag)
    return 0 unless free_tile?(x.to_i,(y+Axis[3]).to_i,map,flag)
    return 0 unless free_tile?((x+Axis[2]).to_i,(y+Axis[3]).to_i,map,flag)
    return 1
  end
  def bush_point?(x,y,map)
    return 1 if (@passages[map.data[x.to_i,y.to_i,1]] & 0x40 == 0x40 rescue false)
    return 1 if (@passages[map.data[(x+Bush_Axis[2]).to_i,y.to_i,1]] & 0x40 == 0x40 rescue false)
    return 1 if (@passages[map.data[x.to_i,(y+Bush_Axis[3]).to_i,1]] & 0x40 == 0x40 rescue false)
    return 1 if (@passages[map.data[(x+Bush_Axis[2]).to_i,(y+Bush_Axis[3]).to_i,1]] & 0x40 == 0x40 rescue false)
    return 0
  end
  def counter_point?(x,y,map)
    return 1 if (@passages[map.data[x.to_i,y.to_i,0]] & 0x80 == 0x80 rescue false)
    return 1 if (@passages[map.data[(x+Counter_Axis[2]).to_i,y.to_i,0]] & 0x80 == 0x80 rescue false)
    return 1 if (@passages[map.data[x.to_i,(y+Counter_Axis[3]).to_i,0]] & 0x80 == 0x80 rescue false)
    return 1 if (@passages[map.data[(x+Counter_Axis[2]).to_i,(y+Counter_Axis[3]).to_i,0]] & 0x80 == 0x80 rescue false)
    return 0
  end
  def free_tile?(x,y,map,flag)
    for i in [2, 1, 0]
      tile_id = map.data[x, y, i]
      return false if tile_id == nil
      pass = @passages[tile_id]
      next if pass & 0x10 == 0x10
      return true if pass & flag == 0x00
      return false if pass & flag == flag
    end
    return false
  end
  def [](id)
    return @maps[id]
  end
end

if File.exists?("Khas Physics.rgss2a") && !(Pixel_Core::Force_Physics_Update && $TEST)
  tmf = File.open("Khas Physics.rgss2a", "rb")
  $physics = Marshal.load(tmf); tmf.close
else
  $physics = Khas_Physics.new
  tmf = File.open("Khas Physics.rgss2a", "wb")
  Marshal.dump($physics,tmf); tmf.close
end

Download:
mediafire.com - 347kb

Como funciona o sistema de colisões?
Considere os ajustes padrão: os tiles são divididos por 4. Para entender o funcionamento do Arcthunder Pixel Movement, note que há um novo sistema de coordenadas: o sistema (PX, PY). A coordenada PX é 4 vezes maior que a coordenada padrão X, o mesmo para PY e Y. Exemplo:
5 PX = 1.25 X
8 PY = 2 Y
31 PX = 7.75 X
Agora, considerando um evento simples, há dois casos de colisão:

- Prioridade abaixo ou acima do herói (o herói pode passar pelo evento):
O evento será ativado quando as seguintes condições ocorrerem:
a. A diferença entre as coordenadas PX do jogador e do evento é menor ou igual à constante de colisão do evento?
b. A diferença entre as coordenadas PY do jogador e do evento é menor ou igual à constante de colisão do evento?
Se estas duas condições acontecerem, o evento será ativado! Em condições práticas:
[collision 0] fará a colisão ocorrer quando o jogador estiver exatamente encima do evento.
[collision 4] fará a colisão ocorrer a 1 tile (4 "pixeis") de distancia, como o padrão do maker.
Conclusões: Inserir valores entre 0 e 4 no comando [collision X] fará com que a colisão ocorra entre 0 e 1 tile.

- Prioridade junto ao herói (o herói não pode passar pelo evento):
O evento funciona como um obstaculo. O jogador não poderá passar se alguma das seguintes condições ocorrer:
a. A diferença entre as coordenadas PX do jogador e do evento é menor ou igual à constante de colisão do evento?
b. A diferença entre as coordenadas PY do jogador e do evento é menor ou igual à constante de colisão do evento?
Note que as condições são as mesmas, porém o evento é um obstaculo, então o jogador não poderá passar através do evento. Em condições práticas:

[collision 0] o jogador pode passear no evento, porém não exatamente encima!
[collision 1] define uma pequena area de colisão, o jogador não poderá passar no centro do evento.
[collision 3] define um bom valor de colisão para personagens
[collision 4] significa que o jogador não pode passar em qualquer parte do evento!
Conclusões: Nesse caso, [collision X] define o tamanho do evento!
Dica: Para eventos grandes, você talvez configure valores maiores que 4. Você pode usar com grandes arvores por exemplo.

Bom, é isso. Talvez seja um pouco complicado, você deverá fazer vários testes para entender.
Qualquer dúvida não hesitem em perguntar!

Arcthunder Physics Editor:
Agora você pode editar o arquivo "Khas Physics.rgss2a"
As instruções e o editor podem ser baixadas em mediafire.com
Veja a screenshot e o video abaixo:

[Tens de ter uma conta e sessão iniciada para poderes visualizar esta imagem]



O editor é um pouco complexo, recomendo-o somente para usuários avançados.
Se você está usando tilesets comuns (passagens quadradas), não é nescessário o editor.

Créditos:
Feito por Khas Arcthunder, leia os termos de uso contidos no script.[quote]

http://retrogamesbr7.blogspot.com

2Arcthunder Pixel Movement Empty Re: Arcthunder Pixel Movement Sáb 20 Out 2012, 17:55

DeadEnd

DeadEnd
Membro de Honra
Membro de Honra
Aii assim que eu gosto !!! :D

3Arcthunder Pixel Movement Empty Re: Arcthunder Pixel Movement Sáb 20 Out 2012, 17:57

Halt

Halt
Administrador
Administrador
As screens são de RMVX/RMVXA .-.

https://arenarpgmaker.forumeiros.com

4Arcthunder Pixel Movement Empty Re: Arcthunder Pixel Movement Sáb 20 Out 2012, 18:07

-Dark

-Dark
Sub Admnistrador
Sub Admnistrador
Topico movido para a área correta

Conteúdo patrocinado


Ver o tópico anterior Ver o tópico seguinte Ir para o topo  Mensagem [Página 1 de 1]

Permissões neste sub-fórum
Não podes responder a tópicos