Per 2016, RMID pindah ke RMID Discord (Invite link dihapus untuk mencegah spambot -Theo @ 2019). Posting sudah tidak bisa dilakukan lagi.
Mohon maaf atas ketidaknyamanannya dan mohon kerjasamanya.

Share | 
 

 [VX]Tower of Hanoi Minigame

Topik sebelumnya Topik selanjutnya Go down 
[VX]Tower of Hanoi Minigame Empty2011-05-10, 11:04
Post[VX]Tower of Hanoi Minigame
#1
hart 
Senior
Senior
avatar

Level 5
Posts : 805
Thanked : 38
Engine : Other
Skill : Very Beginner
Type : Developer

[VX]Tower of Hanoi Minigame Vide
Minigame Menara Hanoi
Versi: Gaje
Tipe: Gaje


Pengenalan

Apa itu Menara Hanoi? Baca ini http://en.wikipedia.org/wiki/Tower_of_Hanoi atau tanya om Oscar. Ini saya kerjakan berdasarkan request dari om oscar kemarin. Maaf buru2 bikinnya jadi mungkin terlalu jelek dan mungkin juga ada bug.


Fitur


  • Bernostalgia pada masa kecil.



Screenshots

takada


Demo

takada


Scripts

Code:

#===============================================================================
# * Minigame Tower of Hanoi
#-------------------------------------------------------------------------------
# Requested by om Oscar tercinta
#-------------------------------------------------------------------------------
# Cara pakai:
# - Copas script ini ke atas main
# - Panggil via event:
#    $scene = Scene_HanoiTower.new(jumlah_kotak, jumlah_tempat[, waktu])
#  keterangan:
#  - jumlah_kotak maksimal 64, jumlah_tempat maksimal 8
#  - kosongkan bagian waktu bila tidak ingin memakai waktu
# - Variabel dengan ID yg ditentukan di bawah akan bernilai 1 jika menang, dan 2
#  jika kalah (waktu habis)
#-------------------------------------------------------------------------------
module Hart
  module HanoiTower
#-------------------------------------------------------------------------------
# Konfigurasi
#-------------------------------------------------------------------------------
ICON_INDEX = 3
RESULT_VAR = 1
REMAINING_TIME_VAR = 2
#-------------------------------------------------------------------------------
  end
end
#===============================================================================
class Hanoi_Timer < Sprite
  attr_reader :time
 
  def initialize(x, y, time)
    super()
    self.visible = false if time < 0
    @framecount = 0
    @time = time
    self.x = x
    self.y = y
    self.z = 50
    self.bitmap = Bitmap.new(544, 12)
    self.bitmap.font = Font.new("Arial", 12)
  end
 
  def update
    super()
   
    @framecount += 1 if @time >= 0
    if @framecount >= 60
      @time -= 1 if @time > 0
      @framecount = 0
    end
   
    self.bitmap.clear
    self.bitmap.draw_text(0, 0, 544, 12, "Time: " + @time.to_s) if @time >= 0
  end
end

class Hanoi_Pointer < Sprite
  attr_accessor :tempats
  attr_accessor :index
  attr_accessor :active
 
  def initialize(tempats)
    super()
    @tempats = tempats
    @active = true
    @index = 0
   
    temp = Cache.system("IconSet.png")
    self.bitmap = Bitmap.new(24, 24)
    self.bitmap.blt(0, 0, temp, Rect.new((Hart::HanoiTower::ICON_INDEX % 16) *
                    24, (Hart::HanoiTower::ICON_INDEX / 16) * 24, 24, 24))
         
    self.x = @tempats[@index].x - 10
    self.y = 386
  end
 
  def update
    super
    self.x = @tempats[@index].x - 10
    self.y = 386
   
    if active
      self.opacity = 255
    else
      self.opacity = 128
    end
   
    update_input
  end
 
  def update_input
    if @active
      if Input.repeat?(Input::RIGHT)
        Sound.play_cursor
        @index = (@index + 1) % @tempats.size
      elsif Input.repeat?(Input::LEFT)
        Sound.play_cursor
        @index = (@index - 1 + @tempats.size) % @tempats.size
      end
    end
  end
end

class Hanoi_Block < Sprite
  attr_accessor :tempat
  attr_accessor :tempatpos
  attr_reader :size
 
  def initialize(size)
    super()
    @size = size
    @color = Color.new(rand(128) + 128, rand(128) + 128, rand(128) + 128)
    @tempat = nil
    @tempatpos = nil
   
    self.bitmap = Bitmap.new(size, 10)
  end
 
  def update
    super
    self.bitmap.fill_rect(0, 0, @size, 10, @color)
    self.x = @tempat.x - @size / 2
    self.y = 380 - @tempatpos * 10 if @tempat != nil
  end
end

class Hanoi_Tempat
  attr_accessor :blocks
  attr_reader :x
 
  def initialize(x)
    @x = x
    @blocks = []
  end
 
  def push(block)
    @blocks.push(block)
    block.tempat = self
    block.tempatpos = self.height
  end
 
  def pop
    @blocks.pop
  end
 
  def height
    return @blocks.size
  end
 
  def empty?
    return @blocks.empty?
  end
 
  def top_smaller?(other)
    return false if empty?
    return true if other.empty?
    return @blocks[height - 1].size < other.blocks[other.height - 1].size
  end
end

class Scene_HanoiTower < Scene_Base
  def initialize(jlh_kotak, jlh_tempat, waktu = -1)
    if jlh_kotak > 64
      @jlh_kotak = 64
    elsif jlh_kotak < 3
      @jlh_kotak = 3
    else
      @jlh_kotak = jlh_kotak
    end
   
    if jlh_tempat > 8
      @jlh_tempat = 8
    elsif jlh_tempat < 3
      @jlh_tempat = 3
    else
      @jlh_tempat = jlh_tempat
    end
   
    @waktu = waktu
    @blocks = []
    @tempats = []
    @timer = Hanoi_Timer.new(0, 0, @waktu)
  end
 
  def start
    for i in 0 ... @jlh_tempat
      @tempats[i] = Hanoi_Tempat.new((i * (544 / @jlh_tempat)) + (544 / @jlh_tempat) / 2)
    end
   
    for i in 0 ... @jlh_kotak
      @blocks[i] = Hanoi_Block.new((@jlh_kotak - i) * (100 / @jlh_kotak) + 5)
      @tempats[rand(@jlh_tempat)].push(@blocks[i])
    end
   
    @pointer1 = Hanoi_Pointer.new(@tempats)
    @pointer2 = Hanoi_Pointer.new(@tempats)
    @pointer2.active = false
    @pointer2.visible = false
  end
 
  def update   
    for block in @blocks
      block.update
    end
   
    if Input.trigger?(Input::C)
      if @pointer1.active
        if !@tempats[@pointer1.index].empty?
          Sound.play_decision
          @pointer2.index = @pointer1.index
          @pointer1.active = false
          @pointer2.visible = true
          @pointer2.active = true
        else
          Sound.play_buzzer
        end
      else
        if @tempats[@pointer1.index].top_smaller?(@tempats[@pointer2.index])
          Sound.play_equip
          @tempats[@pointer2.index].push(@tempats[@pointer1.index].pop)
          @pointer2.active = false
          @pointer2.visible = false
          @pointer1.index = @pointer2.index
          @pointer1.active = true
        else
          Sound.play_buzzer
        end
      end
    elsif Input.trigger?(Input::B)
      if @pointer2.active
        Sound.play_cancel
        @pointer2.active = false
        @pointer2.visible = false
        @pointer1.active = true
      end
    end
   
    @pointer1.update
    @pointer2.update
   
    if win?
      $game_variables[Hart::HanoiTower::RESULT_VAR] = 1
      $game_variables[Hart::HanoiTower::REMAINING_TIME_VAR] = @timer.time
      $scene = Scene_Map.new
    end
   
    if @waktu >= 0 && lose?
      $game_variables[Hart::HanoiTower::RESULT_VAR] = 2
      $game_variables[Hart::HanoiTower::REMAINING_TIME_VAR] = @timer.time
      $scene = Scene_Map.new
    end
   
    @timer.update
  end
 
  def win?
    for tempat in @tempats
      return true if tempat.height == @jlh_kotak
    end
   
    return false
  end
 
  def lose?
    return @timer.time<= 0
  end
 
  def terminate
    for block in @blocks
      next if block == nil
      block.dispose
    end
    @pointer1.dispose
    @pointer2.dispose
    @timer.dispose
  end
end


Credits

Tidak perlu credit bila tidak mau. Asalkan anda sopan dan menghargai sesama manusia


Terakhir diubah oleh hart tanggal 2011-05-10, 11:40, total 1 kali diubah
[VX]Tower of Hanoi Minigame Empty2011-05-10, 11:15
PostRe: [VX]Tower of Hanoi Minigame
#2
nisamerica 
Living Skeleton
nisamerica

Kosong
Posts : 1668
Thanked : 25
Engine : RMVX
Skill : Very Beginner
Type : Artist
Awards:


[VX]Tower of Hanoi Minigame Vide
Wogh, Tower of Hanoi, game yang addictive tapi kadang nyebelin headbang
Bisa di set per wadah maksimal tapi wadahnya cuma 2 ngga?? :kabur:
[VX]Tower of Hanoi Minigame Empty2011-05-10, 11:17
PostRe: [VX]Tower of Hanoi Minigame
#3
hart 
Senior
Senior
avatar

Level 5
Posts : 805
Thanked : 38
Engine : Other
Skill : Very Beginner
Type : Developer

