Skip to content

Instantly share code, notes, and snippets.

@whity-82
Last active December 16, 2015 08:09
Show Gist options
  • Save whity-82/5403912 to your computer and use it in GitHub Desktop.
Save whity-82/5403912 to your computer and use it in GitHub Desktop.
Sample of drawing text with Gosu. Experiment how factor_x works.
require 'gosu'
class GameWindow < Gosu::Window
# 1行の高さ(=フォントサイズ)
LINE_HEIGHT =20
# ウィンドウの高さ(行数)
LINES_IN_WINDOW = 24
def initialize
super(640, LINE_HEIGHT * LINES_IN_WINDOW, false)
self.caption = "Gosu Tutorial Game"
@font = Gosu::Font.new(self, Gosu::default_font_name, 20)
end
def update
end
def draw
# ウィンドウの高さ分、factor_xを変えながら埋め尽くしてみる。
LINES_IN_WINDOW.times do |i|
factor_x = i.to_f / 10
@font.draw( factor_x.to_s + ":Hello World!", 0, LINE_HEIGHT * i, 1, factor_x, 1.0, Gosu::Color::WHITE)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment