查看: 4919|回复: 4

[新手游戏] 双人五子棋小游戏

[复制链接]
梦石
0
星屑
1944
在线时间
404 小时
注册时间
2015-8-30
回帖
322
发表于 2017-1-29 17:00:01 | 显示全部楼层 |阅读模式
游戏发布
游戏类型:其他
版本信息:1.0
制作工具:RPG Maker VX Ace
游戏时长:0.01 小时
下载地址:

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 有丘直方 于 2017-1-31 12:21 编辑

本来想附件售价3经验的……后来想想还是弄三个,第一个是纯文本的,免费;第二个是Scripts.rvdata2,售价1经验;第三个是完整的、带RGSS300.dll的发行包,售价2经验。
第一个(内容较多)请新建一个工程,游戏名定为《五子棋》,然后删除MAP001,再打开脚本编辑器,删除所有预置脚本,再把以下脚本放进脚本编辑器。
这些脚本中包含了Sion的鼠标系统的核心脚本,但没有包含其他内容,所以不算侵权之类的吧。为尊重原作者,不需要的内容并没有直接删去,而是Ctrl+Q注释掉了;自己增添的内容用“#↓-----↓”和“#↑-----↑”标示出来了
  1. # 白菜组基础脚本 WhiteCabbageBase)v1.02 (2013/11/16)
  2. #
  3. module APIs
  4. def self.new(ts); Win32API.new(*ts.split('|')) end
  5. #-------------------------------------------------
  6. ClipCursor          = new 'user32|ClipCursor|p|l'
  7. FindWindowEx        = new 'user32|FindWindowEx|llpp|i'
  8. GetAsyncKeyState    = new 'user32|GetAsyncKeyState|i|i'
  9. GetCursorPos        = new 'user32|GetCursorPos|p|i'
  10. GetKeyState         = new 'user32|GetKeyState|i|i'
  11. GetPrvPflString     = new 'kernel32|GetPrivateProfileString|pppplp|l'
  12. GetSysMtr           = new 'user32|GetSystemMetrics|i|i'
  13. JoyGetPosEx         = new 'winmm|joyGetPosEx|lp|l'
  14. KeybdEvent          = new 'user32|keybd_event|iill|v'
  15. MultiByteToWideChar = new 'kernel32|MultiByteToWideChar|ilpipi|i'
  16. WideCharToMultiByte = new 'kernel32|WideCharToMultiByte|ilpipipp|i'
  17. RtlMoveMemory_pi    = new 'kernel32|RtlMoveMemory|pii|i'
  18. RtlMoveMemory_ip    = new 'kernel32|RtlMoveMemory|ipi|i'
  19. ScreenToClient      = new 'user32|ScreenToClient|ip|i'
  20. SetCursorPos        = new 'user32|SetCursorPos|ii|l'
  21. SetFocus            = new 'user32|SetFocus|l|l'
  22. SetKeyBoardState    = new 'user32|SetKeyboardState|i|i'
  23. SetWindowPos        = new 'user32|SetWindowPos|liiiiip|i'
  24. ShellExecuteA       = new 'shell32|ShellExecuteA|pppppi|i'
  25. ShowCursor          = new 'user32|ShowCursor|i|l'
  26. #-----------------------------------------------
  27. HWnd = FindWindowEx.call(0, 0, 'RGSS Player', 0)
  28. end
  29. # §
  30. # Base Class~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. class NilClass
  32.   def +(v) return v end
  33.   def -(v) return -v end
  34.   def *(v) return 0 end
  35.   def /(v) return 0 end
  36. end
  37. class Numeric
  38.   def fpart; self - self.to_i end #获取小数部分
  39.   def rfpart; 1 - fpart end # 1 - 小数部分
  40.   def max(v); self > v ? self : v end # 取最大值
  41.   def min(v); self < v ? self : v end # 取最小值
  42.   def tide(r); self * (rand-0.5)*2 * r end #进行权值波动 ± v * (-r ~ r)
  43.   def digits(ary=10) # 获取对应进制下的数字位数 2/8/10/16 进制
  44.     dig = 0; num = self.abs.to_i; if ary == 10; until num == 0; dig += 1
  45.     num /= ary; end; else ary = case ary; when 2;1; when 8;3; when 16;4 end
  46.     until num == 0; dig += 1; num = num >> ary end; end; return dig
  47.   end
  48. end
  49. class Array
  50.   def iswap(a, b)
  51.     t_ = self[a]
  52.     self[a] = self[b]
  53.     self[b] = t_
  54.   end
  55. end
  56. class Hash
  57.   def iswap(a, b)
  58.     t_ = self[a]
  59.     self[a] = self[b]
  60.     self[b] = t_
  61.   end
  62.   def key_sort(rev = false)
  63.     a = []; h = {}
  64.     self.each {|k, v| a.push([v, k])}
  65.     a.sort!
  66.     rev ? a.reverse_each {|vk| h[vk[1]] = vk[0]} :
  67.       a.each {|vk| h[vk[1]] = vk[0]}
  68.     return h
  69.   end
  70. end
  71. # ~~~~~~~~~~~~~~~~~~~~~
  72. # =====================
  73. class Font
  74.   def marshal_dump;        end
  75.   def marshal_load(*args); end
  76. end
  77. # =====================
  78. class Bitmap
  79. include APIs
  80.   #Bitmap marshal. by 柳之一(rpg.blue)
  81.   # --------------------------------------
  82.   def _dump(limit)
  83.     data = bit_4 * width * height
  84.     RtlMoveMemory_pi.call(data, address, data.length)
  85.     [width, height, Zlib::Deflate.deflate(data)].pack("LLa*")
  86.   end
  87.   def self._load(str)
  88.     w, h, zdata = str.unpack("LLa*"); buf = new(w, h)
  89.     RtlMoveMemory_ip.call(buf.address, Zlib::Inflate.inflate(zdata), w*h*4)
  90.     return buf
  91.   end
  92.   def address
  93.     buf = bit_4
  94.     ad = object_id * 2 + 16
  95.     RtlMoveMemory_pi.call(buf, ad, 4)
  96.     ad = buf.unpack("L")[0] + 8
  97.     RtlMoveMemory_pi.call(buf, ad, 4)
  98.     ad = buf.unpack("L")[0] + 16
  99.     RtlMoveMemory_pi.call(buf, ad, 4)
  100.     buf.unpack("L")[0]
  101.   end
  102.   def bit_4
  103.     'ccav'
  104.   end
  105.   # --------------------------------------
  106.   # 绘制直线
  107.   def blt_wu_line(x1, y1, x2, y2, r,g,b,a=255) # 抗锯齿
  108.     dx = x2 - x1
  109.     dy = y2 - y1
  110.     if dx.abs < dy.abs
  111.       t_ = x1; x1 = y1; y1 = t_
  112.       t_ = x2; x2 = y2; y2 = t_
  113.       t_ = dx; dx = dy; dy = t_
  114.     end
  115.     if x2 < x1
  116.       t_ = x1; x1 = x2; x2 = t_
  117.       t_ = y1; y1 = y2; y2 = t_
  118.     end
  119.     set_pixel(x1, y1, Color.new(r,g,b,a))
  120.     set_pixel(x2, y2, Color.new(r,g,b,a))
  121.     gradient = dy.fdiv(dx)
  122.     intery = y1 + gradient
  123.     for x in (x1 + 1)..(x2 - 1)
  124.       y1 = intery.to_i
  125.       y2 = intery.ceil
  126.       set_pixel(x, y1, Color.new(r,g,b, intery.rfpart * a))
  127.       set_pixel(x, y2, Color.new(r,g,b, intery.fpart * a)) if y1 != y2
  128.       intery = intery + gradient
  129.     end
  130.   end
  131.   def blt_line(x0, y0, x1, y1, r,g,b,a=255) # 不抗锯
  132.     c = Color.new(r,g,b,a)
  133.     steep = (y1 - y0).abs > (x1 - x0).abs
  134.     if steep
  135.       t_ = x0; x0 = y0; y0 = t_
  136.       t_ = x1; x1 = y1; y1 = t_
  137.     end
  138.     if x0 > x1
  139.       t_ = x0; x0 = x1; x1 = t_
  140.       t_ = y0; y0 = y1; y1 = t_
  141.     end
  142.     deltax = x1 - x0
  143.     deltay = (y1 - y0).abs
  144.     error  = deltax / 2
  145.     y = y0
  146.     ystep = y0 < y1 ? 1 : -1
  147.     for x in x0..x1
  148.       steep ? set_pixel(y,x,c) : set_pixel(x,y,c)
  149.       error = error - deltay
  150.       if error < 0
  151.         y = y + ystep
  152.         error = error + deltax
  153.       end
  154.     end
  155.   end
  156.   # 描边 -----------------------------
  157.   def blt_border(w = 1, d = 0, color = Color.new(255, 255, 255))
  158.     fill_rect(d, d, width - d*2, w, color)
  159.     fill_rect(d, height - d - w, width - d*2, w, color)
  160.     fill_rect(d, d, w, height - d*2 - w, color)
  161.     fill_rect(width - d - w, d*2, w, height - d*2 - w, color)
  162.     return self
  163.   end
  164.   def clear_4angle_dot
  165.     clear_rect(0, 0, 1, 1)
  166.     clear_rect(width - 1, 0, 1, 1)
  167.     clear_rect(0, height - 1, 1, 1)
  168.     clear_rect(width - 1, height - 1, 1, 1)
  169.     return self
  170.   end
  171.   # 纵向中心渐变
  172.   def vert_center_gradual(c2)
  173.     c1 = Color.new
  174.     self.gradient_fill_rect(0, 0, width, height/2, c1, c2, true)
  175.     self.gradient_fill_rect(0, height/2, width, height/2, c2, c1, true)
  176.     return self
  177.   end
  178. end
  179. # =======================
  180. class Sprite
  181.   def center_screen_xy
  182.     self.x = Graphics.width / 2
  183.     self.y = Graphics.height / 2
  184.   end
  185.   def center_origin
  186.     self.ox = (width + 1) / 2
  187.     self.oy = (height + 1) / 2
  188.   end
  189.   def set_origin_tone
  190.     self.tone = $game_map.screen.tone.inverse
  191.   end
  192.   def zoom(v) # 缩放精灵
  193.     self.zoom_x = v
  194.     self.zoom_y = v
  195.   end
  196. end
  197. # =====================
  198. class Table
  199.   def fill(value) # 填充Table
  200.     if ysize == 1
  201.       xsize.times {|i| self[i] = value}
  202.     elsif zsize == 1
  203.       ysize.times {|j| xsize.times {|i| self[i,j] = value}}
  204.     else
  205.       zsize.times {|k| ysize.times {|j| xsize.times {|i| self[i,j,k] = value}}}
  206.     end
  207.     return self
  208.   end
  209.   def amend(value)
  210.     if ysize == 1
  211.       xsize.times {|i| self[i] += value}
  212.     elsif zsize == 1
  213.       ysize.times {|j| xsize.times {|i|self[i,j] += value}}
  214.     else
  215.       zsize.times {|k| ysize.times {|j| xsize.times {|i| self[i,j,k] += value}}}
  216.     end
  217.     return self
  218.   end
  219.   #
  220.   def self.new_by(array) #利用数组中的16进制信息创建一个Table
  221.     xsize = array[0].digits(16) - 1
  222.     ysize = array.size
  223.     table = Table.new(xsize, ysize)
  224.     ysize.times {|y|
  225.       bit = array[y]
  226.       xsize.times {|x|
  227.         table[xsize - x - 1, y] = (bit >> x*4) & 0xf
  228.       }
  229.     }
  230.     return table
  231.   end
  232. end
  233. # =====================
  234. class Tone
  235.   def inverse
  236.     Tone.new(-red, -green, -blue)
  237.   end
  238. end
  239. # =====================
  240. #~ class << SceneManager
  241. #~   def goto(scene_class, *args)
  242. #~     [url=home.php?mod=space&uid=420706]@Scene[/url] = scene_class.new(*args)
  243. #~   end
  244. #~   def call(scene_class, *args)
  245. #~     @stack.push(@scene)
  246. #~     @scene = scene_class.new(*args)
  247. #~   end
  248. #~ end
  249. #
  250. class << Input
  251. include APIs
  252.   def key_press?(key)
  253.     0 != GetAsyncKeyState.call(key)
  254.   end
  255.   def key_on?(key)
  256.     1 == GetKeyState.call(key) & 1
  257.   end
  258.   def key_repeat?(key) # 该方法最好每帧只调用一次
  259.     GetAsyncKeyState.call(key) & 1 == 1
  260.   end
  261.   #
  262.   def press_shift?
  263.     key_press?(0xA0) || key_press?(0xA1)
  264.   end
  265.   def press_ctrl?
  266.     key_press?(0xA2) || key_press?(0xA3)
  267.   end
  268.   def press_alt?
  269.     key_press?(0xA4) || key_press?(0xA5)
  270.   end
  271.   def refresh_all_keys
  272.     255.times {|i| key_press?(i)}
  273.   end
  274. end
  275. #~ # ============================
  276. #~ class Window_Base
  277. #~   def draw_escape_text_al(text, x = 0, y = 0) #绘制文字自动换行
  278. #~     reset_font_settings
  279. #~     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  280. #~     text = convert_escape_characters(text)
  281. #~     process_characters_al(text.slice!(0, 1), text, pos) until text.empty?
  282. #~   end
  283. #~   def process_characters_al(c, text, pos)
  284. #~     case c
  285. #~     when "\r", "\n"; return
  286. #~     when "\f"; process_new_page(text, pos)
  287. #~     when "\e"; process_escape_character(obtain_escape_code(text), text, pos)
  288. #~     else       process_character_al(c, pos)
  289. #~     end
  290. #~   end
  291. #~   def process_character_al(c, pos) #处理自动换行
  292. #~     tw = text_size(c).width
  293. #~     process_new_line(c, pos) if pos[:x] + tw > contents.width - pos[:new_x]
  294. #~     draw_text(pos[:x], pos[:y], tw * 2, pos[:height], c)
  295. #~     pos[:x] += tw
  296. #~   end
  297. #~ end
