Main Menu
  • Welcome to The RPG Maker Resource Kit.

[RESOLVED] Pixel-Movement Script Help Needed

Started by Yawgmothsbud, June 24, 2007, 12:39:03 AM

0 Members and 2 Guests are viewing this topic.

Yawgmothsbud

Not really sure the best way to sum up this problem, but I'll give it a go.

I'm using some Japanese pixelmovement script I found, and the only problem with it is that it doesnt change the animation rate for movement.
In other words, you still have to move a full square to see your sprite move his legs, allowing players to tap the arrow keys and get the sprite to "slide" briefly.

I'm not sure which script controls the rate at which your sprite changes frames, so I don't know where to go to fix this. I used a different pixelmovement script in the past, and it had this problem fixed, but was full of other bugs.

If anyone knows how to fix this, or a script that would do it, please let me know. Also, let me know if im not making sense; ill try to provide more details.

Yawgmothsbud

ok, its been awhile, gonna give this post a little BUMP  :-\

Zeriab

It has more than likely something to do with your script.
It could be an easy modification to the script or it could be a big change is needed to fix it.
We can't tell if you don't post the script ^_^

Yawgmothsbud

Ok, heres the script in question. I was thinking my problem might be soluble by modifying a basic XP script, so I held off on  posting this.
# ?????Main???????????????????????
# ????????????require??????????
# ????????????????????????????????
# ???????????????????????????????????
# ????????????????????????????
# ????????????????????????????????
# ????????????????????????????????????

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ? ??
  #--------------------------------------------------------------------------
  TOP_SPACE = BOTTOM_SPACE = 16 # ?????????
  LEFT_SPACE = RIGHT_SPACE = 16 # ?????????
  #--------------------------------------------------------------------------
  # ? ??????????
  #--------------------------------------------------------------------------
  attr_accessor :dot_moving     # ?????????nil:?????????? 0:???????
  #--------------------------------------------------------------------------
  # ? ???
  #--------------------------------------------------------------------------
  def initialize
    super
    # ???????????????
    @dot_moving = 0
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #--------------------------------------------------------------------------
  def moving?(by_update = false)
    # ??????update???????????????
    if !by_update and @dot_moving
      # ??????????????
      return @dot_moving != 0
    else
      # ??????????????????????????????
      return (!@dot_moving and (@real_x != @x * 128 or @real_y != @y * 128))
    end
  end
  #--------------------------------------------------------------------------
  # ? ????????
  #     move_route : ????????
  #--------------------------------------------------------------------------
  def force_move_route(move_route)
    # ???????
    @dot_moving = 0
    super(move_route)
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def update
    # ????????????
    last_real_x, last_real_y = @real_x, @real_y
    last_x, last_y = @x, @y
    # ?????????????????
    last_moving = moving?(true)
    # ?????????????????????
    # ???????????????????????
    unless moving?(true) or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # ?????
      dot_move(Input.dir4)
    end
    super
    # ??????????????????????????????
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      # ???????????
      $game_map.scroll_down(@real_y - last_real_y)
    end
    # ??????????????????????????????
    if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      # ???????????
      $game_map.scroll_left(last_real_x - @real_x)
    end
    # ??????????????????????????????
    if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      # ???????????
      $game_map.scroll_right(@real_x - last_real_x)
    end
    # ??????????????????????????????
    if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      # ???????????
      $game_map.scroll_up(last_real_y - @real_y)
    end
    # ?????????
    unless moving?(true)
      # ???????????????????????????????????
      if last_x != @x or last_y != @y or (!@dot_moving and last_moving)
        # ???????????????????????
        result = check_event_trigger_here([1,2])
        # ?????????????
        if result == false
          # ???????? ON ?? CTRL ??????????????
          unless $DEBUG and Input.press?(Input::CTRL)
            # ?????? ???????
            if @encounter_count > 0
              @encounter_count -= 1
            end
          end
        # ?????????????
        else
          # ??????????????????????
          @dot_moving = @dot_moving ? 0 : nil
        end
      end
      # C ??????????
      if Input.trigger?(Input::C)
        # ?????????????????
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? ????? : ????
  #--------------------------------------------------------------------------
  def move_type_custom
    # ??????????
    if jumping? or moving?
      return
    end
    # ???????????????????????
    while @move_route_index < @move_route.list.size
      # ?????????
      command = @move_route.list[@move_route_index]
      # ??????? 0 ? (??????) ???
      if command.code == 0
        # ????? [???????] ? ON ???
        if @move_route.repeat
          # ??????????????????
          @move_route_index = 0
        end
        # ????? [???????] ? OFF ???
        unless @move_route.repeat
          # ???????????
          if @move_route_forcing and not @move_route.repeat
            # ???????????
            @move_route_forcing = false
            # ??????????????
            @move_route = @original_move_route
            @move_route_index = @original_move_route_index
            @original_move_route = nil
          end
          # ??????????
          @stop_count = 0
        end
        return
      end
      # ??????? (?????????) ???
      if command.code <= 14
        # ?????????
        @dot_moving = nil
        # ??????????
        case command.code
        when 1  # ????
          move_down
        when 2  # ????
          move_left
        when 3  # ????
          move_right
        when 4  # ????
          move_up
        when 5  # ?????
          move_lower_left
        when 6  # ?????
          move_lower_right
        when 7  # ?????
          move_upper_left
        when 8  # ?????
          move_upper_right
        when 9  # ???????
          move_random
        when 10  # ?????????
          move_toward_player
        when 11  # ???????????
          move_away_from_player
        when 12  # ????
          move_forward
        when 13  # ????
          move_backward
        when 14  # ????
          jump(command.parameters[0], command.parameters[1])
        end
        # ????? [???????????] ? OFF ?????????
        if not @move_route.skippable and not moving? and not jumping?
          return
        end
        @move_route_index += 1
        return
      end
      # ???????
      if command.code == 15
        # ???????????
        @wait_count = command.parameters[0] * 2 - 1
        @move_route_index += 1
        return
      end
      # ?????????????
      if command.code >= 16 and command.code <= 26
        # ??????????
        case command.code
        when 16  # ????
          turn_down
        when 17  # ????
          turn_left
        when 18  # ????
          turn_right
        when 19  # ????
          turn_up
        when 20  # ?? 90 ???
          turn_right_90
        when 21  # ?? 90 ???
          turn_left_90
        when 22  # 180 ???
          turn_180
        when 23  # ???? 90 ???
          turn_right_or_left_90
        when 24  # ?????????
          turn_random
        when 25  # ??????????
          turn_toward_player
        when 26  # ??????????
          turn_away_from_player
        end
        @move_route_index += 1
        return
      end
      # ???????????
      if command.code >= 27
        # ??????????
        case command.code
        when 27  # ???? ON
          $game_switches[command.parameters[0]] = true
          $game_map.need_refresh = true
        when 28  # ???? OFF
          $game_switches[command.parameters[0]] = false
          $game_map.need_refresh = true
        when 29  # ???????
          @move_speed = command.parameters[0]
        when 30  # ???????
          @move_frequency = command.parameters[0]
        when 31  # ?????? ON
          @walk_anime = true
        when 32  # ?????? OFF
          @walk_anime = false
        when 33  # ?????? ON
          @step_anime = true
        when 34  # ?????? OFF
          @step_anime = false
        when 35  # ???? ON
          @direction_fix = true
        when 36  # ???? OFF
          @direction_fix = false
        when 37  # ???? ON
          @through = true
        when 38  # ???? OFF
          @through = false
        when 39  # ?????? ON
          @always_on_top = true
        when 40  # ?????? OFF
          @always_on_top = false
        when 41  # ????????
          @tile_id = 0
          @character_name = command.parameters[0]
          @character_hue = command.parameters[1]
          if @original_direction != command.parameters[2]
            @direction = command.parameters[2]
            @original_direction = @direction
            @prelock_direction = 0
          end
          if @original_pattern != command.parameters[3]
            @pattern = command.parameters[3]
            @original_pattern = @pattern
          end
        when 42  # ???????
          @opacity = command.parameters[0]
        when 43  # ???????
          @blend_type = command.parameters[0]
        when 44  # SE ???
          $game_system.se_play(command.parameters[0])
        when 45  # ?????
          result = eval(command.parameters[0])
        end
        @move_route_index += 1
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????? (??)
  #--------------------------------------------------------------------------
  def update_move
    # ?????????????????
    unless @dot_moving
      # ?????????????????????
      distance = 2 ** @move_speed
      # ??????????????
      if @y * 128 > @real_y
        # ????
        @real_y = [@real_y + distance, @y * 128].min
      end
      # ??????????????
      if @x * 128 < @real_x
        # ????
        @real_x = [@real_x - distance, @x * 128].max
      end
      # ??????????????
      if @x * 128 > @real_x
        # ????
        @real_x = [@real_x + distance, @x * 128].min
      end
      # ??????????????
      if @y * 128 < @real_y
        # ????
        @real_y = [@real_y - distance, @y * 128].max
      end
    end
    # ??????? ON ???
    if @walk_anime
      # ???????? 1.5 ???
      @anime_count += 1.5
    # ??????? OFF ????????? ON ???
    elsif @step_anime
      # ???????? 1 ???
      @anime_count += 1
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????????
  #     dir : ???0,2,4,6,8?
  #--------------------------------------------------------------------------
  def dot_move(dir)
    @dot_moving = dir
    # ???????????????????????????
    if dir == 0 or !dir
      return
    end
    # ?????
    last_real_x, last_real_y = @real_x, @real_y
    last_x, last_y = @x, @y
    # ?????????????????????
    distance = 2 ** @move_speed
    # ????????????????????
    case dir
    when 2
      turn_down
      @real_y += distance
      dx, dy = 0, 1
      x1, y1 = @real_x + LEFT_SPACE, @real_y + 127 - BOTTOM_SPACE
      x2, y2 = @real_x + 127 - RIGHT_SPACE, y1
    when 4
      turn_left
      @real_x -= distance
      dx, dy = -1, 0
      x1, y1 = @real_x + LEFT_SPACE, @real_y + TOP_SPACE
      x2, y2 = x1, @real_y + 127 - BOTTOM_SPACE
    when 6
      turn_right
      @real_x += distance
      dx, dy = 1, 0
      x1, y1 = @real_x + 127 - RIGHT_SPACE, @real_y + TOP_SPACE
      x2, y2 = x1, @real_y + 127 - BOTTOM_SPACE
    when 8
      turn_up
      @real_y -= distance
      dx, dy = 0, -1
      x1, y1 = @real_x + LEFT_SPACE, @real_y + TOP_SPACE
      x2, y2 = @real_x + 127 - RIGHT_SPACE, y1
    end
    # ????????????????????????????
    if (x1 / 128 != @x or y1  / 128 != @y) and (x2  / 128 != @x or y2  / 128 != @y)
      # ???????????????????
      @x, @y = x1 / 128 - dx, y1 / 128 - dy
      pass1 = passable?(@x, @y, dir)
      @x, @y = x2 / 128 - dx, y2 / 128 - dy
      pass2 = passable?(@x, @y, dir)
      # ???????
      @x, @y = last_x, last_y
      # ???????
      if pass1 and pass2
        # ?????????
        @x, @y = (@real_x + 64) / 128, (@real_y + 64) / 128
        # ?????????????
        if last_x != @x or last_y != @y
          increase_steps
        end
      # ????????
      else
        # ?????
        @dot_moving = 0
        # ????????
        case dir
        when 2
          @real_y = [(last_real_y + 64) / 128 * 128, last_real_y].max
          # ??????????
          if @real_x / 128 < @x
            # ???????????
            x1, x2 = x2, x1
          end
        when 4
          @real_x = [(last_real_x + 64) / 128 * 128, last_real_x].min
          # ??????????
          if @real_y / 128 < @y
            # ???????????
            y1, y2 = y2, y1
          end
        when 6
          @real_x = [(last_real_x + 64) / 128 * 128, last_real_x].max
          # ??????????
          if @real_y / 128 < @y
            # ???????????
            y1, y2 = y2, y1
          end
        when 8
          @real_y = [(last_real_y + 64) / 128 * 128, last_real_y].min
          # ??????????
          if @real_x / 128 < @x
            # ???????????
            x1, x2 = x2, x1
          end
        end
        # ???????????????????????????
        check_event_trigger_touch(x1 / 128, y1 / 128) or
        check_event_trigger_touch(x2 / 128, y2 / 128)
      end
    end
  end
