RPGXP 스크립트
2013.09.27 02:21

FPS 표시 스크립트

조회 수 1166 추천 수 0 댓글 7
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 수정 삭제
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 수정 삭제


Graphics.frame_rate = 60
class FPS_Display
 
  #===CONFIGURATION===#
    TOGGLE = Input::F5
  #=END CONFIGURATION=#
 
  attr_accessor :frame_count
 
        def initialize
   
                # Create Sprite to display FPS
                @counter = Sprite.new
   
                # Position Sprite
                @counter.x, @counter.z = 500, 99999999
   
                # Create / Setup Bitmap
                @counter.bitmap = Bitmap.new(200, 24)
                #@counter.bitmap.fill_rect(0, 0, 200, 24, Color.new(0, 0, 0))
                @counter.bitmap.font.size = 15
                @counter.bitmap.font.name = '나눔고딕'
                @counter.bitmap.font.bold = true
                #@counter.bitmap.draw_text(100, 0, 100, 24, ' fps')
   
                # Get Target Frame Rate
                @frame_rate = Graphics.frame_rate
   
                # Set Start time
                @start = nil
                @on = true
                @frame_count = 0
                @fps = @frame_rate
                refresh
   
        end
       
        def refresh
   
                # Clear FPS
                #@counter.bitmap.fill_rect(0, 0, 100, 24, Color.new(0,0,0))
                @counter.bitmap.clear
                # Redraw Current FPS
                @counter.bitmap.font.color = Color.new(0,0,0,120)
                @counter.bitmap.draw_text(100-1, 0, 100, 24, ' fps')
                @counter.bitmap.draw_text(100-1, -1, 100, 24, ' fps')
                @counter.bitmap.draw_text(100-1, +1, 100, 24, ' fps')
                @counter.bitmap.draw_text(100+1, -1, 100, 24, ' fps')
                @counter.bitmap.draw_text(100+1, 1, 100, 24, ' fps')
                @counter.bitmap.draw_text(100+1, 0, 100, 24, ' fps')
                @counter.bitmap.draw_text(100, 1, 100, 24, ' fps')
                @counter.bitmap.draw_text(100, -1, 100, 24, ' fps')
                @counter.bitmap.draw_text(-1, 0, 100, 24, @fps.to_s ,2)
                @counter.bitmap.draw_text(1, 0, 100, 24, @fps.to_s ,2)
                @counter.bitmap.draw_text(0, 1, 100, 24, @fps.to_s ,2)
                @counter.bitmap.draw_text(1, -1, 100, 24, @fps.to_s ,2)
                @counter.bitmap.draw_text(1, -1, 100, 24, @fps.to_s ,2)
                @counter.bitmap.draw_text(1, 1, 100, 24, @fps.to_s ,2)
                @counter.bitmap.draw_text(-1, -1, 100, 24, @fps.to_s ,2)
                @counter.bitmap.draw_text(-1, 1, 100, 24, @fps.to_s ,2)
                @counter.bitmap.font.color = Color.new(255,255,255)
                 @counter.bitmap.draw_text(100, 0, 100, 24, ' fps')
                @counter.bitmap.draw_text(0, 0, 100, 24, @fps.to_s ,2)#+ " / " +
                      #@frame_rate.to_s, 2)
   
        end
               
        def update
   
                # If F5 is pressed, toggle FPS display
                if Input.trigger?(TOGGLE)
                        @on = !@on
                        @counter.visible = @on
                end
   
               (@frame_count = 0; return) if !@on
               if @start == nil
                 @start = Time.now
                 @frame_count = 0
               end
               # Get time elapsed in seconds
               cur_time = Time.now - @start
   
               if cur_time >= 1
               # Get Frames per second
               fps = (@frame_count / cur_time).to_i
   
               # If during check interval and the Frame Rate has changed
               if @fps != fps
                  @fps = fps
                  refresh
                end
                @start = nil
        end
   
        end
       
        def dispose
   
                @counter.dispose; @counter = nil
   
        end
 
end

module Graphics
 
  class << self
   
    alias :new_upd_fps :update unless method_defined?(:new_upd_fps)
   
  end
 
  def self.update
   
    self.new_upd_fps
    $fps = FPS_Display.new if $fps == nil
    #return if $fps == nil
   
    $fps.frame_count += 1
    $fps.update
   
  end
 
end

?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수 추천 수
128 RPGMV 플러그인 윈도우 시스템 트레이로 최소화 2 file 러닝은빛 2016.01.21 2028 0
127 RPGMV 플러그인 커스텀 숫자 입력 패드 1 file 러닝은빛 2018.10.19 1016 0
126 RPGVX Ace 스크립트 LuD Script Package 1 file LuD 2017.08.16 1468 0
125 RPGMV 플러그인 YouTube Player 6 file 러닝은빛 2016.05.08 1477 0
124 RPGMV 플러그인 [plugin] YEP.58 – Item Synthesis (YEP엔진 아이템 합성 시스템) 2 plam 2016.01.21 2371 0
123 RPGXP 스크립트 대화에 얼굴이 나오는 스크립트 by: killarot(네이버 dust_mite)(수정버전) 1 부초 2016.02.22 1895 0
122 유니티 스크립트 화면에 이미지를 표시하는 스크립트(C#) 1 zerosium 2016.02.04 2370 0
121 RPGMV 플러그인 한글 이름 입력창 2.1v 2 file 맛난호빵 2016.02.12 2394 0
120 RPGVX Ace 스크립트 지속데미지 스크립트(MBS) 天下太平 2016.02.14 1516 0
119 RPGMV 플러그인 Item Stream 2 file 러닝은빛 2016.03.08 3196 0
118 RPGVX Ace 스크립트 VX Ace 용 8방향 이동 스크립트 1 도라지power 2016.03.17 1654 0
117 RPGMV 플러그인 맵상에서 캐릭터 스프라이트 이미지를 offset해주는 플러그인 file lklslel 2016.07.19 1071 0
116 RPGXP 스크립트 Font Setup file 운님 2016.07.22 1447 0
115 RPGMV 플러그인 화면 다중 분할 플러그인(Multiple Viewports) 러닝은빛 2016.08.25 1175 0
114 RPGMV 플러그인 CSS 캔버스 필터 file 러닝은빛 2016.10.06 912 0
113 RPGMV 플러그인 Keyboard Event - RPG Maker MV 1 러닝은빛 2017.01.03 2075 0
112 RPGMV 플러그인 Mirror Area - RPG Maker MV 2 file 러닝은빛 2017.01.03 4740 0
111 RPGMV 플러그인 [RPG MV] 퀘스트 마커 지속 표시 플러그인 file lklslel 2017.04.09 1411 0
110 RPGVX Ace 스크립트 [VXAce] 레이어 맵 <layer> 시스템 file LuD 2017.08.07 1042 0
109 RPGMV 플러그인 [鳥小屋] 실적 플러그인(인게임 트로피 시스템) file 이니군 2017.10.31 1548 0
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 ... 15 Next
/ 15






[개인정보취급방침] | [이용약관] | [제휴문의] | [후원창구] | [인디사이드연혁]

Copyright © 1999 - 2016 INdiSide.com/(주)씨엘쓰리디 All Rights Reserved.
인디사이드 운영자 : 천무(이지선) | kernys(김원배) | 사신지(김병국)