Skip to content

Instantly share code, notes, and snippets.

@RPGP1
RPGP1 / DXRubyのSpriteを継承して拡張する方法についてbyしのかろ.md
Created December 6, 2013 23:19
DXRubyのSpriteを継承して拡張する方法について

DXRuby Advent Calendar 2013 7日目 title: DXRubyのSpriteを継承して拡張する方法について author: しのかろ(Twitter@shinokaro)

 DXRuby Advent Calendar 2013も7日目。
 1週間目の終わりは“しのかろ”が記事をお送りします。
 世にゲーム・プログラマー多数あり、と言えども実際のコードにおいては、
文章の形で公開されることは稀です。
 ですから、今年のこのイベントで公開される記事を楽しみに毎日を過ごしています。

@RPGP1
RPGP1 / array#===.rb
Created January 26, 2014 07:32
Array#===は要素を===で判定してくれ!
class Array
def ===(other)
return false if self.size != other.size
self.each_with_index do |value, index|
return false unless value === other[index]
end
return true
end
end
@RPGP1
RPGP1 / push_keys.rb
Created March 14, 2014 10:03
Input.push_keysが欲しくなったから作った。#DXRuby キーコードが全て/^K_/だからできた。
# coding: UTF-8
require "dxruby"
module DXRuby
KeyNames = self.constants.keep_if{|c| c[0..1] == "K_"}.freeze
KeyCodes = KeyNames.dup.map{|k| self.const_get(k)}.freeze
Keys = Hash.new.tap{|h| KeyNames.each_with_index{|n, i| h[n] = KeyCodes[i]}}.freeze
end
# coding: UTF-8
require_relative '../mydxlibrary/push_keys'
class MenuBase < Sprite
attr_accessor :alp, :alp2
attr_reader :bgImage, :child, :parent
def initialize(x, y, bgImage)
super(x, y, RenderTarget.new(bgImage.width, bgImage.height))
@RPGP1
RPGP1 / ART.rb
Last active August 29, 2015 13:57
AnimationRenderTarget完成した!
#coding: UTF-8
require 'dxruby'
module DXRuby
def self.image?(v)
Image === v || RenderTarget === v
end
module Animation
@RPGP1
RPGP1 / animation.rb
Last active August 29, 2015 13:57
RenderTargetにもSpriteにもincludeして使えるAnimationモジュール
#coding: UTF-8
require 'dxruby'
###############################################################################
#How you use this is almost equal to AnimeSprite class. #
#(http://dxruby.sourceforge.jp/cgi-bin/hiki.cgi?AnimeSprite%A5%AF%A5%E9%A5%B9)#
#You only have to remenber to call not 'update' method, #
#but 'update_animation' method. #
# #
@RPGP1
RPGP1 / marshal_image.rb
Last active August 29, 2015 13:58
Image#marshal_dump/marshal_load作った。ひとまずこれで凌ぐ。
# coding: ASCII
require 'dxruby'
require 'zlib'
module DXRuby
class Image
def marshal_dump
image_data = []
for y in 0...height
@RPGP1
RPGP1 / electricpiano.rb
Created April 23, 2014 09:03
安い電子ピアノの音を作った。ProcとFiberで周波数を返すことで、倍音の合成を楽にした。
require 'dxruby'
piano = [0.419414141440249,
0.166971777138902,
0.235853904101082,
0.0470590406691173,
0.0373803247025181,
0.00373803247025181,
0.0166971777138902,
0.0419414141440249,
@RPGP1
RPGP1 / my_map_system.txt
Created May 6, 2014 04:28
マップシステム考えた。
Mapは、TileSetを一つ持つ。
自身の持つ二次元配列とTileSetから受け取る画像配列で描画する。
TileSetは、Tileをまとめる。
分割前の画像・分割方法を記憶し、Tileを生成して保持。
Tileから画像を受け取り画像配列を作る。
Tileの一部だけ画像を変更するとそれを記憶しておく。
Tileはそれぞれのtype毎にサブクラスを定義し、生成時に受け取った画像などの情報を適切に処理する。
オートタイルで実際に表示される画像(複数)を保持する。
@RPGP1
RPGP1 / DXRubyAdventCalendar2014_16.md
Last active November 1, 2015 09:00
DXRuby Advent Calendar 16日目  DXRubyでRPGを作りたくて

DXRubyでRPGを作りたくて

この記事はDXRuby Advent Calendarの16日目の記事です。昨日はmirichiさんのDXRubyの怪しげで不自然な挙動について語るでした。DirectXをCで直接叩いているそうで、かなり大変そうですね。しかし全て把握しているのもまた、凄いと思います。

# coding: Introduction

どうも、GameKazuです。DXRubyという使いやすいライブラリを使って、RPGという最も複雑なゲームの1つを作ろうとしている学生です。プログラミング歴は3年と少し、RubyとDXRubyは2年と少しなので、今回の参加者の中でも短い方だと思います。