end

class Scene_Map
  def update
    # ???
    loop do
      # ?????????????????????
      # (??????????????????????????????
      #  ???????????????????????????)
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # ???? (????)??????
      $game_system.update
      $game_screen.update
      # ??????????????????????
      unless $game_temp.player_transferring
        break
      end
      # ???????
      transfer_player
      # ????????????????????
      if $game_temp.transition_processing
        break
      end
    end
    # ???????????
    @spriteset.update
    # ?????????????
    @message_window.update
    # ??????????
    if $game_temp.gameover
      # ??????????????
      $scene = Scene_Gameover.new
      return
    end
    # ???????????
    if $game_temp.to_title
      # ???????????
      $scene = Scene_Title.new
      return
    end
    # ?????????????
    if $game_temp.transition_processing
      # ?????????????????
      $game_temp.transition_processing = false
      # ?????????
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # ????????????????
    if $game_temp.message_window_showing
      return
    end
    # ?????? ????? 0 ???????????????????
    if $game_player.encounter_count == 0 and $game_map.encounter_list != []
      # ??????????????????????
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # ???????
        n = rand($game_map.encounter_list.size)
        troop_id = $game_map.encounter_list[n]
        # ?????????
        if $data_troops[troop_id] != nil
          # ??????????????
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = troop_id
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # B ??????????
    if Input.trigger?(Input::B)
      # ????????????????????
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # ???????????? SE ?????????
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # ???????? ON ?? F9 ???????????
    if $DEBUG and Input.press?(Input::F9)
      # ???????????????
      $game_temp.debug_calling = true
    end
    # ??????????????????????????
    unless !$game_player.dot_moving and $game_player.moving?
      # ????????????
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
end

