VX 스크립트

기타
2011.07.22 14:06

화면 확대 스크립트

profile
조회 수 3061 추천 수 2 댓글 12
Atachment
첨부 '1'
화면 확대 스크립트 입니다. 사용법은 다음과 같습니다.
$game_map.start_zoom(확대율, 확대속도)
$game_map.start_zoom_back(확대율, 확대속도, 돌아오는 속도)

첨부한 스크립트도 같이 사용해야 합니다.

class Game_Map
  attr_accessor :zoom
  alias zoom_initialize initialize
  alias zoom_update update
  def initialize
    zoom_initialize
    @zoom = 1.0
    @zoom_target = 1.0
    @zoom_duration = 0
    @zoom_back_duration = 0
    @original_display_x = @display_x
    @original_display_y = @display_y
  end
  def update
    zoom_update
    if @zoom_duration >0
      @zoom_duration -= 1
      @zoom += @zoom_speed
      @display_x = $game_player.real_x - 256 * 8 / @zoom
      @display_y = $game_player.real_y - 256 * 6 / @zoom
      if @display_x < 0
        @display_x = 0
      end
      if @display_y < 0
        @display_y = 0
      end
      if @display_x > @map.width * 256 - 256 * 17 / @zoom
        @display_x =  @map.width * 256 - 256 * 17 / @zoom
      end
      if @display_y > @map.height * 256 - 256 * 13 / @zoom
        @display_y =  @map.height * 256 - 256 * 13 / @zoom
      end
    else
      @zoom = @zoom_target
    end
    if @zoom_back_duration >0
      @zoom_back_duration -= 1
      if @zoom_back_duration == 0
        start_zoom(1,20)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set Display Position
  #     x : New display X coordinate (*256)
  #     y : New display Y coordinate (*256)
  #--------------------------------------------------------------------------
  def set_display_pos(x, y)
    @display_x = (x + @map.width * 256) % (@map.width * 256)
    @display_y = (y + @map.height * 256) % (@map.height * 256)
    @parallax_x = x
    @parallax_y = y
  end
  #--------------------------------------------------------------------------
  # * Calculate X coordinate, minus display coordinate
  #     x : x-coordinate
  #--------------------------------------------------------------------------
  def adjust_x(x)
    if loop_horizontal? and x < @display_x - @margin_x
      return x - @display_x + @map.width * 256
    else
      return (x - @display_x) * @zoom
    end
  end
  #--------------------------------------------------------------------------
  # * Calculate Y coordinate, minus display coordinate
  #     y : y-coordinate
  #--------------------------------------------------------------------------
  def adjust_y(y)
    if loop_vertical? and y < @display_y - @margin_y
      return y - @display_y + @map.height * 256
    else
      return (y - @display_y) * @zoom
    end
  end
  def start_zoom(zoom,zoom_speed)
    @original_display_x = @display_x
    @original_display_y = @display_y
    @zoom_target = zoom
    if zoom > @zoom
      @zoom_speed = zoom_speed.to_f / 60
    else
      @zoom_speed = -zoom_speed.to_f / 60
    end
    @zoom_duration = (zoom - @zoom) / @zoom_speed
  end
  def start_zoom_back(zoom,zoom_speed,duration)
    @original_display_x = @display_x
    @original_display_y = @display_y
    @zoom_target = zoom
    if zoom > @zoom
      @zoom_speed = zoom_speed.to_f / 60
    else
      @zoom_speed = -zoom_speed.to_f / 60
    end
    @zoom_duration = (zoom - @zoom) / @zoom_speed
    @zoom_back_duration = duration
  end
end

class Spriteset_Map
  alias zoom_update update
  alias zoom_update_characters update_characters
  def update
   @zoom = $game_map.zoom
    zoom_update
  end
  def update_tilemap
    @tilemap.ox = ($game_map.display_x) / 8
    @tilemap.oy = ($game_map.display_y) / 8 
    @tilemap.zoom = @zoom
    @tilemap.update
  end
  
  def update_characters
    zoom_update_characters
    if @zoom != 0
      for sprite in @character_sprites
          sprite.zoom = @zoom
      end
    end
  end
end

