| 赞 | 189  | 
 
| VIP | 627 | 
 
| 好人卡 | 188 | 
 
| 积分 | 96 | 
 
| 经验 | 171230 | 
 
| 最后登录 | 2024-7-3 | 
 
| 在线时间 | 5073 小时 | 
 
 
 
 
 
Lv4.逐梦者 (版主) 
	- 梦石
 - 0 
 
        - 星屑
 - 9552 
 
        - 在线时间
 - 5073 小时
 
        - 注册时间
 - 2013-6-21
 
        - 帖子
 - 3580
 
 
    
 
 | 
	
 本帖最后由 RyanBern 于 2015-10-5 16:25 编辑  
 
一本正经地发工程。小7说的是真的么?平时答题都没糖所以坐等小7赞助 
以下工程需要RGSS102J.dll,修改的话需要RMXP。如果不符合要求请告知 
module Hanoi   Max_Plates = 4 # 最大可设置为 6   def self.start     self.create_ui     @pillars = [Array.new(Max_Plates){|i| i}, [], []]     @hold_index =  -1     loop do       Graphics.update       Input.update       self.update     end   end   def self.create_ui     @sprite_title = Sprite.new     @sprite_title.bitmap = Bitmap.new(640, 32)     @sprite_title.bitmap.draw_text(0, 0, 640, 32, "将所有盘子移动到红色柱子上,且不能把大盘放到小盘上!", 1)     @sprite_pillars = Array.new(3) do |i|       sprite = Sprite.new       sprite.bitmap = Bitmap.new(16, 320)       sprite.x,sprite.y = 100 + 208 * i, 128       sprite.bitmap.fill_rect(0, 0, 32, 320, i == 2 ? Color.new(200, 0, 0) : Color.new(255, 255, 255))       sprite     end     @sprite_plates = Array.new(Max_Plates) do |i|       sprite = Sprite.new       sprite.bitmap = Bitmap.new(192 - 32 * i, 32)       sprite.ox,sprite.x,sprite.y = sprite.bitmap.width / 2, 108, 416 - 32 * i       sprite.bitmap.fill_rect(0, 0, sprite.bitmap.width, 32, Color.new(200, 200, 200))       sprite     end     @arrow = Arrow_Base.new(nil)     @arrow.x,@arrow.y = 108, 96   end   def self.update     @arrow.update     if Input.trigger?(Input::LEFT)       @arrow.index -= 1       return     end     if Input.trigger?(Input::RIGHT)       @arrow.index += 1       return     end     @arrow.index %= 3     @arrow.x = 108 + @arrow.index * 208     @sprite_plates[@hold_index].x = 108 + @arrow.index * 208 if @hold_index != -1     if Input.trigger?(Input::C)       if @hold_index == -1         return if @pillars[@arrow.index].empty?         @hold_index = @pillars[@arrow.index].pop         @sprite_plates[@hold_index].y = 64       else         return unless @pillars[@arrow.index].empty? || @pillars[@arrow.index][-1] < @hold_index         @pillars[@arrow.index] << @hold_index         @sprite_plates[@hold_index].y = 416 - 32 * (@pillars[@arrow.index].size - 1)         @hold_index = -1         if (0...Max_Plates).to_a == @pillars[2]           print "You win!!"           exit         end       end     end   end end 
 
 module Hanoi  
  Max_Plates = 4 # 最大可设置为 6  
  def self.start  
    self.create_ui  
    @pillars = [Array.new(Max_Plates){|i| i}, [], []]  
    @hold_index =  -1  
    loop do  
      Graphics.update  
      Input.update  
      self.update  
    end  
  end  
  def self.create_ui  
    @sprite_title = Sprite.new  
    @sprite_title.bitmap = Bitmap.new(640, 32)  
    @sprite_title.bitmap.draw_text(0, 0, 640, 32, "将所有盘子移动到红色柱子上,且不能把大盘放到小盘上!", 1)  
    @sprite_pillars = Array.new(3) do |i|  
      sprite = Sprite.new  
      sprite.bitmap = Bitmap.new(16, 320)  
      sprite.x,sprite.y = 100 + 208 * i, 128  
      sprite.bitmap.fill_rect(0, 0, 32, 320, i == 2 ? Color.new(200, 0, 0) : Color.new(255, 255, 255))  
      sprite  
    end  
    @sprite_plates = Array.new(Max_Plates) do |i|  
      sprite = Sprite.new  
      sprite.bitmap = Bitmap.new(192 - 32 * i, 32)  
      sprite.ox,sprite.x,sprite.y = sprite.bitmap.width / 2, 108, 416 - 32 * i  
      sprite.bitmap.fill_rect(0, 0, sprite.bitmap.width, 32, Color.new(200, 200, 200))  
      sprite  
    end  
    @arrow = Arrow_Base.new(nil)  
    @arrow.x,@arrow.y = 108, 96  
  end  
  def self.update  
    @arrow.update  
    if Input.trigger?(Input::LEFT)  
      @arrow.index -= 1  
      return  
    end  
    if Input.trigger?(Input::RIGHT)  
      @arrow.index += 1  
      return  
    end  
    @arrow.index %= 3  
    @arrow.x = 108 + @arrow.index * 208  
    @sprite_plates[@hold_index].x = 108 + @arrow.index * 208 if @hold_index != -1  
    if Input.trigger?(Input::C)  
      if @hold_index == -1  
        return if @pillars[@arrow.index].empty?  
        @hold_index = @pillars[@arrow.index].pop  
        @sprite_plates[@hold_index].y = 64  
      else  
        return unless @pillars[@arrow.index].empty? || @pillars[@arrow.index][-1] < @hold_index  
        @pillars[@arrow.index] << @hold_index  
        @sprite_plates[@hold_index].y = 416 - 32 * (@pillars[@arrow.index].size - 1)  
        @hold_index = -1  
        if (0...Max_Plates).to_a == @pillars[2]  
          print "You win!!"  
          exit  
        end  
      end  
    end  
  end  
end  
 
  
附工程:
 
ProjectR.rar
(191.7 KB, 下载次数: 37)
   |   
 
 
 
 |