Yawgmothsbud

Bump...still looking for feedback...i was almost positive this was a pretty simple thing to do...

Yawgmothsbud


kathis

Wish I knew what the " ???????" were saying since they are just Japaneses characters unable to be presented. If I knew what they where saying about the section of the script it would be easier to dissect it and find the problem.
Project
New project. The other dimention DND
RPG makers challenge http://rmrk.net/index.php/topic,13503.0.html

Yawgmothsbud

Personally, I wouldn't mind English directions either, but I was lucky to find that script at all, and its the only bug-free pixel-movement script I've ever been able to find. I know nothing about scripts, but from my limited understanding I'm thinking a section could be added that would make it so that your sprite is updated with every arrow key press, as opposed to every 32 pixels you move. Of course, I have no idea how to do this  :(

Yawgmothsbud

I hate to be an obnoxious bumper/spammer, but I really need to get to the bottom of this. Anyone out there with any scripting knowledge? Helloooo?
::)

kami130

ok, i know this is a noob question, but what is the advantage of Pixel-movement over the default?
Current project. GAIA
http://rmrk.net/index.php/topic,19136.msg240888.html#msg240888
Overall    05.00%
Graphics 01.0%
Music      00.05%
Story      15.00%
Gmeplay 02.00%
JOIN!!

