Last active
December 16, 2015 08:09
-
-
Save whity-82/5403912 to your computer and use it in GitHub Desktop.
Sample of drawing text with Gosu.
Experiment how factor_x works.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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