RPG maker VX


Unirse al foro, es rápido y fácil

RPG maker VX
RPG maker VX
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.
Últimos temas
» Script de menu
por maxi Jue 04 Dic 2014, 1:44 pm

» Ayuda intro animado!!!
por maxi Miér 03 Dic 2014, 9:41 pm

» ayuda con este engin
por maxi Miér 03 Dic 2014, 8:42 am

» Hud de Vida 100% Personalizable - Engine Sencillo! Sin Scripts :)
por davidaikago Jue 20 Nov 2014, 10:58 am

» Ultimate parallax control by:GDS [ace]
por arellano Miér 08 Oct 2014, 8:28 pm

» Script Touhou (animated) Map name (v1.4)
por davidaikago Miér 08 Oct 2014, 2:09 pm

» tutorial puerta nueva
por davidaikago Miér 08 Oct 2014, 9:08 am

» cámara de fotos
por davidaikago Miér 08 Oct 2014, 9:05 am

» Imperial Action System II Demo
por davidaikago Miér 08 Oct 2014, 8:47 am

» VE Batalla animada [ACE]
por FhierusIV Jue 18 Sep 2014, 10:57 am

» Nuevo Reglamento del Foro [Vigente desde Septiembre 2014]
por maxi Miér 17 Sep 2014, 8:37 am

» MOG|Animated Title
por Souta21 Mar 09 Sep 2014, 7:24 pm

» Tutorial Engine - Cambiar Character al Equipar Objeto
por maxi Lun 21 Jul 2014, 10:19 am

» Script de climas
por gambasoxd Sáb 19 Jul 2014, 8:58 am

» Script de contraseña(codigo) para abrir un cofre
por rpgame Jue 03 Jul 2014, 6:03 pm

¿Quién está en línea?
En total hay 1 usuario en línea: 0 Registrados, 0 Ocultos y 1 Invitado

Ninguno

[ Ver toda la lista ]


El record de usuarios en línea fue de 117 durante el Mar 09 Ago 2011, 3:39 pm

[Script] Tetris (Piezas x Monstruos)

Ir abajo

[Script] Tetris (Piezas x Monstruos) Empty [Script] Tetris (Piezas x Monstruos)

Mensaje por Linksen Lun 22 Oct 2012, 12:15 pm

Tetris (Piezas x Monstruos)

por ????


-Instrucciones-:

Pegar encima de Main.
Llamar al evento tal y cómo se muestra
en el script.

!: Son necesários los 3 scripts para que funcione.


-Script:-

Código:

#==============================================================================
# ■ TPuzzle_Scene
#------------------------------------------------------------------------------
#  落ち物パズルのシーンクラス
#==============================================================================
module TPUZZLE
  FIELD_WIDTH = 10
  FIELD_HEIGHT = 15
  FIELD_LEFT = 1
  FIELD_RIGHT = 8
  FIELD_TOP = 1
  FIELD_BOTTOM = 13
  VARIABLE_ID = 37    # 結果を保存する変数
end