modern algebra

I'll take a look at it maybe tomorrow yawg. If I forget, bump it again. I wouldn't worry much about it yet though. You won't need it to work perfectly until you release the game anyway.

Yawgmothsbud

Quote from: kami130 on July 15, 2007, 04:30:02 AM
ok, i know this is a noob question, but what is the advantage of Pixel-movement over the default?

Its mostly an aesthetic addition, but I personally feel it lends a more professional feeling to a game, and even makes the whole play experiance more immersing. Rather than being bound to moving around on a grid, the player can fully explore their environment. It helps to create the illusion that the game is NOT just made up of lots of little tiles.

Thanks Modern, I realize this isn't terribly crucial at this point in my game's development, but its really the last major element I've added in a long time. I'm hoping resolving this problem will rekindle my creativity on this game. I've been in a bit of a slump for the past few weeks, and Summer is rapidly drawing to a close  :-[

Yawgmothsbud


modern algebra

hmm, I can't know if this'll work, but it seemed to make a bit of difference.

Scroll down the script to def update:


def update
    # ????????????
    last_real_x, last_real_y = @real_x, @real_y
    last_x, last_y = @x, @y
    # ?????????????????
    last_moving = moving?(true)
    # ?????????????????????
    # ???????????????????????
    unless moving?(true) or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # ?????
          dot_move(Input.dir4)
    end


