Aldeia RPG

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Suporte ao desenvolvimento de jogos


5 participantes

    Sistema de Plataforma

    Paulo Soreto
    Paulo Soreto
    Lenda
    Lenda


    Mensagens : 1980
    Créditos : 367

    Ficha do personagem
    Nível: 1
    Experiência:
    Sistema de Plataforma Left_bar_bleue0/0Sistema de Plataforma Empty_bar_bleue  (0/0)
    Vida:
    Sistema de Plataforma Left_bar_bleue30/30Sistema de Plataforma Empty_bar_bleue  (30/30)

    Sistema de Plataforma Empty Sistema de Plataforma

    Mensagem por Paulo Soreto Sáb Out 06, 2012 5:55 pm

    Fala ae pessoal, eu comecei a fazer um sistema de plataforma pro meu jogo mas daí repensei e achei melhor fazer ele normal mesmo xD
    O sistema está inacabado, possui alguns bugs e tal, mas coisas mínimas, também é funcional em netplay (já que fiz nele :S)

    Screens? Ele só faz o carinha andar só na esquerda e direita, pular na diagonal e descer .-.

    Script
    Código:
    #================================================================
    # By Soreto
    # 06/10/2012
    # AVISO: Sistema incompleto!
    #================================================================
    module ConfigPlat
      MAX_JUMP = 2
    end
    class Game_Player
      alias srt_pl_update update
      def update
        srt_pl_update
        last_moving = moving?
        unless moving? or $game_system.map_interpreter.running? or
              @move_route_forcing or $game_temp.message_window_showing
          case Input.dir4
          when 2
            move_down
          when 4
            move_left
          when 6
            move_right
          when 1
            move_lower_left
          when 3
            move_lower_right
          when 7
            move_upper_left
          when 9
            move_upper_right
          end
        end
      end
    end
    class Game_Character
      def move_down(turn_enabled = true)
        if passable?(@x, @y, 4) or passable?(@x, @y, 6)
          @y += ConfigPlat::MAX_JUMP
          increase_steps
        else
          check_event_trigger_touch(@x, @y+1)
        end
      end
      def move_up
        @y -= 2 if @y > 0
        return
      end
      def move_left(turn_enabled = true)
        if !passable?(@x, @y, 4)
          turn_left
          @x -= ConfigPlat::MAX_JUMP
          increase_steps
        else
          check_event_trigger_touch(@x-1, @y)
        end
      end
      def move_right(turn_enabled = true)
        if !passable?(@x, @y, 6)
          turn_right
          @x += 1
          increase_steps
        else
          check_event_trigger_touch(@x+1, @y)
        end
      end
      def move_upper_left
        unless @direction_fix
          @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
        end
        if (!passable?(@x, @y, 6) and !passable?(@x, @y - 1, 4)) or
          (!passable?(@x, @y, 4) and !passable?(@x - 1, @y, 6))
          @x -= ConfigPlat::MAX_JUMP
          @y -= ConfigPlat::MAX_JUMP
          increase_steps
        end
      end
      def move_upper_right
        unless @direction_fix
          @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
        end
        if (!passable?(@x, @y, 4) and !passable?(@x, @y - 1, 6)) or
          (!passable?(@x, @y, 6) and !passable?(@x + 1, @y, 4))
          @x += ConfigPlat::MAX_JUMP
          @y -= ConfigPlat::MAX_JUMP
          increase_steps
        end
      end
      alias srt_up_update update
      def update
        srt_up_update
        for i in 1...3
          if passable?(@x, @y - i, 6) and !moving?
            move_down
          end
        end
        if Input.trigger?(Input::Letters["A"])
          if @direction == 4
            move_upper_left
          elsif @direction == 6
            move_upper_right
          end
        end
      end
    end

    Obs: Para criar plataformas onde o personagem possa andar, use o tile com bloqueio.


    _________________
    Sistema de Plataforma FwYnoXI
    Samuka_Maker
    Samuka_Maker
    Aldeia Friend
    Aldeia Friend


    Medalhas : Sistema de Plataforma WBLhI
    Mensagens : 1204
    Créditos : 127

    Sistema de Plataforma Empty Re: Sistema de Plataforma

    Mensagem por Samuka_Maker Sáb Out 06, 2012 6:27 pm

    .-. acho q n devo dar osparabéns pq vcv sabe q eu diria isso
    +1 cred
    mesmo eu preferindo oq o rd12 usa .-.
    talves eu o use xD
    vlw ai manin
    acho q a maioria dos scripts de plataforma são iguais hsuhaosahuoa


    _________________

    Life rpg maker, suporte para criacao de jgoos online eoffline, link do forum:(v2.0)
    http://liferpgmakerv2.forumais.com/

    Sistema de Plataforma 6f4EA

    Sistema de Plataforma Bxvno
    Tópico original/Tópico de Recrutamento
    guilherme.maker
    guilherme.maker
    Novato
    Novato


    Mensagens : 6
    Créditos : 0

    Sistema de Plataforma Empty Re: Sistema de Plataforma

    Mensagem por guilherme.maker Sáb Out 06, 2012 6:36 pm

    Só faltou passar o Input Module né amigão!!!


    _________________
    Sistema de Plataforma Fs_pc
    Paulo Soreto
    Paulo Soreto
    Lenda
    Lenda


    Mensagens : 1980
    Créditos : 367

    Ficha do personagem
    Nível: 1
    Experiência:
    Sistema de Plataforma Left_bar_bleue0/0Sistema de Plataforma Empty_bar_bleue  (0/0)
    Vida:
    Sistema de Plataforma Left_bar_bleue30/30Sistema de Plataforma Empty_bar_bleue  (30/30)

    Sistema de Plataforma Empty Re: Sistema de Plataforma

    Mensagem por Paulo Soreto Sáb Out 06, 2012 6:38 pm

    Samuka: Realmente kkk
    A maioria são iguais mesmo, mas em geral, quase nenhum tem uma boa física.
    Pode me passar o link do que o rd usa?

    Guilherme: Mes esqueci disso, mas uso o do NP Master.


    _________________
    Sistema de Plataforma FwYnoXI
    Samuka_Maker
    Samuka_Maker
    Aldeia Friend
    Aldeia Friend


    Medalhas : Sistema de Plataforma WBLhI
    Mensagens : 1204
    Créditos : 127

    Sistema de Plataforma Empty Re: Sistema de Plataforma

    Mensagem por Samuka_Maker Sáb Out 06, 2012 7:04 pm

    soreto, eu não sei se tem na aldeia :C
    mas por via das duvidas tá ai:
    Código:
    #======================================#
    #
    #
    # Platform System 2.001
    #  Sweet Liar Adaption
    #
    #
    #
    #======================================#

    class Game_Character
      attr_reader  :xv                      # Trục x
      attr_reader  :yv                      # Trục y
      attr_accessor :gravity                  # Độ cao
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      alias pms_initialize initialize
      def initialize
        pms_initialize
        @xv = 0
        @yv = 0
        @move_count = 0
        @gravity = 6
        @jump_flag = false
      end
      #--------------------------------------------------------------------------
      # * Determine if Moving
      #--------------------------------------------------------------------------
      def moving?
        # If logical coordinates differ from real coordinates,
        # movement is occurring.
        return @move_count > 0
      end
      #--------------------------------------------------------------------------
      # * Tocch
      #    mode :
      #    * 0 : Left or Right
      #    * 1 : Up or Down
      #--------------------------------------------------------------------------
      def touch?(mode = 0)
        if mode == 0
          if @xv > 0
            check_event_trigger_touch(@x+1, @y)
          else
            check_event_trigger_touch(@x-1, @y)
          end
        else
          if @xv > 0
            check_event_trigger_touch(@x, @y+1)
          else
            check_event_trigger_touch(@x, @y-1)
          end
        end
      end
      def distance_x_from_player
        sx = @x - $game_player.x
        return sx
      end
      def passable?(mode = 0)
        left_x = @real_x + 32 >> 7    # 4 << 3
        right_x = @real_x + 110 >> 7  # 28 << 3
        up_y = @real_y + 16>> 7      # 2 << 3
        down_y = @real_y + 110 >> 7  # 28 << 3
        # Get new coordinates
        if mode == 0
          if @xv > 0
            return false unless $game_map.passable?(right_x, up_y,6)
            return false unless $game_map.passable?(right_x, down_y,6)
          else
            return false unless $game_map.passable?(left_x, up_y,4)
            return false unless $game_map.passable?(left_x, down_y,4)
          end
        else
          if @yv > 0
            return false unless $game_map.passable?(left_x, down_y,2)
            return false unless $game_map.passable?(right_x, down_y,2)
          else
            return false unless $game_map.passable?(left_x, up_y,8)
            return false unless $game_map.passable?(right_x, up_y,8)
          end
        end
     
        return true if @through
        # Loop all events
        for event in $game_map.events.values
          new_x = (event.direction == 6 ? ((@real_x + 32 >> 7) + 1) : event.direction == 4 ? ((@real_x + 110 >> 7) + 1) : 0)
          new_y = (event.direction == 2 ? ((@real_y + 16 >> 7) + 1) : event.direction == 8 ? ((@real_y + 110 >> 7) + 1) : 0)
          # If event coordinates are consistent with move destination
          if event.x == new_x and event.y == new_y
            # If through is OFF
            unless event.through
              # If self is event
              if self != $game_player
                # impassable
                return false
              end
              # With self as the player and partner graphic as character
              if event.character_name != ""
                # impassable
                return false
              end
            end
          end
        end
     
        new1_x = ($game_player.direction == 6 ? ((@real_x + 32 >> 7) + 1) : $game_player.direction == 4 ? ((@real_x + 110 >> 7) + 1) : 0)
        new1_y = ($game_player.direction == 2 ? ((@real_y + 16 >> 7) + 1) : $game_player.direction == 8 ? ((@real_y + 110 >> 7) + 1) : 0)
       
        if $game_player.x == new1_x and $game_player.y == new1_y
          # If through is OFF
          unless $game_player.through
            # If your own graphic is the character
            if @character_name != ""
              # impassable
              return false
            end
          end
        end
        return true
      end
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        return if self.id == 1
       
        update_x
        update_y
        # Branch with jumping, moving, and stopping
        if jumping?
          update_jump
        elsif moving?
          @move_count -= 1
          if @walk_anime
            @anime_count += 1.5
          elsif @step_anime
            @anime_count += 1
          end
        else
          update_stop
        end
        # If animation count exceeds maximum value
        # * Maximum value is move speed * 1 taken from basic value 18
        if @anime_count > 18 - @move_speed * 2
          # If stop animation is OFF when stopping
          if not @step_anime and @stop_count > 0
            # Return to original pattern
            @pattern = @original_pattern
          # If stop animation is ON when moving
          else
            # Update pattern
            @pattern = (@pattern + 1) % 4
          end
          # Clear animation count
          @anime_count = 0
        end
        # If waiting
        if @wait_count > 0
          # Reduce wait count
          @wait_count -= 1
          return
        end
        # If move route is forced
        if @move_route_forcing
          # Custom move
          move_type_custom
          return
        end
        # When waiting for event execution or locked
        if @starting or lock?
          # Not moving by self
          return
        end
        # If stop count exceeds a certain value (computed from move frequency)
        if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
          # Branch by move type
          case @move_type
          when 1  # Random
            move_type_random
          when 2  # Approach
            move_type_toward_player
          when 3  # Custom
            move_type_custom
          end
        end
      end
      #--------------------------------------------------------------------------
      # ● Update X
      #--------------------------------------------------------------------------
      def update_x
        if !@jump_flag && !moving?
          @xv = 0
          return
        end
        last_x = @real_x
        @real_x += @xv
        @x = @real_x >> 7
        unless passable?(0)
          @real_x = last_x
          @x = @real_x >> 7
          @xv = 0
          touch?(0)
        end
      end
      #--------------------------------------------------------------------------
      # ● Update Y
      #--------------------------------------------------------------------------
      def update_y
        if  @gravity > 0
          @yv += @gravity
          @yv = 64 if @yv > 64
        elsif !moving?
          @yv = 0
          return
        end
        last_y = @real_y
        @real_y += @yv
        @y = @real_y >> 7
        unless passable?(1)
          @real_y = last_y
          @y = @real_y >> 7
          @jump_flag = false if @yv > 0
          @yv = 0
          touch?(1)
        end
      end
      #--------------------------------------------------------------------------
      # * Move Down
      #    turn_enabled : a flag permits direction change on that spot
      #--------------------------------------------------------------------------
      def move_down(turn_enabled = true)
        @stop_count = 0
        d = 2 ** @move_speed
        @yv = d
        @move_count = 128 / d
      end
      #--------------------------------------------------------------------------
      # * Move Left
      #    turn_enabled : a flag permits direction change on that spot
      #--------------------------------------------------------------------------
      def move_left(turn_enabled = true)
        turn_left
        d = 2 ** @move_speed
        @xv = 0 - d
        @move_count = 128 / d
        increase_steps
      end
      #--------------------------------------------------------------------------
      # * Move Right
      #    turn_enabled : a flag permits direction change on that spot
      #--------------------------------------------------------------------------
      def move_right(turn_enabled = true)
        turn_right
        d = 2 ** @move_speed
        @xv = d
        @move_count = 128 / d
        increase_steps
      end
      #--------------------------------------------------------------------------
      # * Move up
      #    turn_enabled : a flag permits direction change on that spot
      #--------------------------------------------------------------------------
      def move_up(turn_enabled = true)
        @stop_count = 0
        d = 2 ** @move_speed
        @yv = 0 - d
        @move_count = 128 / d
      end
      #--------------------------------------------------------------------------
      # * Move Lower Left
      #--------------------------------------------------------------------------
      def move_lower_left
        # If no direction fix
        unless @direction_fix
          # Face down is facing right or up
          @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
        end
          # Update coordinates
          d = 2 ** @move_speed
          @xv = 0 - d
          @yv = d
          @move_count = 128 / d
          # Increase steps
          increase_steps
      end
      #--------------------------------------------------------------------------
      # * Move Lower Right
      #--------------------------------------------------------------------------
      def move_lower_right
        # If no direction fix
        unless @direction_fix
          # Face right if facing left, and face down if facing up
          @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
        end
          d = 2 ** @move_speed
          @xv = d
          @yv = d
          @move_count = 128 / d
          # Increase steps
          increase_steps
      end
      #--------------------------------------------------------------------------
      # * Move Upper Left
      #--------------------------------------------------------------------------
      def move_upper_left
        # If no direction fix
        unless @direction_fix
          # Face left if facing right, and face up if facing down
          @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
        end
          # Update coordinates
          d = 2 ** @move_speed
          @xv = 0 - d
          @yv = 0 - d
          @move_count = 128 / d
          # Increase steps
          increase_steps
      end
      #--------------------------------------------------------------------------
      # * Move Upper Right
      #--------------------------------------------------------------------------
      def move_upper_right
        # If no direction fix
        unless @direction_fix
          # Face right if facing left, and face up if facing down
          @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
        end
          d = 2 ** @move_speed
          @xv = d
          @yv = 0 - d
          @move_count = 128 / d
          # Increase steps
          increase_steps
      end
      #--------------------------------------------------------------------------
      # * Move at Random
      #--------------------------------------------------------------------------
      def move_random
        case rand(@gravity == 0 ? 4 : 2)
        when 0;  move_left(false)
        when 1;  move_right(false)
        when 2;  move_up(false)
        when 3;  move_down(false)
        end
      end
      #--------------------------------------------------------------------------
      # * Move toward Player
      #--------------------------------------------------------------------------
      def move_toward_player
        sx = distance_x_from_player
        sx > 0 ? move_left : move_right
      end
      #--------------------------------------------------------------------------
      # * Move away from Player
      #--------------------------------------------------------------------------
      def move_away_from_player
        sx = distance_x_from_player
        sx > 0 ? move_right : move_left
      end
      #--------------------------------------------------------------------------
      # * Jump
      #  Không cần nhập giá trị x và y ở RMXP
      #--------------------------------------------------------------------------
      def jump(x_plus, y_plus)
        return if @jump_flag
        @yv = -48
        @jump_flag = true
        @stop_count = 0
      end
      #--------------------------------------------------------------------------
      # * Turn Towards Player
      #--------------------------------------------------------------------------
      def turn_toward_player
        if @real_x < $game_player.real_x
          turn_right
        else
          turn_left
        end
      end
    end
     

    class Game_Player < Game_Character
      #--------------------------------------------------------------------------
      # * Passable Determinants
      #--------------------------------------------------------------------------
      def passable?(mode)
        super(mode)
      end
     
      def move_left(turn_ok = true)
        turn_left
        max_speed = -16
        @xv = [@xv + 2, max_speed].min if @xv < max_speed and !@jump_flag
        @xv = [@xv - 2, max_speed].max if @xv > max_speed
        @move_count = 1
      end
     
      def move_right(turn_ok = true)
        turn_right
        max_speed = 16
        @xv = [@xv + 2, max_speed].min if @xv < max_speed
        @xv = [@xv - 2, max_speed].max if @xv > max_speed and !@jump_flag
        @move_count = 1
      end
     
      def update_x
        if !@jump_flag && !moving?
          @xv = [@xv + 2, 0].min if @xv < 0
          @xv = [@xv - 2, 0].max if @xv > 0
        end
        last_x = @real_x
        @real_x += @xv
        @x = @real_x >> 7
        unless passable?(0)
          @real_x = last_x
          @x = @real_x >> 7
          @xv = 0
          touch?(0)
        end
      end
      def move_jump(yv)
        @yv = yv
        @jump_flag = true
      end
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        # Remember whether or not moving in local variables
        last_moving = moving?
        # If moving, event running, move route forcing, and message window
        # display are all not occurring
        unless moving? or $game_system.map_interpreter.running? or
              @move_route_forcing or $game_temp.message_window_showing
          # Move player in the direction the directional button is being pressed
        if $key.call(65)!= 0
          move_left
        elsif $key.call(68) != 0
          move_right
        end
        end

        if $key.call(87) != 0 && @jump_flag == false    # Jump
          move_jump(-48)
        end
        # Remember coordinates in local variables
        last_real_x = @real_x
        last_real_y = @real_y
        super
        # If character moves down and is positioned lower than the center
        # of the screen
        if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y-3
          # Scroll map down
          #$game_map.scroll_down(@real_y - last_real_y)
          $map_scrolls.push Map_Scroll_Down.new(@real_y - last_real_y)
        end 
        # If character moves left and is positioned more let on-screen than
        # center
        if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
          # Scroll map left
          $game_map.scroll_left(last_real_x - @real_x)
        end
        # If character moves right and is positioned more right on-screen than
        # center
        if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
          # Scroll map right
          $game_map.scroll_right(@real_x - last_real_x)
        end
        # If character moves up and is positioned higher than the center
        # of the screen
        if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y-3
          # Scroll map up
          #$game_map.scroll_up(last_real_y - @real_y)
          $map_scrolls.push Map_Scroll_Up.new(@real_y - last_real_y)
        end
        # If not moving
        unless moving?
          # If player was moving last time
          if last_moving
            # Event determinant is via touch of same position event
            result = check_event_trigger_here([1,2])
            # If event which started does not exist
            if result == false
              # Disregard if debug mode is ON and ctrl key was pressed
              unless $DEBUG and Input.press?(Input::CTRL)
                # Encounter countdown
                if @encounter_count > 0
                  @encounter_count -= 1
                end
              end
            end
          end
          # If C button was pressed
          if Input.trigger?(Input::C)
            # Same position and front event determinant
            check_event_trigger_here([0])
            check_event_trigger_there([0,1,2])
          end
        end
      end
    end
     
    class Game_Event < Game_Character
      def get_name
        return @event.name
      end
    end


    _________________

    Life rpg maker, suporte para criacao de jgoos online eoffline, link do forum:(v2.0)
    http://liferpgmakerv2.forumais.com/

    Sistema de Plataforma 6f4EA

    Sistema de Plataforma Bxvno
    Tópico original/Tópico de Recrutamento
    RD12
    RD12
    Lenda
    Lenda


    Medalhas : Sistema de Plataforma 48080450Sistema de Plataforma Trophy11Sistema de Plataforma GIueZSistema de Plataforma ZgLkiRU
    Mensagens : 1946
    Créditos : 745

    Sistema de Plataforma Empty Re: Sistema de Plataforma

    Mensagem por RD12 Sáb Out 06, 2012 7:08 pm

    ficou legal paulo soreto pogger. o que eu uso é por pixels.
    Samuka_Maker
    Samuka_Maker
    Aldeia Friend
    Aldeia Friend


    Medalhas : Sistema de Plataforma WBLhI
    Mensagens : 1204
    Créditos : 127

    Sistema de Plataforma Empty Re: Sistema de Plataforma

    Mensagem por Samuka_Maker Sex Jan 04, 2013 12:40 pm

    desculpem-me por reviver este tópico, porem de acordo com as regras pode-se reviver tópicos em casos de duvidas/erros.
    podem me corrigir caso oque disse esteja errado.
    _____________________________________
    estava testando seu script em um jogo off-line do qual você disse que funcionaria, quando iniciei um jogo deu um erro:


    Erro no script Plataforma, na lina 96 'NameError' uninitialized constant Input::Letters

    Linha do erro: if Input.trigger?(Input::Letters["A"])
    se puder corrigir ficarei grato

    ______________________
    att.Samuka_Maker


    _________________

    Life rpg maker, suporte para criacao de jgoos online eoffline, link do forum:(v2.0)
    http://liferpgmakerv2.forumais.com/

    Sistema de Plataforma 6f4EA

    Sistema de Plataforma Bxvno
    Tópico original/Tópico de Recrutamento
    Komuro Takashi
    Komuro Takashi
    Colaborador
    Colaborador


    Mensagens : 1047
    Créditos : 130

    Sistema de Plataforma Empty Re: Sistema de Plataforma

    Mensagem por Komuro Takashi Qua Jan 30, 2013 6:48 am

    @samuka pelo que eu entendi o problema é seu script de Input que é separado desse, vc possui tal script?....caso não tem o do NetPlayMaster mais aconselho montar o seu próprio o usar o do Cidi que é mais completo, o RD também tem um bem legal e se não me engano ele postou aqui na Aldeia.

    Caso haja mais alguma dúvida mandar por PM.


    _________________
    Sistema de Plataforma Takashi_komuro_by_minato8-d51g9o4

    Paga um café? Patreon

    Conteúdo patrocinado


    Sistema de Plataforma Empty Re: Sistema de Plataforma

    Mensagem por Conteúdo patrocinado


      Data/hora atual: Qui Mar 28, 2024 6:24 am