#coding:utf-8
require "dxruby"
# ----------------------------- array rot lib --------------------------------
def array_rot45 vv
vv.transpose .each_with_index .map do | m , i |
[ nil ] * i + m + [ nil ] * ( ( vv.size - 1 ) - i)
end .transpose .map ( & :compact)
end
def array_rot45_decode a
z = a.map ( & :size) .max
a.each_with_index .inject ( z.times .map do [ ] end ) do | c , ( m , i ) |
z.times .each_with_object c do | k |
if ( k...( z+ k) ) === i
if c[ k] .size != z
c[ k] .push m.pop
end
end
end
end
end
def array_rot_print v
v.map ( & :to_s) .each do | m |
puts m.rjust ( m.size / 2 + v.size + 5 )
end
end
def array_rot n , v
case n
when 0 , 360
v
when 90
v.transpose .map ( & :reverse)
when 180
v.map ( & :reverse) .reverse
when 270
v.map ( & :reverse) .transpose
when 45
array_rot45 v
when 135
array_rot45 v.reverse .transpose
when 225
array_rot45 v.map ( & :reverse) .reverse
when 315
array_rot45 v.map ( & :reverse) .transpose
else
p "err"
end
end
def array_rot_decode n , v
case n
when 0 , 360
v
when 90
v.map ( & :reverse) .transpose
when 180
v.map ( & :reverse) .reverse
when 270
v.transpose .map ( & :reverse)
when 45
array_rot45_decode v
when 135
array_rot45_decode( v.reverse ) .map ( & :reverse)
when 225
array_rot45_decode v.map ( & :reverse) .reverse
when 315
array_rot45_decode( v) .transpose .map ( & :reverse)
else
p "err"
end
end
# ---------------------------------------------------------------------
def recthit x1 , y1 , w1 , h1 , x2 , y2 , w2 , h2
x1 + w1 > x2 && x1 < x2 + w2 && y1 + h1 > y2 && y1 < y2 + h2 ; end
def f mm , x , y , n
return mm if mm[ x] [ y] != "0"
def miko_neko mm , x , y , n
miko_neko_sub n do | r |
tmp = mm[ x] [ y]
mm[ x] [ y] = "5"
mm[ x] .sub! ( r ) { "#{n}" * $1.size }
mm[ x] .sub! ( "5" ,tmp)
mm
end
mm
end
def miko_neko_sub n
[ / ( #{n}#{3^n}+5)/ , /(5#{3^n}+#{n})/ ].each do | r |
yield r
end
end
def transpose2 a ; a.replace a.map ( & :chars) .map ( & :to_a) .transpose .map ( & :join) ; end
miko_neko mm , x , y , n
transpose2 miko_neko transpose2( mm) , y , x , n
#------------------naname----------------------
def array_to_chars mm
mm.map ( & :chars) .map ( & :to_a)
end
def miko_array mm , x , y , n , ang , v
miko_neko_sub n do | r |
tmp = mm[ x] [ y]
mm[ x] [ y] = "5"
a = array_rot ang , array_to_chars( mm )
a.map !( & :join)
a[ v] .sub! ( r ) { "#{n}" * $1.size }
a[ v] .sub! ( "5" ,tmp)
mm.replace array_rot_decode( ang , array_to_chars( a) ) .map !( & :join)
end
end
miko_array mm , x , y , n , 45 , x + y
miko_array mm , x , y , n , 315 , x + 7 - y
end
font = Font.new 20
size = 30
mm = [ "00000000" , "00000000" , "00000000" , "00021000" , "00012000" , "00000000" , "00000000" , "00000000" ,]
Window.loop do
exit if Input.keyPush ? K_F9
64 .times do | i | ( k=i/ 8 ) ; ( u=i% 8)
Window.drawFont k* size , u* size , % w!□ ○ ●![ mm[ k] [ u] .to_i ] , font , { color: [ 170 ,140 ,160 ] }
if recthit( k* size , u* size , font.getWidth ( "□" ) , font.size , Input.mousePosX ,Input.mousePosY ,1 ,1 )
f mm , k , u , 2 if Input.mousePush ?( M_LBUTTON)
f mm , k , u , 1 if Input.mousePush ?( M_RBUTTON)
end
end
end
I2NvZGluZzp1dGYtOApyZXF1aXJlICJkeHJ1YnkiCgojIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tIGFycmF5ICByb3QgIGxpYiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQoKZGVmIGFycmF5X3JvdDQ1IHZ2CiAgdnYudHJhbnNwb3NlLmVhY2hfd2l0aF9pbmRleC5tYXAgZG8gfCBtICwgaSB8CiAgICBbbmlsXSppICsgbSArIFtuaWxdKigodnYuc2l6ZS0xKSAtIGkpCiAgZW5kLnRyYW5zcG9zZS5tYXAoJjpjb21wYWN0KQplbmQKCmRlZiBhcnJheV9yb3Q0NV9kZWNvZGUgYQogIHog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