class TPuzzle_Scene < Scene_Base
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :stage
  attr_reader :block
  attr_reader :total_time
  attr_accessor :game_end
  attr_accessor :score
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    $game_temp.map_bgm = RPG::BGM.last
    $game_temp.map_bgs = RPG::BGS.last
    RPG::BGM.stop
    RPG::BGS.stop
    Sound.play_battle_start
    $game_system.battle_bgm.play
  end
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @score = 0
    @total_time = 0
    @stage = TPuzzle_Cell.new(TPUZZLE::FIELD_WIDTH, TPUZZLE::FIELD_HEIGHT)
    for i in [Tienes que estar registrado y conectado para ver este vínculo]
      @stage.set(0, i, "#")
      @stage.set(@stage.width - 1, i, "#")
    end
    for i in [Tienes que estar registrado y conectado para ver este vínculo] do @stage.set(i, @stage.height - 1, "#") end
    @sprite = Sprite.new
    @sprite.z = 200
    bitmap = Bitmap.new(544, 416)
    @sprite.bitmap = bitmap
    @block = TPuzzle_Dropblock.new
    @game_end = false
  end
  #--------------------------------------------------------------------------
  # ● 終了処理
  #--------------------------------------------------------------------------
  def terminate
    $game_variables[TPUZZLEVARIABLE_ID] = @score
    unless $BTEST
      $game_temp.map_bgm.play
      $game_temp.map_bgs.play
    end
    super
    dispose_menu_background
    @sprite.dispose
    @block.dispose
    @stage.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    if Input.trigger?(Input::F5) or @game_end  # F5強制終了
      $scene = Scene_Map.new
      return
    end
    @block.update
    @total_time += 1
    draw
  end
  #--------------------------------------------------------------------------
  # ● 描画
  #--------------------------------------------------------------------------
  def draw
    @sprite.bitmap.clear
    ox = (544 - TPUZZLE::FIELD_WIDTH * 32) / 2 - 32
    oy = 416 - TPUZZLE::FIELD_HEIGHT * 32
    color = Color.new(255, 255, 255, 255)
    @sprite.bitmap.fill_rect(ox + 16, 0, 2, 416, color)
    @sprite.bitmap.fill_rect(ox + TPUZZLE::FIELD_WIDTH * 32 - 20, 0, 2, 416, color)
    bitmap_monster = Cache.character("Monster")
    rect = Rect.new(192, 0, 32, 32)
    alpha = 255 - @block.time * 16
    for i in TPUZZLE::FIELD_LEFT..TPUZZLE::FIELD_RIGHT
      for j in TPUZZLE::FIELD_TOP..TPUZZLE::FIELD_BOTTOM
        if @stage.get(i, j) == "#"
          @sprite.bitmap.blt(i * 32 + ox, j * 32 + oy, bitmap_monster, rect)
        elsif @stage.get(i, j) == "+"
          @sprite.bitmap.blt(i * 32 + ox, j * 32 + oy, bitmap_monster, rect, alpha)
        end
      end
    end
    @sprite.bitmap.draw_text(ox + TPUZZLE::FIELD_WIDTH * 32, 16, 120, 24, @score.to_s)
  end
end
Código:

#==============================================================================
# ■ TPuzzle_Dropblock
#------------------------------------------------------------------------------
#  落ち物パズルのセルクラス
#==============================================================================
class TPuzzle_Dropblock < TPuzzle_Cell
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :cx
  attr_reader :cy
  attr_reader :time
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(width = 4, height = 4)
    super(width, height)
    @block_pattern = Array.new(32)
    @block_pattern[0]  = " #  ###        "
    @block_pattern[1]  = " #  ##  #      "
    @block_pattern[2]  = "    ###  #      "
    @block_pattern[3]  = " #  ##  #      "
    @block_pattern[4]  = "    ##  ##    "
    @block_pattern[5]  = "    ##  ##    "
    @block_pattern[6]  = "    ##  ##    "
    @block_pattern[7]  = "    ##  ##    "
    @block_pattern[8]  = "    ####        "
    @block_pattern[9]  = " #  #  #  #  "
    @block_pattern[10] = "    ####        "
    @block_pattern[11] = " #  #  #  #  "
    @block_pattern[12] = "    ##  ##    "
    @block_pattern[13] = "  #  ##  #      "
    @block_pattern[14] = "    ##  ##    "
    @block_pattern[15] = "  #  ##  #      "
    @block_pattern[16] = "    ## ##      "
    @block_pattern[17] = " #  ##  #    "
    @block_pattern[18] = "    ## ##      "
    @block_pattern[19] = " #  ##  #    "
    @block_pattern[20] = "  # ###        "
    @block_pattern[21] = " #  #  ##    "
    @block_pattern[22] = "    ### #      "
    @block_pattern[23] = "##  #  #      "
    @block_pattern[24] = "#  ###        "
    @block_pattern[25] = " ##  #  #      "
    @block_pattern[26] = "    ###  #    "
    @block_pattern[27] = " #  #  ##      "
    @sprite = Sprite.new
    @sprite.z = 250
    @sprite.bitmap = Bitmap.new(128, 128)
    @pattern_next = rand(7)
    @sprite_next = Sprite.new
    @sprite_next.x = 400
    @sprite_next.y = 64
    @sprite_next.z = 250
    @sprite_next.bitmap = Bitmap.new(128, 128)
    reset(true)
  end
  #--------------------------------------------------------------------------
  # ● リセット
  # flag = 初期化時フラグ
  #--------------------------------------------------------------------------
  def reset(flag = false)
    @pattern = @pattern_next
    set_pattern(@pattern * 4)
    @pattern_next = rand(7)
    @cx = 4
    @cy = TPUZZLE::FIELD_TOP
    @x = cx * 32
    @y = cy * 32
    @sprite.x = @x + (544 - TPUZZLE::FIELD_WIDTH * 32) / 2 - 32
    @sprite.y = @y + (416 - TPUZZLE::FIELD_HEIGHT * 32)
    @sprite.visible = true
    @state = 0
    @time = 0
    @rotate = 0
    draw
    draw_next
    unless flag
      if $scene.stage.hit?(@cx, @cy, $scene.block)
        $scene.game_end = true
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● ブロック描画
  #--------------------------------------------------------------------------
  def draw
    @sprite.bitmap.clear
    bitmap_monster = Cache.character("Monster")
    rect = Rect.new(192, 0, 32, 32)
    for i in 0...@width
      for j in 0...@height
        if get(i, j) == "#"
          @sprite.bitmap.blt(i * 32, j * 32, bitmap_monster, rect)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 次のブロック描画
  #--------------------------------------------------------------------------
  def draw_next
    @sprite_next.bitmap.clear
    bitmap_monster = Cache.character("Monster")
    rect = Rect.new(192, 0, 32, 32)
    for i in 0...@width * @height
      if @block_pattern[@pattern_next * 4][i, 1] == "#"
        @sprite_next.bitmap.blt(i % 4 * 32, i / 4 * 32, bitmap_monster, rect)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 終了処理
  #--------------------------------------------------------------------------
  def dispose
    super
    @sprite.dispose
    @sprite_next.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    case @state
    when 0
      update_input
    when 1
      update_ground
    when 2
      update_erase
    when 3
      update_pop
    end
  end
  #--------------------------------------------------------------------------
  # ● 入力状態の更新
  #--------------------------------------------------------------------------
  def update_input
    if @time > 0
      @time -= 1
      if @time == 0
        if $scene.stage.hit?(@cx, @cy + 1, $scene.block)
          $scene.stage.add(@cx, @cy, $scene.block)
          @sprite.visible = false
          @state = 1
          Audio.se_play("Audio/SE/Cursor.ogg", 80, 100)
        end
      end
    else
      @y += (Input.press?(Input::DOWN) ? 5 : 1)
      @cy = @y / 32
      if $scene.stage.hit?(@cx, @cy + 1, $scene.block)
        @time = 20
        @y = @cy * 32
      end
    end
    if @x == @cx * 32
      test_y = (@y % 32 >= 16 ? 1 : 0)
      if Input.press?(Input::LEFT)
        unless $scene.stage.hit?(@cx - 1, @cy + test_y, $scene.block)
          @cx -= 1
        end
      elsif Input.press?(Input::RIGHT)
        unless $scene.stage.hit?(@cx + 1, @cy + test_y, $scene.block)
          @cx += 1
        end
      end
    end
    @x += 4 if @x < @cx * 32
    @x -= 4 if @x > @cx * 32
    @sprite.x = @x + (544 - TPUZZLE::FIELD_WIDTH * 32) / 2 - 32
    @sprite.y = @y + (416 - TPUZZLE::FIELD_HEIGHT * 32)
    rotate(-1) if Input.trigger?(Input::C)
    rotate(1) if Input.trigger?(Input::B)
  end
  #--------------------------------------------------------------------------
  # ● 着地状態の更新
  #--------------------------------------------------------------------------
  def update_ground
    @state = 3
    n = 0  # 消去する段数
    for i in TPUZZLE::FIELD_TOP..TPUZZLE::FIELD_BOTTOM
      for j in TPUZZLE::FIELD_LEFT..TPUZZLE::FIELD_RIGHT
        break if $scene.stage.get(j, i) == " "
        if j == TPUZZLE::FIELD_RIGHT
          for k in TPUZZLE::FIELD_LEFT..TPUZZLE::FIELD_RIGHT
            $scene.stage.set(k, i, "+")
          end
          @state = 2
          @time = 0
          n += 1
        end
      end
    end
    if n > 0
      $scene.score += n * n * 50
      Audio.se_play("Audio/SE/Absorb1.ogg", 80, 100)
      Audio.se_play("Audio/SE/Applause.ogg", 80, 100) if n == 4
    end
  end
  #--------------------------------------------------------------------------
  # ● 消去状態の更新
  #--------------------------------------------------------------------------
  def update_erase
    @time += 1
    if @time == 16
      for i in TPUZZLE::FIELD_TOP..TPUZZLE::FIELD_BOTTOM
        if $scene.stage.get(1, i) == "+"
          y = i
          while(y >= TPUZZLE::FIELD_TOP)
            for j in TPUZZLE::FIELD_LEFT..TPUZZLE::FIELD_RIGHT
              $scene.stage.set(j, y, $scene.stage.get(j, y - 1))
            end
            y -= 1
          end
        end
      end
      @state = 3
    end
  end
  #--------------------------------------------------------------------------
  # ● 再出現状態の更新
  #--------------------------------------------------------------------------
  def update_pop
    reset
  end
  #--------------------------------------------------------------------------
  # ● 回転処理
  #--------------------------------------------------------------------------
  def rotate(n)
    last_rotate = @rotate
    @rotate += n
    @rotate = 3 if @rotate < 0
    @rotate = 0 if @rotate > 3
    set_pattern(@pattern * 4 + @rotate)
    if $scene.stage.hit?(@cx, @cy, $scene.block)
      @rotate = last_rotate
      set_pattern(@pattern * 4 + @rotate)
      Audio.se_play("Audio/SE/Buzzer1.ogg", 80, 100)
    else
      Audio.se_play("Audio/SE/Evasion.ogg", 80, 100)
      draw
    end
  end
  #--------------------------------------------------------------------------
  # ● パターンの変更
  #--------------------------------------------------------------------------
  def set_pattern(pattern)
    for i in 0...@width * @height
      @cell[i] = @block_pattern[pattern][i, 1]
    end
  end