class Sprite_Character
  attr_accessor :zoom
  alias zoom_update update
  alias zoom_initialize initialize
  def initialize(viewport, character = nil)
    @zoom = 1
    zoom_initialize(viewport, character)
  end
  def update
    zoom_update
    self.zoom_x = @zoom
    self.zoom_y = @zoom
  end
end

class Game_Character
  def screen_x
    return ($game_map.adjust_x(@real_x) + 8007) / 8 - 1000 + 16 * $game_map.zoom
  end
  def screen_y
    y = ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32 * $game_map.zoom
    y -= 4 unless object?
    if @jump_count >= @jump_peak
      n = @jump_count - @jump_peak
    else
      n = @jump_peak - @jump_count
    end
    return y - (@jump_peak * @jump_peak - n * n) / 2
  end

end 









Who's 에돌이

profile
돌이 돌이 에돌이. 에돌 에돌 에돌이. 
Comment '12'
  • ?
    석진이 2011.07.23 02:33

    우와 멋있다!!!

  • ?
    베넘 2011.07.23 02:48

    오.. 멋지다. 잘쓸게요. >_<

  • ?
    신휴이 2011.07.24 12:15

    스크립트도 스크립트지만 응용 비디오가 정말 인상 깊네요.

  • ?
    오그리토그리 2011.07.24 23:42

    오옷! 잘쓰겠습니다

  • ?
    RPG가 짱이야 2011.07.26 21:10

    동영상에 렉이....

  • profile
    개촙포에버 2011.07.27 20:57

    저기..;;동영상에 나온 응용한거 말이죠.예제좀 올려주시면 안될까요?

    ㅎㅎ

  • ?
    시객 2011.07.29 14:50

    잘 쓸께요


  • ?
    웃자 2011.07.29 20:54

    예제를 꼭 올려주세요.. 어떻게 사용하는지.. 잘 모르겠네요

  • ?
    이상한드링크 2011.08.02 12:54

    던파 같다 ㅋㅋ

  • ?
    그 누군가 2011.08.17 12:02

    ㄳ요

  • ?
    늑대고양이 2013.12.15 21:34
    줌은 필요없구요 채력 마력 경험치 알려주는 스크립트랑
    저렇개 싸우는 스크립트좀 찾아주세요 ㄷㄷ
  • ?
    불곰 2014.02.03 19:40
    무슨 말을 그렇게 하시나요.. 님한테 필요없으면 글쓰면 안되나요?
    체력마력경험치 표시 스크립트 액알 스크립트 널려있는데 님은 검색 하실줄모르시나요?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
637 기타 Gamepad Extender VX 습작 2015.01.02 672
636 버그픽스 DerVVulfman's Tileset Reader VX Bug Fix 습작 2014.11.16 701
635 아이템 현재있는 파티원 선택 레벨업 아이템 만들기 1 file 싸패 2016.06.06 713
634 메뉴 Etude87_Ace_Style_Formation_Change ver.1.01 습작 2014.10.05 758
633 저장 세이브 파일 개수 16개로 늘리기 (기본 세이브 엔진용) 1 file Bunny_Boy 2015.09.07 816
632 ??? 1 Man... 2008.10.27 1020
631 버그픽스 Graphical Object Global Reference VX by Mithran Alkaid 2014.03.03 1027
630 키입력 No F1, F12 and Alt+Return (Kein F1, F12 und Alt+Eingabe) by cremno 습작 2013.04.19 1046
629 메시지 Etude87 Dialogue History Scene file 습작 2014.07.07 1069
628 ??(다 영어)여기서 부터 드레그만 빼고 Man... 2008.10.27 1078
627 메뉴 KGC - 커스텀 메뉴 커멘드 (번역) 1 듀란테 2015.07.27 1078
626 Scene_Credit script Plug & Play 1 Man... 2008.10.27 1085
625 Multi-threader snippet by Omegazion Man... 2008.10.28 1107
624 메뉴 MOG - Scroll Bar for VX file 습작 2014.07.06 1115
623 Screen Shortcut Script Man... 2008.10.27 1142
622 LevelMe v1.2 3 Man... 2008.10.27 1154
621 Screen Resolution 3 Man... 2008.10.28 1171
620 키입력 Key Simulator by Fantasist 습작 2013.05.01 1176
619 MAX Level Limitation System 3 Man... 2008.10.28 1198
618 Simple Fon Chage 3 Man... 2008.10.28 1212
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 32 Next
/ 32