复制代码
  1. # 基础鼠标模组(Sion_MouseBase)v1.01 (2013/11/5)
  2. # 需求! 白菜组脚本基 (WhiteCabbageBase) v1.0+
  3. #
  4. # 鼠标指针图片 MouseCursor.png 放入 Graphics\System 文件夹
  5. # 按下 Alt + L 将鼠标锁定在屏幕内; Alt + O(字母欧) 解除锁定

  6. module Mouse end
  7. class << Mouse
  8. DCF = 15 # 判断双击间隔帧数
  9. include APIs
  10. attr_reader :left_state, :right_state
  11.   def activate(vp = nil)
  12.     @dk_count = 0
  13.     hide_system_cursor
  14.     create_cursor(vp)
  15.   end
  16.   def update
  17.     update_cursor
  18.     update_click
  19.     update_mouse_lock
  20.     update_right_click
  21.   end
  22.   def deactivate
  23.     show_system_cursor
  24.     dispose_cursor
  25.   end


  26.   def create_cursor(vp)
  27.     dispose_cursor if @sprite
  28.     @sprite = Sprite.new(vp)
  29.     @sprite.z = 9999
  30.     if File.exist?('Graphics/System/MouseCursor.png')
  31.       @sprite.bitmap = Cache.system('MouseCursor')
  32.     else
  33.       @sprite.bitmap = Bitmap.new(30, 30)
  34. #~       @sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
  35. #~         Rect.new(5 * 24, 24 * 24, 24, 24))
  36. # ↓---------------------------------------------------------------↓
  37.       for i in 1..6
  38.         @sprite.bitmap.fill_rect(i,i,i,i, Color.new(0,0,0))
  39.       end
  40. # ↑---------------------------------------------------------------↑
  41.     end
  42.     update_cursor
  43.   end
  44.   def dispose_cursor
  45.     return if @sprite.disposed?
  46.     @sprite.bitmap.dispose
  47.     @sprite.dispose
  48.   end

  49.   def update_cursor
  50.     buf = '00000000'
  51.     GetCursorPos.call(buf)
  52.     ScreenToClient.call(HWnd, buf)
  53.     x, y = buf.unpack('ll')
  54.     @sprite.x = x
  55.     @sprite.y = y
  56.   end
  57.   def update_click
  58.     @left_state  = GetAsyncKeyState.call(0x01) == 0 ? 0 : @left_state  + 1
  59.     @right_state = GetAsyncKeyState.call(0x02) == 0 ? 0 : @right_state + 1
  60.   end

  61.   #
  62.   def x
  63.     @sprite.x
  64.   end
  65.   def y
  66.     @sprite.y
  67.   end
  68. # ↓---------------------------------------------------------------↓
  69.   def area?(x,y=nil,w=nil,h=nil)
  70.     if y == nil
  71.       self.x.between?(x.x,x.x+x.width) and self.y.between?(x.y,x.y+x.height)
  72.     else
  73.       self.x.between?(x,x+w) and self.y.between?(y,y+h)
  74.     end
  75.   end
  76. # ↑---------------------------------------------------------------↑
  77.   def press?(sym)
  78.     state(sym) > 0
  79.   end
  80.   def trigger?(sym)
  81.     state(sym) == 1
  82.   end
  83.   def repeat?(sym)
  84.     s = state(sym)
  85.     s == 1 || s > 19 && s % 5 == 0
  86.   end
  87.   def state(sym)
  88.     case sym
  89.     when :L; @left_state
  90.     when :R; @right_state
  91.     end
  92.   end
  93.   #
  94.   def update_right_click
  95.     if @left_state == 1
  96.       @ck_count = 0
  97.       @clicked = true
  98.     else
  99.       @ck_count += 1
  100.     end
  101.     if @dk_count > 0 && @left_state == 1
  102.       @dk_count = 0; @clicked = false
  103.       return @double_click = true
  104.     elsif @clicked
  105.       if @dk_count < DCF
  106.         @dk_count += 1
  107.       else
  108.         @dk_count = 0
  109.         @clicked = false
  110.       end
  111.     end
  112.     @double_click = false
  113.   end
  114.   def double_click?
  115.     @double_click
  116.   end
  117.   def click_count
  118.     @ck_count
  119.   end
  120.   #
  121.   def update_mouse_lock # press Alt + L 锁定 Alt + O 解除锁定
  122.     if GetAsyncKeyState.call(0xA4) != 0 || GetAsyncKeyState.call(0xA5) != 0
  123.       return lock   if GetAsyncKeyState.call(0x4C) != 0
  124.       return unlock if GetAsyncKeyState.call(0x4F) != 0
  125.     end
  126.   end
  127.   def lock
  128.     x, y = get_window_pos
  129.     ClipCursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
  130.   end
  131.   def unlock
  132.     ClipCursor.call(0)
  133.   end
  134.   def show_system_cursor
  135.     begin state = ShowCursor.call(1) end while state < 0
  136.   end
  137.   def hide_system_cursor
  138.     begin state = ShowCursor.call(0) end while state >= 0
  139.   end
  140.   def set_pos(m_x, m_y)
  141.     x, y = get_window_pos
  142.     SetCursorPos.call(m_x - x, m_y - y)
  143.   end
  144.   #
  145.   #
  146.   def get_window_pos
  147.     buf = [0, 0].pack('ll')#= '00000000'
  148.     ScreenToClient.call(HWnd, buf)
  149.     return buf.unpack('ll')
  150.   end
  151. end