Now, place update_move right under dot_move (Input.dir4), so that the code looks like this:


def update
    # ????????????
    last_real_x, last_real_y = @real_x, @real_y
    last_x, last_y = @x, @y
    # ?????????????????
    last_moving = moving?(true)
    # ?????????????????????
    # ???????????????????????
    unless moving?(true) or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # ?????
          dot_move(Input.dir4)
        update_move
    end


It might cause lag, I don't know, but I think it should improve the situation a little bit.

Yawgmothsbud

Awesome. That fixed the issue I was looking at quite nicely and simply. However, would it be possible to add a condition of some kind to the script so that if an directional key is HELD the update rate is normal? Otherwise, individual steps look fine, but holding a key makes your sprite kinda do a crazy speed-walk/shuffle.

Regardless, thanks Modern. Once again, you have triumphed where so many others have failed, and saved my ass from yet another irritating bug. You rock  ;D

modern algebra

I'm glad I can help out  ;D

Okay, well, try this. No guarantees it'll work, just an attempt:

in initialize, place this below @dot_moving = 0



@long_range_check = 0



Then go to update, and make it look like this:



  def update
    # ????????????
     last_real_x, last_real_y = @real_x, @real_y
    last_x, last_y = @x, @y
    # ?????????????????
    last_moving = moving?(true)
    # ?????????????????????
    # ???????????????????????
    unless moving?(true) or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # ?????
       if Input.dir4 != 0
       @long_range_check += 1
     else
       @long_range_check = 0
     end
      dot_move(Input.dir4)
      if @long_range_check.between? (0,10)
         update_move
      end
    end



The line underneath of that should be super, and everything from there should not be changed




Yawgmothsbud

Wow, that's exactly what I was looking for! Thanks again Modern (+ rep)  :D

shaz

#17
this looks really good.  Took me a while to figure out what the difference was! ;)

I notice now it seems to affect passabilities - well, if the tile I'm wanting to move to is passable but the one above it isn't, if I'm slightly higher than the middle of the current tile, it won't let me go (though it looks like it should 'cause I'm not running into anything).  I have to step down so I'm closer to the middle of the tile before I can keep moving.

Is that difficult to fix?

(pics)
[spoiler]

Big gap in front, but pile of wood is forcing to stop


can walk part way through fence - COULD change passability to fix this one, but I don't think it'd help the one above
[/spoiler]
Always remember you're unique.
Just like everybody else.

Kokowam

Wow, modern, I told you you were good at scripting? :D Also, I don't get what's happening in shaz's post. ???

tSwitch

I'm thinking for the sake of the database, someone should post the completely bug-free
pixel movement script.
(I would, but I ain't got it)

also @ shaz I understand the problem you're having, but could you please send me your scripts.rxdata
and maps.rxdata so that I can see what mods I need to do to the script to make that work
(I'm sure I can just change a few variables here and there to fix the first problem, but I dunno about the 2nd)

*note, NAMKCOR does not make any claim that the problem will be fixed an an extremely timely manner, if at all, NAMKCOR is by no means and expert, and is merely offering to try to help you


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

shaz

on their way.  Everything is standard, except the above script which I've added and made the suggested mods to.  Map is just standard tileset.  I'll email those files through to you.

It's not a biggie - I'm happy to go without the script, but I think others will run into the same problem if they're using it with all the default tilesets.
Always remember you're unique.
Just like everybody else.

tSwitch

err...e-mail?
alright, it would have been simpler to PM or attach it to the post

when I get it, I'll see what I can do


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

shaz

#22
sorry - not sure how to attach files to a PM or a post without having to load them up somewhere.

(lol - thanks Namkcor - I was looking for something in the icons!)

ok - zip includes scripts.rxdata and anything with map*.rxdata.  Will load up the whole project if it's helpful.
Always remember you're unique.
Just like everybody else.

tSwitch

Additional Options> Browse> select the file> post


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon