SHARE
TWEET

Three Box Class Program

a guest Dec 5th, 2014 3 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! ruby -Ku
  2.  
  3. #3通り継承クラスプログラム
  4. #作者 mireiyu
  5. require "kconv"
  6. require_relative "dxruby"
  7.  
  8. class Any_box
  9.   def initialize(dx,dy,argb,sx,sy)
  10.  
  11.    @dx = dx
  12.    @dy = dy
  13.    @argb = argb
  14.    @sx = sx
  15.    @sy = sy
  16.  
  17.    @box_default_image = Image.new(@dx,@dy,[@argb[0],@argb[1],@argb[2],@argb[3]]).draw_font_ex(0,0,"1",$font,{color:[255,0,0,0]})
  18.    @box_default_sprite = Sprite.new(@sx,@sy,@box_default_image)
  19.   end
  20.   def sprite_action
  21.    
  22.   end
  23.   def sprite_render
  24.    @box_default_sprite.draw
  25.    @box_default_sprite.update
  26.   end
  27. end
  28.  
  29. class Color_box < Any_box
  30.   def initialize(dx,dy,argb,sx,sy)
  31.    super
  32.    @argb = argb
  33.    @sx = sx
  34.    @sy = sy
  35.  
  36.    @box_default_image = Image.new(@dx,@dy,[@argb[0],@argb[1],@argb[2],@argb[3]]).draw_font_ex(0,0,"2",$font,{color:[255,0,0,0]})
  37.    @box_default_sprite = Sprite.new(@sx,@sy,@box_default_image)
  38.   end
  39.   def sprite_action
  40.    
  41.   end
  42.   def sprite_render
  43.    @box_default_sprite.draw
  44.    @box_default_sprite.update
  45.   end
  46. end
  47.  
  48. class Size_color_box < Color_box
  49.   def initialize(dx,dy,argb,sx,sy)
  50.    super
  51.    @argb = argb
  52.    @sx = sx
  53.    @sy = sy
  54.  
  55.    @box_default_image = Image.new(@dx,@dy,[@argb[0],@argb[1],@argb[2],@argb[3]]).draw_font_ex(0,0,"3",$font,{color:[255,0,0,0]})
  56.    @box_default_sprite = Sprite.new(@sx,@sy,@box_default_image)  end
  57.   def sprite_action
  58.    
  59.   end
  60.   def sprite_render
  61.    @box_default_sprite.draw
  62.    @box_default_sprite.update
  63.   end
  64. end
  65.  
  66. module Main
  67. #全般定義
  68.   $font = Font.new(20, 'HGP行書体')
  69.   @pointar = 0
  70.   @pointar_argb = 0
  71. #数値初期定義=>
  72.   @@dx_ary    = [20,20,20]
  73.   @@dy_ary    = [20,20,20]
  74.   @@argb_ary  = [[255,255,255,255],[255,255,255,255],[255,255,255,255]]
  75.   @@sx_ary    = [20,20,20]
  76.   @@sy_ary    = [20,20,20]
  77. #<=定義
  78.   3.times do |i|
  79.    dx    = @@dx_ary[i]
  80.    dy    = @@dy_ary[i]
  81.    argb  = @@argb_ary[i]
  82.    sx    = @@sx_ary[i]
  83.    sy    = @@sy_ary[i]
  84.    @@any_box = Any_box.new(dx,dy,argb,sx,sy) if i == 0
  85.    @@color_box = Color_box.new(dx,dy,argb,sx,sy) if i == 1
  86.    @@size_color_box = Size_color_box.new(dx,dy,argb,sx,sy) if i == 2
  87.   end
  88.  
  89.   Window.loop do
  90. #動作
  91.    @@any_box.sprite_action
  92.    @@any_box.sprite_render
  93.    @@color_box.sprite_action
  94.    @@color_box.sprite_render
  95.    @@size_color_box.sprite_action
  96.    @@size_color_box.sprite_render
  97. #コントローラー
  98.    @pointar = 0 if Input.keyPush?(K_1)
  99.    @pointar = 1 if Input.keyPush?(K_2)
  100.    @pointar = 2 if Input.keyPush?(K_3)
  101.    @pointar_argb = 0 if Input.keyPush?(K_4)
  102.    @pointar_argb = 1 if Input.keyPush?(K_5)
  103.    @pointar_argb = 2 if Input.keyPush?(K_6)
  104.    @pointar_argb = 3 if Input.keyPush?(K_7)
  105.    @@dx_ary[@pointar]       += 20 if Input.keyPush?(K_L) and @@dx_ary[@pointar] < 200
  106.    @@dy_ary[@pointar]       += 20 if Input.keyPush?(K_K) and @@dy_ary[@pointar] < 200
  107.    @@argb_ary[@pointar][@pointar_argb]  += 15 if Input.keyPush?(K_A) and @@argb_ary[@pointar][@pointar_argb] < 255
  108.    @@sx_ary[@pointar]       += 20 if Input.keyPush?(K_RIGHT) and @@sx_ary[@pointar] < 620
  109.    @@sy_ary[@pointar]       += 20 if Input.keyPush?(K_DOWN) and @@sy_ary[@pointar] < 460
  110.    @@dx_ary[@pointar]       -= 20 if Input.keyPush?(K_J) and @@dx_ary[@pointar] > 0
  111.    @@dy_ary[@pointar]       -= 20 if Input.keyPush?(K_I) and @@dy_ary[@pointar] > 0
  112.    @@argb_ary[@pointar][@pointar_argb]  -= 15 if Input.keyPush?(K_S) and @@argb_ary[@pointar][@pointar_argb] > 0
  113.    @@sx_ary[@pointar]       -= 20 if Input.keyPush?(K_LEFT) and @@sx_ary[@pointar] > 0
  114.    @@sy_ary[@pointar]       -= 20 if Input.keyPush?(K_UP) and @@sy_ary[@pointar] > 0
  115.  
  116. #<=再定義
  117.    if Input.keyPush?(K_SPACE)
  118.     3.times do |i|
  119.      dx    = @@dx_ary[i]  
  120.      dy    = @@dy_ary[i]  
  121.      argb  = @@argb_ary[i]
  122.      sx    = @@sx_ary[i]  
  123.      sy    = @@sy_ary[i]  
  124.      @@any_box = Any_box.new(dx,dy,argb,sx,sy) if i == 0
  125.      @@color_box = Color_box.new(dx,dy,argb,sx,sy) if i == 1
  126.      @@size_color_box = Size_color_box.new(dx,dy,argb,sx,sy) if i == 2
  127.     end
  128.    end
  129. #値表示
  130.    info_y = 30
  131.    3.times do |o|
  132.     Window.draw_font(0,480-90 + 30 * o , @@dx_ary[o].to_s + ":" + @@dy_ary[o].to_s + ":" + @@sx_ary[o].to_s + ":" + @@sy_ary[o].to_s + ":" + @@argb_ary[o].to_s + ":",$font)
  133.    end
  134.    Window.draw_font(0,360,"Pontar/ArgbPointar=" + @pointar.to_s + ":" + @pointar_argb.to_s + ":",$font)
  135.    Window.draw_font(640-140,460,"Z To Help",$font)
  136.    Window.draw_font(0,200,"123:target box,4567:target argb,↑↓←→:move box\nKLIJ:change box size,AS:tweak color\nspace:reinit",$font,{color:[255,255,66,66]}) if Input.keyDown?(K_Z)
  137.   end
  138. end
RAW Paste Data
Top