复制代码
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Integer
  4. #------------------------------------------------------------------------------
  5. #   整数的抽象类。
  6. #==============================================================================

  7. class Integer
  8.   #--------------------------------------------------------------------------
  9.   # ● 判断self是否为一个偶数
  10.   #--------------------------------------------------------------------------
  11.   def even?
  12.     v = self / 2.0
  13.     case v - v.truncate
  14.     when 0.0;       return true
  15.     when 0.5, -0.5; return false
  16.     end
  17.   end
  18. end
复制代码
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Bitmap
  4. #------------------------------------------------------------------------------
  5. #   位图类。
  6. #==============================================================================

  7. class Bitmap
  8.   #--------------------------------------------------------------------------
  9.   # ● 将位图的圆形填充指定颜色
  10.   #     ox    :圆心的x坐标
  11.   #     oy    :圆心的y坐标
  12.   #     radius:圆形的半径
  13.   #     color :填充的颜色
  14.   #--------------------------------------------------------------------------
  15.   def fill_circle(ox, oy, radius, color)
  16.     i_max = radius * Math.sqrt(2) / 2
  17.     square_max = radius * radius + radius / 2
  18.     x = radius
  19.     fill_rect(ox - radius, oy, 2 * radius, 1, color)
  20.     for i in 1..i_max
  21.       if i * i + x * x > square_max
  22.         if x > i_max
  23.           fill_rect(ox - i + 1, oy + x, 2 * (i - 1), 1, color)
  24.           fill_rect(ox - i + 1, oy - x, 2 * (i - 1), 1, color)
  25.         end
  26.         x -= 1
  27.       end
  28.       fill_rect(ox - x, oy + i, 2 * x, 1, color)
  29.       fill_rect(ox - x, oy - i, 2 * x, 1, color)
  30.     end
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● 将位图填充指定颜色
  34.   #     color :填充的颜色
  35.   #--------------------------------------------------------------------------
  36.   def fill(color)
  37.     fill_rect(0, 0, width, height, color)
  38.   end
  39. end
