| 1 | #!/usr/bin/env ruby
|
|---|
| 2 | # fontsはStarRuby同梱のものを使用してください
|
|---|
| 3 |
|
|---|
| 4 | $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
|
|---|
| 5 |
|
|---|
| 6 | require "starruby"
|
|---|
| 7 | require "starframe"
|
|---|
| 8 | include StarRuby
|
|---|
| 9 |
|
|---|
| 10 | class MainScene < StarFrame::Scene
|
|---|
| 11 | def init
|
|---|
| 12 | # @fps = 30 # 処理レート
|
|---|
| 13 | # @frame_skip = false # フレームスキップするかどうか
|
|---|
| 14 |
|
|---|
| 15 | @font = Font.new("fonts/ORANGEKI", 24)
|
|---|
| 16 | @white = Color.new(255, 255, 255)
|
|---|
| 17 |
|
|---|
| 18 | @counter = 0
|
|---|
| 19 | end
|
|---|
| 20 |
|
|---|
| 21 | update do
|
|---|
| 22 | exit_scene if Input.keys(:keyboard).include?(:escape)
|
|---|
| 23 | @counter += 1
|
|---|
| 24 |
|
|---|
| 25 | # sleep 0.2 # 処理が重い! # フレームスキップがオンだと固まる
|
|---|
| 26 | end
|
|---|
| 27 |
|
|---|
| 28 | def render
|
|---|
| 29 | i = -1
|
|---|
| 30 | @screen.render_text("FPS: #{@game.fps}", 8, 8 + 32 * (i += 1), @font, @white)
|
|---|
| 31 | @screen.render_text("Real FPS: %0.6f" % @game.real_fps, 8, 8 + 32 * (i += 1), @font, @white)
|
|---|
| 32 | @screen.render_text("Frames: #{@counter}", 8, 8 + 32 * (i += 1), @font, @white)
|
|---|
| 33 | @screen.render_text("Ticks: #{Game.ticks}", 8, 8 + 32 * (i += 1), @font, @white)
|
|---|
| 34 | # sleep 0.2 # 描画が重い!
|
|---|
| 35 | end
|
|---|
| 36 | end
|
|---|
| 37 |
|
|---|
| 38 | StarFrame.start :width => 320, :height => 240,
|
|---|
| 39 | :title => "Timer (with StarFrame::Scene)", :fullscreen => false
|
|---|