RPGXP スクリプト
2013.09.27 02:21

FPS 표시 스크립트

閲覧数 1393 推奨数 0 コメント 7
?

Shortcut

Prev前へ 書き込み

Next次へ 書き込み

Larger Font Smaller Font 上へ 下へ Go comment 印刷 修正 削除
?

Shortcut

Prev前へ 書き込み

Next次へ 書き込み

Larger Font Smaller Font 上へ 下へ Go comment 印刷 修正 削除


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
番号 カテゴリ タイトル 投稿者 日付 閲覧数 推奨数
288 RPG MVプラグイン Mog_Battle_hud(MZ버전도 있습니다) 스트레이보우 2021.03.05 2011 0
287 RPG MVプラグイン 컷신 플러그인 스트레이보우 2020.10.30 2694 0
286 RPG MVプラグイン 업적플러그인 스트레이보우 2020.09.02 2262 0
285 RPGXP スクリプト 한글조합입력기(영어가능) file 조규진1 2019.11.10 1201 0
284 RPG MVプラグイン 게임에서 제공해주는 노래가 아닌 외부에서 다운받고 안에 넣어쓰려면 어떻게 해야하나요? 3 BigOrca 2019.07.26 1650 0
283 RPG MVプラグイン Ghost Effect 러닝은빛 2019.01.20 1323 0
282 RPGXP スクリプト RPG XP Xas액알 1 file 심심치 2018.10.30 1331 0
281 RPG MVプラグイン 커스텀 숫자 입력 패드 1 file 러닝은빛 2018.10.19 1399 0
280 RPG MVプラグイン 9마리 이상의 몬스터 설정 | More Enemies 러닝은빛 2018.08.31 1150 0
279 RPG MVプラグイン 동적 맵 타일 수정 플러그인 베지테리안카카오 2018.07.17 1251 0
278 RPG VX Ace スクリプト VXA에서 XBOX360 컨트롤러 사용 여부 체크 file 러닝은빛 2018.07.15 1053 0
277 RPG MVプラグイン RMMV 옵션 창에 메시지 속도 및 글자 크기 변경 기능 추가 file 러닝은빛 2018.07.15 1795 0
276 RPG MVプラグイン 한글 데미지 표시 file 러닝은빛 2018.07.09 1613 0
275 RPG MVプラグイン [ MV ] 심장[체력표시 하트] 플러그인 file 수성의물 2018.07.01 2407 0
274 RPG MVプラグイン [鳥小屋] 실적 플러그인(인게임 트로피 시스템) file 이니군 2017.10.31 1909 0
273 RPG VX Ace スクリプト LuD Script Package 1 file LuD 2017.08.16 1822 0
272 RPG VX Ace スクリプト [VXAce] 레이어 맵 <layer> 시스템 file LuD 2017.08.07 1478 0
271 RPG MVプラグイン [RPG MV] 퀘스트 마커 지속 표시 플러그인 file lklslel 2017.04.09 1875 0
270 RPG MVプラグイン Mirror Area - RPG Maker MV 2 file 러닝은빛 2017.01.03 5181 0
269 RPG MVプラグイン Keyboard Event - RPG Maker MV 1 러닝은빛 2017.01.03 2456 0
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 15 Next
/ 15