复制代码
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Con
  4. #------------------------------------------------------------------------------
  5. #   所有的常量和一些方法在这里被设置。
  6. #==============================================================================

  7. module Con
  8.   #--------------------------------------------------------------------------
  9.   # ● 常量
  10.   #--------------------------------------------------------------------------
  11.   # 画面
  12.   Size          = 480 # 棋盘大小
  13.   GraphicsWidth = 640 # 画面宽度
  14.   Checker       = 15  # 棋盘大小(格子)
  15.   Bulge         = 3   # 棋子的凸度和连珠粗细
  16.   Tab           = 20  # 缩进值
  17.   # 颜色
  18.   White  = Color.new(255, 255, 255) # 白色
  19.   Black  = Color.new(0, 0, 0)       # 黑色
  20.   Gray   = Color.new(127, 127, 127) # 灰色
  21.   Yellow = Color.new(204, 153, 0)   # 土黄色
  22.   Red    = Color.new(255, 0, 0)     # 红色
  23.   Blue   = Color.new(0, 0, 102)     # 深蓝色
  24.   # 时间
  25.   Game = 15 * Graphics.frame_rate ** 2 # 局时(帧)
  26.   Step = Graphics.frame_rate ** 2      # 步时(帧)
  27.   # 文字
  28.   Title    = "五子棋"                   # 标题
  29.   Author   = Title + " - 有丘直方 制作" # 作者
  30.   Nomsg    = "新局开始"                 # 没有消息的情况
  31.   Success  = "成功"                     # 成功的消息
  32.   Failure  = "失败"                     # 失败的消息
  33.   Alphabet = ["a", "b", "c", "d", "e",  # 小写字母表
  34.               "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p",
  35.               "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
  36.   #--------------------------------------------------------------------------
  37.   # ● 搭建环境
  38.   #--------------------------------------------------------------------------
  39.   def self.environment
  40.     Graphics.freeze
  41.     Graphics.resize_screen(GraphicsWidth, Size)
  42.     Mouse.activate
  43.     Font.default_outline = false
  44.     Font.default_size = Tab
  45.     Font.default_color = Black
  46.     Font.default_name = "幼圆"
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ● 运行
  50.   #--------------------------------------------------------------------------
  51.   def self.run
  52.     environment
  53.     scene = Playing.new
  54.     rgss_main { scene.main }
  55.   end
  56. end
复制代码
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Checkerboard
  4. #------------------------------------------------------------------------------
  5. #   棋盘的精灵。
  6. #==============================================================================

  7. class Checkerboard < Sprite
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_reader(:size)
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化对象
  14.   #--------------------------------------------------------------------------
  15.   def initialize
  16.     super()
  17.     self.bitmap = Bitmap.new(Con::GraphicsWidth, Con::Size)
  18.     @check = Con::Size / (Con::Checker + 1)
  19.     draw_background # 绘制底色
  20.     draw_board      # 绘制棋盘
  21.     draw_text       # 绘制文字
  22.     draw_pos        # 绘制坐标
  23.     @bitmap = bitmap
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 绘制底色
  27.   #--------------------------------------------------------------------------
  28.   def draw_background
  29.     bitmap.fill(Con::Gray)
  30.     size = Con::Size - @check * 2
  31.     rect = Rect.new(@check, @check, size, size)
  32.     bitmap.fill_rect(rect, Con::Yellow)
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 绘制棋盘
  36.   #--------------------------------------------------------------------------
  37.   def draw_board
  38.     for i in 1..Con::Checker # 绘制横线
  39.       x = @check
  40.       y = @check * i
  41.       width = Con::Size - @check * 2
  42.       bitmap.fill_rect(x, y, width, 1, Con::Black)
  43.     end
  44.     for i in 1..Con::Checker # 绘制竖线
  45.       x = @check * i
  46.       y = @check
  47.       height = Con::Size - @check * 2
  48.       bitmap.fill_rect(x, y, 1, height, Con::Black)
  49.     end
  50.     for i in 1..3            # 绘制“星”
  51.       rect = Rect.new(Con::Size / 4 * i - 2, Con::Size / 4 * (4 - i) - 2, 4, 4)
  52.       bitmap.fill_rect(rect, Con::Black)
  53.       rect = Rect.new(Con::Size / 4 * i - 2, Con::Size / 4 * i - 2, 4, 4)
  54.       bitmap.fill_rect(rect, Con::Black)
  55.     end
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 绘制文字
  59.   #--------------------------------------------------------------------------
  60.   def draw_text
  61.     v = Con::Tab
  62.     x = Con::Size - v
  63.     width = Con::GraphicsWidth - Con::Size
  64.     bitmap.draw_text(x,     10,  width, v, "——指令——", 1)
  65.     bitmap.draw_text(x,     30,  width, v, "进程")
  66.     bitmap.draw_text(x + v, 50,  width, v, "悔棋(Q)")
  67.     bitmap.draw_text(x + v, 70,  width, v, "新局(W)")
  68.     bitmap.draw_text(x,     90,  width, v, "文件管理")
  69.     bitmap.draw_text(x + v, 110, width, v, "保存棋局(F5)")
  70.     bitmap.draw_text(x + v, 130, width, v, "复盘(F6)")
  71.     bitmap.draw_text(x,     150, width, v, "落子步数")
  72.     bitmap.draw_text(x + v, 170, width, v, "全部显示(A)")
  73.     bitmap.draw_text(x + v, 190, width, v, "显示一手(S)")
  74.     bitmap.draw_text(x + v, 210, width, v, "不显示(D)")
  75.     bitmap.draw_text(x,     230, width, v, "坐标")
  76.     bitmap.draw_text(x + v, 250, width, v, "全部显示(Z)")
  77.     bitmap.draw_text(x + v, 270, width, v, "不显示(X)")
  78.     bitmap.draw_text(x,     310, width, v, "——信息——", 1)
  79.     bitmap.draw_text(x,     330, width, v, "消息")
  80.     bitmap.draw_text(x,     370, width, v, "计时器")
  81.     bitmap.font.name = "黑体"
  82.     bitmap.draw_text(0, 460, Con::Size, v, Con::Author, 1)
  83.     bitmap.font.name = Font.default_name
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● 绘制坐标
  87.   #--------------------------------------------------------------------------
  88.   def draw_pos
  89.     bitmap.font.color = Con::Black
  90.     bitmap.font.name = "Times New Roman"
  91.     size = Con::Tab
  92.     bitmap.font.italic = true
  93.     bitmap.font.bold = true
  94.     for i in 1..Con::Checker # 绘制字母
  95.       x = @check * i - Con::Tab / 2
  96.       bitmap.draw_text(x, 0, size, size, Con::Alphabet[i - 1], 1)
  97.     end
  98.     bitmap.font.italic = Font.default_italic
  99.     bitmap.font.bold = Font.default_bold
  100.     for i in 1..Con::Checker # 绘制数字
  101.       y = @check * i - Con::Tab / 2
  102.       bitmap.draw_text(0, y, size, size, i, 1)
  103.     end
  104.     bitmap.font.color = Font.default_color
  105.     bitmap.font.name = Font.default_name
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 清除坐标
  109.   #--------------------------------------------------------------------------
  110.   def clear_pos
  111.     rect = Rect.new(0, 0, Con::Size, Con::Size / Con::Checker - 2)
  112.     bitmap.clear_rect(rect)
  113.     bitmap.fill_rect(rect, Con::Gray)
  114.     rect = Rect.new(0, 0, Con::Size / Con::Checker - 2, Con::Size)
  115.     bitmap.clear_rect(rect)
  116.     bitmap.fill_rect(rect, Con::Gray)
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 绘制消息
  120.   #     msg:需要绘制的信息
  121.   #--------------------------------------------------------------------------
  122.   def draw_msg(msg)
  123.     v = Con::Tab
  124.     x = Con::Size - v
  125.     width = Con::GraphicsWidth - Con::Size
  126.     height = Con::Tab
  127.     bitmap.font.name = "楷体_GB2312"
  128.     bitmap.clear_rect(x + v, 350, width, height)
  129.     bitmap.fill_rect(x + v, 350, width, height, Con::Gray)
  130.     bitmap.draw_text(x + v, 350, width, height, msg)
  131.     bitmap.font.name = Font.default_name
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 绘制计时器
  135.   #     game:局时(数组)
  136.   #     step:步时(数组)
  137.   #--------------------------------------------------------------------------
  138.   def draw_time(game, step)
  139.     v = Con::Tab
  140.     x = Con::Size - v
  141.     width = Con::GraphicsWidth - Con::Size
  142.     bitmap.clear_rect(rect = Rect.new(x + v, 390, width, v * 4))
  143.     bitmap.fill_rect(rect, Con::Gray)
  144.     rect = Rect.new(x + v, 390, width, v)
  145.     str = "黑方:" + "局时" + time_str(game[0], Con::Game)
  146.     bitmap.draw_text(rect, str)
  147.     rect = Rect.new(x + v * 4, 410, width, v)
  148.     str = "步时" + time_str(step[0], Con::Step)
  149.     bitmap.draw_text(rect, str)
  150.     rect = Rect.new(x + v, 430, width, v)
  151.     str = "白方:" + "局时" + time_str(game[1], Con::Game)
  152.     bitmap.draw_text(rect, str)
  153.     rect = Rect.new(x + v * 4, 450, width, v)
  154.     str = "步时" + time_str(step[1], Con::Step)
  155.     bitmap.draw_text(rect, str)
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 获取时间字符串
  159.   #     time:时间(帧)
  160.   #     top :上限(帧)
  161.   #--------------------------------------------------------------------------
  162.   def time_str(time, top)
  163.     rest = top - time
  164.     rate = Graphics.frame_rate
  165.     str = ""
  166.     str += "0" if (v = (minute = (second = rest / rate) / rate)) < 10
  167.     str += v.to_s
  168.     str += ":"
  169.     str += "0" if (v = second - minute * rate) < 10
  170.     str += v.to_s
  171.     return str
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ● 释放
  175.   #--------------------------------------------------------------------------
  176.   def dispose
  177.     bitmap.dispose
  178.     super
  179.   end
  180. end
复制代码
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Pieces
  4. #------------------------------------------------------------------------------
  5. #   棋子的精灵。
  6. #==============================================================================

  7. class Pieces < Sprite
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化对象
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super()
  13.     self.bitmap = Bitmap.new(Con::Size, Con::Size)
  14.     self.z = 1
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 绘制棋子
  18.   #     x:     棋子的位置x坐标
  19.   #     y:     棋子的位置y坐标
  20.   #     id:    棋子的ID
  21.   #     number:是否绘制落子步数,0:全部显示;1:显示一手;2:不显示
  22.   #     pieces:当前棋子的总数
  23.   #--------------------------------------------------------------------------
  24.   def draw_piece(x, y, id, number, pieces)
  25.     size = 20
  26.     v = Con::Size / (Con::Checker + 1)
  27.     a = v * (x + 1)
  28.     b = v * (y + 1)
  29.     u = id
  30.     rect = Rect.new(a - v / 2, b - v / 2, v, v)
  31.     bitmap.clear_rect(rect)
  32.     return if u == 0
  33.     if u.even?
  34.       color1 = Con::White
  35.       color2 = Con::Black
  36.     else
  37.       color1 = Con::Black
  38.       color2 = Con::White
  39.     end
  40.     # 绘制棋子外形
  41.     bitmap.fill_circle(a, b, size / 2 + Con::Bulge, color1)
  42.     bitmap.fill_circle(a, b, Con::Bulge, Con::Red) if u == pieces # 新标
  43.     # 绘制落子步数
  44.     unless u == 0 or number == 2
  45.       rect = Rect.new(a - size / 2, b - size / 2, Con::Tab, Con::Tab)
  46.       bitmap.font.color = color2
  47.       case number
  48.       when 0; bitmap.draw_text(rect, u, 1)
  49.       when 1; bitmap.draw_text(rect, u, 1) if u == pieces
  50.       end
  51.     end
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 绘制线段
  55.   #     x     :线段起始点的x坐标(格子)
  56.   #     y     :线段起始点的y坐标(格子)
  57.   #     direct:线段方向,0:横;1:纵;2:左斜;3:右斜
  58.   #     color :线段的颜色
  59.   #--------------------------------------------------------------------------
  60.   def draw_line(x, y, direct, color)
  61.     v = Con::Size / (Con::Checker + 1)
  62.     thickness = Con::Bulge
  63.     x0 = (x + 1.5) * v - thickness / 2
  64.     y0 = (x + 1.5) * v - thickness / 2
  65.     x1 = (x + 1)   * v - thickness / 2
  66.     y1 = (y + 1)   * v - thickness / 2
  67.     x2 = (x + 0.5) * v - thickness / 2
  68.     y2 = (y + 0.5) * v - thickness / 2
  69.     for i in 0..(v * 5)
  70.       case direct
  71.       when 0; bitmap.fill_rect(x2 + i, y1,         thickness, thickness, color)
  72.       when 1; bitmap.fill_rect(x1,     y2 * v + i, thickness, thickness, color)
  73.       when 2; bitmap.fill_rect(x0 - i, y2 + i,     thickness, thickness, color)
  74.       when 3; bitmap.fill_rect(x2 + i, y2 + i,     thickness, thickness, color)
  75.       end
  76.     end
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 释放
  80.   #--------------------------------------------------------------------------
  81.   def dispose
  82.     bitmap.dispose
  83.     super
  84.   end
  85. end
复制代码
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Playing
  4. #------------------------------------------------------------------------------
  5. #   下棋的场景的类。
  6. #==============================================================================

  7. class Playing
  8.   #--------------------------------------------------------------------------
  9.   # ● 主逻辑
  10.   #--------------------------------------------------------------------------
  11.   def main
  12.     start           # 开始
  13.     post_start      # 开始后
  14.     loop { update } # 更新
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 开始
  18.   #--------------------------------------------------------------------------
  19.   def start
  20.     @board = Checkerboard.new # 棋盘
  21.     init_board                # 初始化棋盘
  22.     @pieces = Pieces.new      # 棋子
  23.     @number = 0               # 显示数字
  24.     @pos = 0                  # 显示坐标
  25.     @sign = false             # 棋子更新标志
  26.     @msg = Con::Nomsg         # 消息
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 开始后
  30.   #--------------------------------------------------------------------------
  31.   def post_start
  32.     Graphics.transition
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 更新
  36.   #--------------------------------------------------------------------------
  37.   def update
  38.     update_basic
  39.     update_all_sprites
  40.     last_msg = @msg.clone
  41.     judge_mouse                     # 判断鼠标
  42.     judge_key                       # 判断键盘
  43.     update_pieces if @sign          # 更新棋子
  44.     unless @lock
  45.       update_time if @game          # 更新计时器
  46.       draw_time                     # 绘制计时器
  47.     end
  48.     if @msg != last_msg or @msg == Con::Nomsg
  49.       draw_msg                      # 绘制信息
  50.     end
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 基础更新
  54.   #--------------------------------------------------------------------------
  55.   def update_basic
  56.     Graphics.update
  57.     Mouse.update
  58.     Input.update
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 棋盘初始化
  62.   #--------------------------------------------------------------------------
  63.   def init_board
  64.     @msg = "新局开始" + Con::Success
  65.     @table = Table.new(Con::Checker, Con::Checker)
  66.     @board.bitmap.font.color = Font.default_color
  67.     for i in 0...Con::Checker
  68.       for j in 0...Con::Checker
  69.         @table[i, j] = 0
  70.       end
  71.     end
  72.     @game_time = [0, 0]       # 局时
  73.     @step_time = [0, 0]       # 步时
  74.     @pieces_number = 0
  75.     @lock = false
  76.     @game = false
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 落子
  80.   #--------------------------------------------------------------------------
  81.   def go
  82.     v = Con::Size / (Con::Checker + 1)
  83.     x = (Mouse.x - v / 2) / v
  84.     y = (Mouse.y - v / 2) / v
  85.     if @lock or @table[x, y] != 0
  86.       @msg = "落子" + Con::Failure
  87.     else
  88.       @sign = true
  89.       @pieces_number += 1
  90.       index = nil
  91.       if (@table[x, y] = @pieces_number).even?
  92.         @msg = "白方落子" + Con::Success
  93.         index = 1
  94.       else
  95.         @msg = "黑方落子" + Con::Success
  96.         index = 0
  97.       end
  98.       @step_time[index] = 0 # 步时归零
  99.     end
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● 悔棋
  103.   #--------------------------------------------------------------------------
  104.   def regret
  105.     if @pieces_number - 1 != -1
  106.       @sign = true
  107.       sign = false
  108.       for i in 0...Con::Checker
  109.         for j in 0...Con::Checker
  110.           if @table[i, j] == @pieces_number
  111.             sign = true
  112.             @table[i, j] = 0
  113.             break
  114.           end
  115.         end
  116.         break if sign
  117.       end
  118.       @pieces_number -= 1
  119.       if @pieces_number.even?
  120.         @msg = "黑方悔棋" + Con::Success
  121.       else
  122.         @msg = "白方悔棋" + Con::Success
  123.       end
  124.       @lock = false
  125.     else
  126.       @msg = "悔棋" + Con::Failure
  127.     end
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 新局
  131.   #--------------------------------------------------------------------------
  132.   def new_game
  133.     @sign = true
  134.     init_board
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 保存棋局
  138.   #--------------------------------------------------------------------------
  139.   def save
  140.     File.open("Save.rvdata2", "wb") do |file|
  141.       Marshal.dump(@table, file)
  142.     end
  143.     @msg = "棋局保存" + Con::Success
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ● 复盘
  147.   #--------------------------------------------------------------------------
  148.   def load
  149.     @sign = true
  150.     @msg = "复盘"
  151.     begin
  152.       File.open("Save.rvdata2", "rb") do |file|
  153.         @table = Marshal.load(file)
  154.         v = 0
  155.         for i in 0...Con::Checker
  156.           for j in 0...Con::Checker
  157.             v = @table[i, j] if v < @table[i, j]
  158.           end
  159.         end
  160.         @pieces_number = v
  161.       end
  162.       @msg += Con::Success
  163.     rescue
  164.       @msg += Con::Failure
  165.     end
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 落子步数
  169.   #     number: 显示状态,0:全部显示;1:显示一手;2:不显示
  170.   #--------------------------------------------------------------------------
  171.   def number(number)
  172.     @sign = true
  173.     @number = number
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● 坐标
  177.   #     pos: 显示状态,0:全部显示;1:不显示
  178.   #--------------------------------------------------------------------------
  179.   def pos(pos)
  180.     @pos = pos
  181.     draw_pos
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 判断鼠标
  185.   #--------------------------------------------------------------------------
  186.   def judge_mouse
  187.     if Mouse.trigger?(:L)
  188.       x = Con::Size
  189.       width = Con::GraphicsWidth - Con::Size
  190.       height = Con::Tab
  191.       if    Mouse.area?(0, 0,   x,     x);      go
  192.       elsif Mouse.area?(x, 50,  width, height); regret
  193.       elsif Mouse.area?(x, 70,  width, height); new_game
  194.       elsif Mouse.area?(x, 110, width, height); save
  195.       elsif Mouse.area?(x, 130, width, height); load
  196.       elsif Mouse.area?(x, 170, width, height); number(0)
  197.       elsif Mouse.area?(x, 190, width, height); number(1)
  198.       elsif Mouse.area?(x, 210, width, height); number(2)
  199.       elsif Mouse.area?(x, 250, width, height); pos(0)
  200.       elsif Mouse.area?(x, 270, width, height); pos(1)
  201.       end
  202.     elsif Mouse.trigger?(:R)
  203.       regret
  204.     end
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # ● 判断键盘
  208.   #--------------------------------------------------------------------------
  209.   def judge_key
  210.     if    Input.trigger?(:L);  regret
  211.     elsif Input.trigger?(:R);  new_game
  212.     elsif Input.trigger?(:F5); save
  213.     elsif Input.trigger?(:F6); load
  214.     elsif Input.trigger?(:X);  number(0)
  215.     elsif Input.trigger?(:Y);  number(1)
  216.     elsif Input.trigger?(:Z);  number(2)
  217.     elsif Input.trigger?(:C);  pos(0)
  218.     elsif Input.trigger?(:B);  pos(1)
  219.     end
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 更新棋子
  223.   #--------------------------------------------------------------------------
  224.   def update_pieces
  225.     for i in 0...Con::Checker
  226.       for j in 0...Con::Checker
  227.         draw_piece(i, j)
  228.       end
  229.     end
  230.     v = judge_winner
  231.     if v[0] != 0
  232.       if v[0] != 3
  233.         @pieces.draw_line(v[1], v[2], v[3], Con::Red)
  234.       end
  235.       case v[0]
  236.       when 1; @msg = "黑方获胜"
  237.       when 2; @msg = "白方获胜"
  238.       when 3; @msg = "双方和棋"
  239.       end
  240.       @lock = true
  241.     end
  242.     @game = true if @pieces_number != 0
  243.     @sign = false
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ● 更新计时器
  247.   #--------------------------------------------------------------------------
  248.   def update_time
  249.     if @pieces_number.even?
  250.       @game_time[0] += 1
  251.       @step_time[0] += 1
  252.     else
  253.       @game_time[1] += 1
  254.       @step_time[1] += 1
  255.     end
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 绘制棋子
  259.   #     x:棋子的位置x坐标
  260.   #     y:棋子的位置y坐标
  261.   #--------------------------------------------------------------------------
  262.   def draw_piece(x, y)
  263.     @pieces.draw_piece(x, y, @table[x, y], @number, @pieces_number)
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ● 绘制消息
  267.   #--------------------------------------------------------------------------
  268.   def draw_msg
  269.     @board.draw_msg(@msg)
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 绘制计时器
  273.   #--------------------------------------------------------------------------
  274.   def draw_time
  275.     @board.draw_time(@game_time, @step_time)
  276.     if @game_time.include?(Con::Game)
  277.       i = 0
  278.       @game_time.each do |j|
  279.         if j == Con::Game
  280.           @lock = true
  281.           @msg = ((i == 1) ? "黑方获胜" : "白方获胜")
  282.         end
  283.         i += 1
  284.       end
  285.     elsif @step_time.include?(Con::Step)
  286.       i = 0
  287.       @step_time.each do |j|
  288.         if j == Con::Step
  289.           @lock = true
  290.           @msg = ((i == 1) ? "黑方获胜" : "白方获胜")
  291.         end
  292.         i += 1
  293.       end
  294.     end
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 绘制坐标
  298.   #--------------------------------------------------------------------------
  299.   def draw_pos
  300.     case @pos
  301.     when 0; @board.draw_pos
  302.     when 1; @board.clear_pos
  303.     end
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 判断胜负
  307.   #--------------------------------------------------------------------------
  308.   def judge_winner
  309.     return [0] if @pieces_number < 9        # 目前没到9个棋子则未决胜负
  310.     return [3] if @pieces_number == 15 ** 2 # 棋盘下满则和棋
  311.     for i in 0...Con::Checker
  312.       for j in 0...Con::Checker
  313.         if @table[i, j] != 0
  314.           if i <= Con::Checker - 5                           # 横向
  315.             for k in 1..4
  316.               break if @table[i, j].even? != @table[i + k, j].even?
  317.               break if @table[i + k, j] == 0
  318.               if k == 4
  319.                 if @table[i, j].even?
  320.                   return [2, i, j, 0]
  321.                 else
  322.                   return [1, i, j, 0]
  323.                 end
  324.               end
  325.             end
  326.           end
  327.           if j <= Con::Checker - 5                           # 纵向
  328.             for k in 1..4
  329.               break if @table[i, j].even? != @table[i, j + k].even?
  330.               break if @table[i, j + k] == 0
  331.               if k == 4
  332.                 if @table[i, j].even?
  333.                   return [2, i, j, 1]
  334.                 else
  335.                   return [1, i, j, 1]
  336.                 end
  337.               end
  338.             end
  339.           end
  340.           if i >= 4 and j <= Con::Checker - 5                # 左斜向
  341.             for k in 1..4
  342.               break if @table[i, j].even? != @table[i - k, j + k].even?
  343.               break if @table[i - k, j + k] == 0
  344.               if k == 4
  345.                 if @table[i, j].even?
  346.                   return [2, i, j, 2]
  347.                 else
  348.                   return [1, i, j, 2]
  349.                 end
  350.               end
  351.             end
  352.           end
  353.           if i <= Con::Checker - 5 and j <= Con::Checker - 5 # 右斜向
  354.             for k in 1..4
  355.               break if @table[i, j].even? != @table[i + k, j + k].even?
  356.               break if @table[i + k, j + k] == 0
  357.               if k == 4
  358.                 if @table[i, j].even?
  359.                   return [2, i, j, 3]
  360.                 else
  361.                   return [1, i, j, 3]
  362.                 end
  363.               end
  364.             end
  365.           end
  366.         end
  367.       end
  368.     end
  369.     return [0]
  370.   end
  371.   #--------------------------------------------------------------------------
  372.   # ● 更新所有精灵
  373.   #--------------------------------------------------------------------------
  374.   def update_all_sprites
  375.     instance_variables.each do |varname|
  376.       ivar = instance_variable_get(varname)
  377.       ivar.update if ivar.is_a?(Sprite)
  378.     end
  379.   end
  380. end
复制代码
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Main
  4. #------------------------------------------------------------------------------
  5. #   各种定义结束后,从这里开始实际运行。
  6. #==============================================================================

  7. Con.run
复制代码

第二个请新建一个工程,游戏名定为《五子棋》,然后删除MAP001,保存并退出,解压此文件并覆盖目录Data\下的Scripts.rvdata2。
Scripts.zip (11.37 KB, 下载次数: 8)

第三个莫名其妙,为什么360会说这个Game.exe有病毒?如果不放心的话,换一个确认无毒的RGSS3的引擎即可。
Gobang.zip (1.34 MB, 下载次数: 29)

感谢@Mr.Jin @Sion

图 搜狗截图20170129170246.png 搜狗截图20170129170208.png 搜狗截图20170129170146.png

评分

参与人数 1赞 +1 收起 理由
whitedewxiao + 1 简直棒呆了

查看全部评分

小仙女一枚~
梦石
0
星屑
50
在线时间
277 小时
注册时间
2012-12-1
回帖
298
发表于 2017-1-29 18:53:58 | 显示全部楼层
作死吧你,我会埋葬的,阿门
果然还是《漂流武士》、《恶魔人》还有《魔法少女小圆》最赞了。 不过拔作还是推荐《药与魔法的米莉尔》和《小春酱的巫女奋斗记》。
回复

使用道具 举报

梦石
1
星屑
24088
在线时间
3339 小时
注册时间
2011-7-8
回帖
3862

开拓者

发表于 2017-1-30 12:08:09 来自手机 | 显示全部楼层
哇,这个界面好看~为啥楼上会说是作死呢?
我之前也写了个联机的五子棋小游戏:
来自我的新浪博客已弃坑
功能比你这个要少多了……不过可以局域网联机(๑• . •๑)

点评

我也是从6R某个奇怪的地方搞到了这个TCP脚本,至少是能用。有兴趣的话可以看看博客前面的文章内容~  发表于 2017-1-30 22:47
谢谢,, 联机之类的一直不会弄……  发表于 2017-1-30 12:56
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部