[VX]Tower of Hanoi Minigame Vide
Quote :

Bisa di set per wadah maksimal tapi wadahnya cuma 2 ngga?? :kabur:
bisa
[VX]Tower of Hanoi Minigame Empty2011-05-10, 11:22
PostRe: [VX]Tower of Hanoi Minigame
#4
nisamerica 
Living Skeleton
nisamerica

Kosong
Posts : 1668
Thanked : 25
Engine : RMVX
Skill : Very Beginner
Type : Artist
Awards:


[VX]Tower of Hanoi Minigame Vide
Loh tunggu, kalo gitu ga bisa selesai kan? =))
Ato gwa ketuker antara game lain? :kabur:
[VX]Tower of Hanoi Minigame Empty2011-05-10, 11:26
PostRe: [VX]Tower of Hanoi Minigame
#5
hart 
Senior
Senior
avatar

Level 5
Posts : 805
Thanked : 38
Engine : Other
Skill : Very Beginner
Type : Developer

[VX]Tower of Hanoi Minigame Vide
@om merica: memang gk bisa selesai klo cuma 2 wadah, tapi kan anda yg tentuin berapa wadah sebagai pembuat gamenya, masa sih anda mau membiarkan pemain main yg gk mungkin diselesaikan? kalo ya, ya silahkan =))
[VX]Tower of Hanoi Minigame Empty2011-05-10, 11:34
PostRe: [VX]Tower of Hanoi Minigame
#6
nisamerica 
Living Skeleton
nisamerica

Kosong
Posts : 1668
Thanked : 25
Engine : RMVX
Skill : Very Beginner
Type : Artist
Awards:


[VX]Tower of Hanoi Minigame Vide
Kadang kepengen juga nyiksa player =))
Bikin batasan aja biar ga disalahgunakan =))
[VX]Tower of Hanoi Minigame Empty2011-05-10, 11:40
PostRe: [VX]Tower of Hanoi Minigame
#7
hart 
Senior
Senior
avatar

Level 5
Posts : 805
Thanked : 38
Engine : Other
Skill : Very Beginner
Type : Developer

[VX]Tower of Hanoi Minigame Vide
@om merica: jangan donk.. script itu kan harus se-flexibel mungkin... Kan memang ada aja orang yg mau nyiksa player, yah biarlah dia berbuat begitu kalau memang mau =)) tapi setelah dipikir-pikir oke deh sekarang udah dibatasi minimal 3 wadah dan minimal 3 kotak, untuk om merica tercinta :malu:
[VX]Tower of Hanoi Minigame Empty2011-05-10, 11:55
PostRe: [VX]Tower of Hanoi Minigame
#8
nisamerica 
Living Skeleton
nisamerica

Kosong
Posts : 1668
Thanked : 25
Engine : RMVX
Skill : Very Beginner
Type : Artist
Awards:


[VX]Tower of Hanoi Minigame Vide
Wah makasih Hart... :malu:
Padahal ga ada niat buat masukin Hanoi ke game :kabur:
Cuma ngusul2 dan nyampah ga jelas gwa =))

Bikin yg XP aja, sapa tau kepake :kabur: :hammer:
[VX]Tower of Hanoi Minigame Empty2011-05-10, 12:20
PostRe: [VX]Tower of Hanoi Minigame
#9
Oscar 
Senior
Senior
Oscar

Level 5
Posts : 830
Thanked : 13
Engine : RMVX
Skill : Beginner
Type : Writer

[VX]Tower of Hanoi Minigame Vide
wah2 , dibikinin juga ternyata :sembah:

nda nyangka , padahal cuman tanya bisa atau enggak huheuehuehue :peace:

thanks banget om hart :muach:

+1 reppo
[VX]Tower of Hanoi Minigame Empty2011-05-10, 13:02
PostRe: [VX]Tower of Hanoi Minigame
hart 
Senior
Senior
avatar

Level 5
Posts : 805
Thanked : 38
Engine : Other
Skill : Very Beginner
Type : Developer

[VX]Tower of Hanoi Minigame Vide
@om merica: macama~~ :malu:
saya tau kok kalau anda cuma nyampah :malu:
XP yach? coba dech macukin tuh script ke XP, capa tau isa :malu:

@om oscar: ihihi, makacii banget wat cendol na :malu: :muach: :malu:
[VX]Tower of Hanoi Minigame Empty
PostRe: [VX]Tower of Hanoi Minigame
Sponsored content 




[VX]Tower of Hanoi Minigame Vide
 

[VX]Tower of Hanoi Minigame

Topik sebelumnya Topik selanjutnya Kembali Ke Atas 

Similar topics

+
Halaman 1 dari 1

Permissions in this forum:Anda tidak dapat menjawab topik
RPGMakerID :: Scripts & Event Systems :: RMVX Scripts-