Skip to content

Instantly share code, notes, and snippets.

View myokoym's full-sized avatar
💭
hi

Masafumi Yokoyama myokoym

💭
hi
View GitHub Profile
@myokoym
myokoym / homography_params.rb
Last active August 29, 2015 14:01
Rubyで射影変換(ホモグラフィ)のパラメーターを求めてみた。8元一次連立方程式を行列(Ruby標準添付のMatrixライブラリ)を使って解くやり方。
require "matrix"
# 変換前後の座標から射影変換のパラメーターを求める
# x11-x14: 変換前のX座標(左上から時計回り)
# y11-y14: 変換前のY座標
# x21-x24: 変換後のX座標
# y21-y24: 変換後のY座標
def homography_params(x11, y11, x12, y12,
x13, y13, x14, y14,
x21, y21, x22, y22,
@myokoym
myokoym / input_name.rb
Last active November 8, 2017 11:10
Gosuによる名前入力のサンプル(英字3文字)
require "gosu"
module InputName
module ZOrder
Background, Text, Cursor = *0..2
end
class Window < Gosu::Window
def initialize(width=240, height=160)
super(width, height, false)
@myokoym
myokoym / firehats.rb
Last active August 29, 2015 14:01
A shooting game. Using Gosu (http://www.libgosu.org/) and Ruby (https://www.ruby-lang.org/).
begin
require "gosu"
rescue LoadError
$stderr.puts(<<-END_OF_MESSAGE)
LoadError: #{$!.message}. Please try `gem install gosu`.
If you are using Linux, please see https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux
END_OF_MESSAGE
exit(false)
end
require "gosu"
module CatchHats
module ZOrder
Background, Object, Text = *0..2
end
class Player
attr_reader :x, :y
@myokoym
myokoym / create-pieces.rb
Last active August 29, 2015 14:00
将棋駒生成スクリプト
# -*- coding: utf-8 -*-
require "shogi_koma"
PIECES = [
["歩兵", "FU"],
["香車", "KY"],
["桂馬", "KE"],
["銀将", "GI"],
["金将", "KI"],
@myokoym
myokoym / game-of-life.rb
Last active August 29, 2015 14:00
A Conway's Game of Life. Using Gosu (http://www.libgosu.org/) and Ruby (https://www.ruby-lang.org/).
require "gosu/zen"
include Gosu::Zen
# patch
module Gosu
module Zen
def init(&body)
ZenWindow.send(:define_method, :init, &body)
end
end
@myokoym
myokoym / gosu_image_viewer.rb
Last active August 29, 2015 14:00
Image Viewer using Gosu and Ruby
require "gosu"
module GosuImageViewer
class Window < Gosu::Window
def initialize(width=640, height=480)
super(width, height, false)
self.caption = "Image Viewer using Gosu"
@images = []
@scale = 1.0
@angle = 0
@myokoym
myokoym / rbshogi.rb
Last active August 29, 2015 13:59
A Shogi board using Gosu and Ruby. (under construction...)
require "gosu"
require "shogi"
require "socket"
module RbShogi
PIECES = [
"FU", "TO",
"KY", "NY",
"KE", "NK",
"GI", "NG",
@myokoym
myokoym / bricks_meet_balls-gtk.rb
Last active August 29, 2015 13:59
A game launcher by Ruby/GTK3.
require "gtk3"
require "bricks_meet_balls"
class GameButton < Gtk::Button
PROPERTIES = [
"num_of_rows",
"num_of_columns",
"num_of_balls",
"ball_images",
"brick_images",
@myokoym
myokoym / space_invaders.rb
Last active April 6, 2017 23:45
A game as Space Invaders using Gosu and Ruby. (under construction...)
#
# space_invaders.rb:
# A game as Space Invaders using Gosu and Ruby.
#
# Authors:
# (c) 2014 Masafumi Yokoyama
#
# License:
# This program is licensed under the MIT License.
#