end
Código:

#==============================================================================
# ■ TPuzzle_Cell
#------------------------------------------------------------------------------
#  落ち物パズルのセルクラス
#==============================================================================
class TPuzzle_Cell
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :x
  attr_reader :y
  attr_reader :width
  attr_reader :height
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(width = 4, height = 4)
    @x = 0
    @y = 0
    @width = width
    @height = height
    @cell = Array.new(@width * @height)
    for i in [Tienes que estar registrado y conectado para ver este vínculo] do @cell[i] = " " end
  end
  #--------------------------------------------------------------------------
  # ● 終了処理
  #--------------------------------------------------------------------------
  def dispose
    @cell = nil
  end
  #--------------------------------------------------------------------------
  # ● セルの値を取得
  #--------------------------------------------------------------------------
  def get(x, y)
    return @cell[x + @width * y]
  end
  #--------------------------------------------------------------------------
  # ● セルに値をセット
  #--------------------------------------------------------------------------
  def set(x, y, value)
    @cell[x + @width * y] = value
  end
  #--------------------------------------------------------------------------
  # ● セルとセルとの当たり判定
  #--------------------------------------------------------------------------
  def hit?(x, y, cell)
    for i in 0...cell.width
      for j in 0...cell.height
        if cell.get(i, j) != " " and get(i + x, j + y) != " "
          return true
        end
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ● セルとセルの合成
  #--------------------------------------------------------------------------
  def add(x, y, cell)
    for i in 0...cell.width
      for j in 0...cell.height
        if cell.get(i, j) != " "
          set(i + x, j + y, cell.get(i, j))
        end
      end
    end
  end
end
Linksen
Linksen
300
300

Masculino

Edad 30

Cantidad de envíos 306

Maker Cash 1769

Reputación 23


Extras
Sobre mí::

Volver arriba Ir abajo

Volver arriba

- Temas similares

 
Permisos de este foro:
No puedes responder a temas en este foro.