活宝 发表于 2010-1-21 11:46:49

[模拟][2D]小霸王系统演示之俄罗斯方块

v1.4c更新
背景音乐更新为经典的三套车(总算找到了)和喀秋莎

v1.4b更新
再次更新了方块式样。


v1.4更新

v1.3更新
改进控制系统。
修改背景显示。
隐藏鼠标指针。

v1.2更新
修正方块着陆后变形会导致方块着陆不正确的BUG。(感谢Peppers大人)

v1.1更新
增加计分规则,每着陆一个方块加一分。

更新
更正地图描述中的错别字。
英文版完成(Wc3c)。

更新
根据actboy168大人的提示制作了彩虹版,现在七种方块有七种颜色了。




前言
    前几天看到了头目的点阵动画《Bad Apple》之后不禁心潮澎湃,激动得几夜没合眼。那段时间我一直在想,War3除了可以播放动画,还可以做什么呢?想来又想去,终于想到了——原来除了播放动画以外,还可以用War3玩游戏!

    于是我就开始着手这方面的研究,说到游戏,头脑中就冒出很多经典的名字,像俄罗斯方块,超级马里奥,坦克大战,B计划,宇宙巡航机等等。但是要做什么好呢?仔细想了想,发现还是俄罗斯方块比较合适。首先俄罗斯方块对画面的要求不高,黑白彩色都可以,分辨率只要足够显示方块即可,而像超级马里奥那样的游戏非得是彩色高分辨率不可,然而考虑到我的小霸王机能有限,连播放烂苹果都一顿一顿的,所以还是玩俄罗斯方块吧;其次俄罗斯方块系统比较简单,适合我这样的Jass新手,而且参考资料也多,遇到困难容易解决;最后俄罗斯方块的操作也简单,只需4个健就够了,而超级马里奥的话如果不用手柄会比较难控制(至少对于我这样的低手而言)。于是最终就决定制作俄罗斯方块了。

    经过一个星期断断续续的奋斗,终于制作完成了。
   

说明
左上角显示下一个方块,右上角显示当前等级,右下角显示分数
在对话框中输入大写的"START"可以开始新游戏
方向键控制方块
计分规则:
Single=100
Double=400
Triple=900
Tetris=1600





系统界面
游戏开始!
ummm...好机会!
Tetris! Haha,一下就升级了
ummm...又一个好机会!
升入第三级感觉难度明显增加
呜呜~~~game over...
我最多就打到过Level 5.

注记
游戏中音效来自于NES,著作权归原作者所有。
2D图形引擎部分改编自头目的烂苹果。
我刚学会Jass没多久,水平有限,做得比较简陋还请见谅。
请把图像设置中的纹理质量设为“高”,为了正确地显示背景……

reference:
realsy. 俄罗斯方块C语言版
benpaodelvzi. 俄罗斯方块Java版


воздать должное великому сестра Рени!Слава Ringleader,Аллилуйя, аминь...





活宝 发表于 2010-1-21 11:52:29

源代码

//===========================================================================
//
// WAR3小霸王系列之俄罗斯方块
//
//   Warcraft III map script
//   Generated by the Warcraft III World Editor
//   Date: Thu Jan 21 10:39:32 2010
//   Map Author: 活宝
//
//===========================================================================

//***************************************************************************
//*
//*Global Variables
//*
//***************************************************************************

globals
    // User-defined
    hashtable               udg_AS                     = null
    hashtable               udg_NS                     = null
    hashtable               udg_GS                     = null
    hashtable               udg_IF                     = null
    hashtable               udg_BG                     = null
    hashtable               udg_FP                     = null
    integer               udg_iLarge               = 0
    integer               udg_iCol                   = 0
    boolean               udg_isBottom               = false
    integer               udg_currentRect            = 0
    integer               udg_iLevel               = 0
    integer               udg_iPerformance         = 0
    integer               udg_icurrentStatus         = 0
    integer               udg_inextStatus            = 0
    integer               udg_iStartX                = 0
    boolean               udg_bGameEnd               = false
    integer               udg_iStartY                = 0
    boolean               udg_bGamePaush             = false
    boolean               udg_bMusic               = false
    boolean               udg_bDrawGrid            = false
    integer               udg_iRow                   = 0
    timer                   udg_GTimer               = null
    timer                   udg_LTimer               = null
    timer                   udg_RTimer               = null
    timer                   udg_DTimer               = null
    timer                   udg_Delay                  = null
    unit                  udg_CenterUnit             = null
    real                  udg_LevelTime            = 0
    hashtable               udg_LS                     = null
    hashtable               udg_PS                     = null
    hashtable               udg_SS                     = null
    hashtable               udg_NP                     = null
    hashtable               udg_LP                     = null
    hashtable               udg_SP                     = null
    hashtable               udg_NGS                  = null
    boolean array         udg_bS
    timer                   udg_Flash                  = null
    boolean               udg_bloop                  = false
    integer               udg_k                      = 0
    integer array         udg_UpScore
    boolean               udg_Up                     = false
    integer               udg_Value                  = 0
    boolean               udg_bFlash               = false
    boolean               udg_bABrun               = false

    // Generated
    camerasetup             gg_cam_center            = null
    sound                   gg_snd_change            = null
    sound                   gg_snd_down                = null
    sound                   gg_snd_move                = null
    sound                   gg_snd_levelup             = null
    sound                   gg_snd_bottom            = null
    sound                   gg_snd_bang                = null
    sound                   gg_snd_gameover            = null
    string                  gg_snd_russia
    sound                   gg_snd_LittleKing          = null
    sound                   gg_snd_deblock             = null
    sound                   gg_snd_tetris            = null
    string                  gg_snd_BWing
    trigger               gg_trg________________u    = null
    trigger               gg_trg_OnKeyLeft         = null
    trigger               gg_trg_OffKeyLeft          = null
    trigger               gg_trg_left                = null
    trigger               gg_trg_OnKeyRight          = null
    trigger               gg_trg_OffKeRight          = null
    trigger               gg_trg_right               = null
    trigger               gg_trg_OnKeyDown         = null
    trigger               gg_trg_OffKeDown         = null
    trigger               gg_trg_down                = null
    trigger               gg_trg_OnKeyUp             = null
    trigger               gg_trg_OffKeUp             = null
    trigger               gg_trg_GameStart         = null
    trigger               gg_trg_OnTimer             = null
    unit                  gg_unit_e001_0002          = null
    sound                   gg_snd_bigin               = null
endglobals

function InitGlobals takes nothing returns nothing
    local integer i = 0
    set udg_iLarge = 60
    set udg_iCol = 10
    set udg_isBottom = true
    set udg_currentRect = 2
    set udg_iLevel = 0
    set udg_iPerformance = 0
    set udg_icurrentStatus = 2
    set udg_inextStatus = 2
    set udg_iStartX = 0
    set udg_bGameEnd = false
    set udg_iStartY = 0
    set udg_bGamePaush = false
    set udg_bMusic = false
    set udg_bDrawGrid = false
    set udg_iRow = 20
    set udg_GTimer = CreateTimer()
    set udg_LTimer = CreateTimer()
    set udg_RTimer = CreateTimer()
    set udg_DTimer = CreateTimer()
    set udg_Delay = CreateTimer()
    set udg_LevelTime = 1.00
    set i = 0
    loop
      exitwhen (i > 100)
      set udg_bS = false
      set i = i + 1
    endloop

    set udg_Flash = CreateTimer()
    set udg_bloop = false
    set udg_k = 0
    set i = 0
    loop
      exitwhen (i > 11)
      set udg_UpScore = 0
      set i = i + 1
    endloop

    set udg_Up = false
    set udg_Value = 100
    set udg_bFlash = false
    set udg_bABrun = false
endfunction

//***************************************************************************
//*
//*Sounds
//*
//***************************************************************************

function InitSounds takes nothing returns nothing
    set gg_snd_change = CreateSound( "war3mapImported\\\\change.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_change, 345 )
    call SetSoundChannel( gg_snd_change, 0 )
    call SetSoundVolume( gg_snd_change, 127 )
    call SetSoundPitch( gg_snd_change, 1.0 )
    set gg_snd_down = CreateSound( "war3mapImported\\\\down.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_down, 1000 )
    call SetSoundChannel( gg_snd_down, 0 )
    call SetSoundVolume( gg_snd_down, 127 )
    call SetSoundPitch( gg_snd_down, 1.0 )
    set gg_snd_move = CreateSound( "war3mapImported\\\\move.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_move, 135 )
    call SetSoundChannel( gg_snd_move, 0 )
    call SetSoundVolume( gg_snd_move, 127 )
    call SetSoundPitch( gg_snd_move, 1.0 )
    set gg_snd_levelup = CreateSound( "war3mapImported\\\\levelup.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_levelup, 934 )
    call SetSoundChannel( gg_snd_levelup, 0 )
    call SetSoundVolume( gg_snd_levelup, 127 )
    call SetSoundPitch( gg_snd_levelup, 1.0 )
    set gg_snd_bottom = CreateSound( "war3mapImported\\\\bottom.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_bottom, 253 )
    call SetSoundChannel( gg_snd_bottom, 0 )
    call SetSoundVolume( gg_snd_bottom, 127 )
    call SetSoundPitch( gg_snd_bottom, 1.0 )
    set gg_snd_bang = CreateSound( "war3mapImported\\\\bang.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_bang, 978 )
    call SetSoundChannel( gg_snd_bang, 0 )
    call SetSoundVolume( gg_snd_bang, 127 )
    call SetSoundPitch( gg_snd_bang, 1.0 )
    set gg_snd_gameover = CreateSound( "war3mapImported\\\\gameover.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_gameover, 6498 )
    call SetSoundChannel( gg_snd_gameover, 0 )
    call SetSoundVolume( gg_snd_gameover, 127 )
    call SetSoundPitch( gg_snd_gameover, 1.0 )
    set gg_snd_russia = "war3mapImported\\\\russia.mp3"
    set gg_snd_LittleKing = CreateSound( "war3mapImported\\\\LittleKing.mp3", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_LittleKing, 3200 )
    call SetSoundChannel( gg_snd_LittleKing, 0 )
    call SetSoundVolume( gg_snd_LittleKing, 127 )
    call SetSoundPitch( gg_snd_LittleKing, 1.0 )
    set gg_snd_deblock = CreateSound( "war3mapImported\\\\deblock.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_deblock, 1520 )
    call SetSoundChannel( gg_snd_deblock, 0 )
    call SetSoundVolume( gg_snd_deblock, 127 )
    call SetSoundPitch( gg_snd_deblock, 1.0 )
    set gg_snd_tetris = CreateSound( "war3mapImported\\\\tetris.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_tetris, 1965 )
    call SetSoundChannel( gg_snd_tetris, 0 )
    call SetSoundVolume( gg_snd_tetris, 127 )
    call SetSoundPitch( gg_snd_tetris, 1.0 )
    set gg_snd_BWing = "war3mapImported\\\\BWing.mp3"
    set gg_snd_bigin = CreateSound( "war3mapImported\\\\bigin.wav", false, false, false, 10, 10, "" )
    call SetSoundDuration( gg_snd_bigin, 4192 )
    call SetSoundChannel( gg_snd_bigin, 0 )
    call SetSoundVolume( gg_snd_bigin, 127 )
    call SetSoundPitch( gg_snd_bigin, 1.0 )
endfunction

//***************************************************************************
//*
//*Unit Creation
//*
//***************************************************************************

//===========================================================================
function CreateUnitsForPlayer6 takes nothing returns nothing
    local player p = Player(6)
    local unit u
    local integer unitID
    local trigger t
    local real life

    set gg_unit_e001_0002 = CreateUnit( p, 'e001', -7.0, -0.2, 125.160 )
endfunction

//===========================================================================
function CreatePlayerBuildings takes nothing returns nothing
endfunction

//===========================================================================
function CreatePlayerUnits takes nothing returns nothing
    call CreateUnitsForPlayer6()
endfunction

//===========================================================================
function CreateAllUnits takes nothing returns nothing
    call CreatePlayerBuildings()
    call CreatePlayerUnits()
endfunction

//***************************************************************************
//*
//*Cameras
//*
//***************************************************************************

function CreateCameras takes nothing returns nothing

    set gg_cam_center = CreateCameraSetup()
    call CameraSetupSetField( gg_cam_center, CAMERA_FIELD_ZOFFSET, 0.0, 0.0 )
    call CameraSetupSetField( gg_cam_center, CAMERA_FIELD_ROTATION, 90.0, 0.0 )
    call CameraSetupSetField( gg_cam_center, CAMERA_FIELD_ANGLE_OF_ATTACK, 270.0, 0.0 )
    call CameraSetupSetField( gg_cam_center, CAMERA_FIELD_TARGET_DISTANCE, 1650.0, 0.0 )
    call CameraSetupSetField( gg_cam_center, CAMERA_FIELD_ROLL, 0.0, 0.0 )
    call CameraSetupSetField( gg_cam_center, CAMERA_FIELD_FIELD_OF_VIEW, 70.0, 0.0 )
    call CameraSetupSetField( gg_cam_center, CAMERA_FIELD_FARZ, 5000.0, 0.0 )
    call CameraSetupSetDestPosition( gg_cam_center, 0.0, 0.0, 0.0 )

endfunction


//***************************************************************************
//*
//*Custom Script Code
//*
//***************************************************************************
function CHWRECTView takes nothing returns nothing
    local integer i
    local integer j
   
    //总分值清零
    set udg_iPerformance = 0
   
    //测试值:为20行,10列
    set udg_iRow = 20
    set udg_iCol = 10
   
   
   
    //缺省级别为1级
    set udg_iLevel = 1
   
    //缺省方块大小为udg_iLarge个象素
    set udg_iLarge = 40
   
    //缺省游戏是结束的
    set udg_bGameEnd = TRUE
   
    set udg_AS=InitHashtable()
    set udg_GS=InitHashtable()
    set udg_NS=InitHashtable()
    set udg_NGS=InitHashtable()
    set udg_LS=InitHashtable()
    set udg_PS=InitHashtable()
    set udg_SS=InitHashtable()
    set udg_IF=InitHashtable()
    set udg_FP=InitHashtable()
    set udg_NP=InitHashtable()
    set udg_SP=InitHashtable()
    set udg_LP=InitHashtable()
    set udg_BG=InitHashtable()
   
   
   
    set i=0
    //赋初值
    loop
      exitwhen(i>=100)
      set j=0
      loop
            exitwhen (j>=100)
            call SaveInteger(udg_GS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
    //赋初值
    loop
      exitwhen(i>=4)
      set j=0
      loop
            exitwhen (j>=4)
            call SaveInteger(udg_NGS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
    //赋初值
    loop
      exitwhen(i>=5)
      set j=0
      loop
            exitwhen (j>=3)
            call SaveInteger(udg_LS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
    //赋初值
    loop
      exitwhen(i>=5)
      set j=0
      loop
            exitwhen (j>=15)
            call SaveInteger(udg_SS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
   
    //各种形状方块的接触面数据,参见设计书的接触面表格, 如果某种形状的方块没有4个接触面,则后面的数据填-1
    set i=0
    loop
      exitwhen i>=74
      set j=0
      
      loop
            exitwhen j>=4
            call SaveInteger(udg_IF,i,j,-1)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=1
    loop
      exitwhen i>=10
      set udg_UpScore=1000*(i-1)*(i-1)
      set i=i+1
    endloop
    set udg_UpScore=1000000
   
    call SaveInteger(udg_IF,1,0,3)
    call SaveInteger(udg_IF,11,0,0)
    call SaveInteger(udg_IF,11,1,1)
    call SaveInteger(udg_IF,11,2,2)
    call SaveInteger(udg_IF,11,3,3)
    call SaveInteger(udg_IF,2,0,1)
    call SaveInteger(udg_IF,2,1,3)
    call SaveInteger(udg_IF,3,0,0)
    call SaveInteger(udg_IF,3,1,2)
    call SaveInteger(udg_IF,3,2,3)
    call SaveInteger(udg_IF,31,0,2)
    call SaveInteger(udg_IF,31,1,3)
    call SaveInteger(udg_IF,32,0,0)
    call SaveInteger(udg_IF,32,1,2)
    call SaveInteger(udg_IF,32,2,3)
    call SaveInteger(udg_IF,33,0,0)
    call SaveInteger(udg_IF,33,1,3)
    call SaveInteger(udg_IF,4,0,1)
    call SaveInteger(udg_IF,4,1,3)
    call SaveInteger(udg_IF,41,0,0)
    call SaveInteger(udg_IF,41,1,2)
    call SaveInteger(udg_IF,41,2,3)
    call SaveInteger(udg_IF,5,0,1)
    call SaveInteger(udg_IF,5,1,3)
    call SaveInteger(udg_IF,51,0,0)
    call SaveInteger(udg_IF,51,1,2)
    call SaveInteger(udg_IF,51,2,3)
    call SaveInteger(udg_IF,6,0,0)
    call SaveInteger(udg_IF,6,1,3)
    call SaveInteger(udg_IF,61,0,1)
    call SaveInteger(udg_IF,61,1,2)
    call SaveInteger(udg_IF,61,2,3)
    call SaveInteger(udg_IF,62,0,2)
    call SaveInteger(udg_IF,62,1,3)
    call SaveInteger(udg_IF,63,0,0)
    call SaveInteger(udg_IF,63,1,1)
    call SaveInteger(udg_IF,63,2,3)
    call SaveInteger(udg_IF,7,0,2)
    call SaveInteger(udg_IF,7,1,3)
    call SaveInteger(udg_IF,71,0,1)
    call SaveInteger(udg_IF,71,1,2)
    call SaveInteger(udg_IF,71,2,3)
    call SaveInteger(udg_IF,72,0,0)
    call SaveInteger(udg_IF,72,1,3)
    call SaveInteger(udg_IF,73,0,0)
    call SaveInteger(udg_IF,73,1,1)
    call SaveInteger(udg_IF,73,2,3)
endfunction

function S2Wx takes integer y, real x0 returns real
    local real wx
    set wx=x0+y*udg_iLarge
   
    return wx
endfunction
function S2Wy takes integer x, real y0 returns real
    local real wy
    set wy=y0-x*udg_iLarge
   
    return wy
endfunction

function InitDraw0 takes nothing returns nothing
    local image bg
    local real x0
    local real y0
    local real x00
    local real y00
    set bg=CreateImage("bg.tga",2000,2000,0,-1000,-1000,0,0,0,0,4)
    call SetImageRenderAlways(bg,true)
    call SaveImageHandle(udg_BG,0,0,bg)
    set x00=(-udg_iCol/2)*udg_iLarge
    set y00=(udg_iRow/2-1)*udg_iLarge
    set x0=S2Wx(-17,x00)
    set y0=S2Wy(21,y00)
    set bg=CreateImage("logo.tga",400,400,0,x0,y0,0,0,0,0,3)
    call SetImageRenderAlways(bg,true)
    call SaveImageHandle(udg_BG,0,1,bg)
    set bg=null
    //return
endfunction

function InitDraw takes nothing returns nothing
    local integer i
    local integer in
    local integer j
    local integer jn
    local real x
    local real y
    local real x00
    local real y00
    local real x0
    local real y0
    local image fp
   
   
    set x00=(-udg_iCol/2)*udg_iLarge
    set y00=(udg_iRow/2-1)*udg_iLarge
    set x0=x00
    set y0=y00
   
    set i=-1
    set in=udg_iRow
    loop
      exitwhen i>in
      set j=-1
      set jn=udg_iCol
      loop
            exitwhen j>jn
            set x= S2Wx(j,x0)
            set y= S2Wy(i,y0)
            
            //set bg=CreateImage("bg.tga",udg_iLarge,udg_iLarge,0,x,y,0,0,0,0,4)
            set fp=CreateImage("fp.tga",udg_iLarge,udg_iLarge,0,x,y,0,0,0,0,2)
            //call SetImageRenderAlways(bg,true)
            call SetImageRenderAlways(fp,true)
            //call SaveImageHandle(udg_BG,i,j,bg)
            call SaveImageHandle(udg_FP,i,j,fp)
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
    set in=udg_iRow-1
    loop
      exitwhen i>in
      set j=0
      set jn=udg_iCol-1
      loop
            exitwhen j>jn
            
            
            set fp=LoadImageHandle(udg_FP,i,j)
            call SetImageColor(fp,255,255,0,255)
            call ShowImage(fp,false)
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
   
    set x0=S2Wx(-7,x00)
    set y0=S2Wy(0,y00)
   
    set i=-1
    set in=4
    loop
      exitwhen i>in
      set j=0
      set jn=3
      loop
            exitwhen j>jn
            set x= S2Wx(j,x0)
            set y= S2Wy(i,y0)
            
            
            set fp=CreateImage("fp.tga",udg_iLarge,udg_iLarge,0,x,y,0,0,0,0,2)
            call SetImageRenderAlways(fp,true)
            call SaveImageHandle(udg_NP,i,j,fp)
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
    set in=3
    loop
      exitwhen i>in
      set j=0
      set jn=3
      loop
            exitwhen j>jn
            
            
            set fp=LoadImageHandle(udg_NP,i,j)
            call SetImageColor(fp,255,255,0,255)
            call ShowImage(fp,false)
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
   
   
   
   
   
    set fp=null
   
   
    //return
endfunction

function InitDraw2 takes nothing returns nothing
    local integer i
    local integer in
    local integer j
    local integer jn
    local real x
    local real y
    local real x00
    local real y00
    local real x0
    local real y0
    local image fp
    set x00=(-udg_iCol/2)*udg_iLarge
    set y00=(udg_iRow/2-1)*udg_iLarge
    set x0=S2Wx(12,x00)
    set y0=S2Wy(0,y00)
   
    set i=-1
    set in=5
    loop
      exitwhen i>in
      set j=0
      set jn=2
      loop
            exitwhen j>jn
            set x= S2Wx(j,x0)
            set y= S2Wy(i,y0)
            
            
            set fp=CreateImage("fp.tga",udg_iLarge,udg_iLarge,0,x,y,0,0,0,0,2)
            call SetImageRenderAlways(fp,true)
            call SaveImageHandle(udg_LP,i,j,fp)
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
    set in=4
    loop
      exitwhen i>in
      set j=0
      set jn=2
      loop
            exitwhen j>jn
            
            
            set fp=LoadImageHandle(udg_LP,i,j)
            call SetImageColor(fp,255,0,0,255)
            call ShowImage(fp,false)
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set x0=S2Wx(12,x00)
    set y0=S2Wy(15,y00)
   
    set i=-1
    set in=5
    loop
      exitwhen i>in
      set j=0
      set jn=14
      loop
            exitwhen j>jn
            set x= S2Wx(j,x0)
            set y= S2Wy(i,y0)
            
            
            set fp=CreateImage("fp.tga",udg_iLarge,udg_iLarge,0,x,y,0,0,0,0,2)
            call SetImageRenderAlways(fp,true)
            call SaveImageHandle(udg_SP,i,j,fp)
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
    set in=4
    loop
      exitwhen i>in
      set j=0
      set jn=14
      loop
            exitwhen j>jn
            
            
            set fp=LoadImageHandle(udg_SP,i,j)
            call SetImageColor(fp,0,255,0,255)
            call ShowImage(fp,false)
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set fp=null
    //return
endfunction



function ActiveStatusToGameStatus takes nothing returns nothing
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
   
   
    set x1 = LoadInteger(udg_AS,0,0)
    set x2 = LoadInteger(udg_AS,1,0)
    set x3 = LoadInteger(udg_AS,2,0)
    set x4 = LoadInteger(udg_AS,3,0)
    set y1 = LoadInteger(udg_AS,0,1)
    set y2 = LoadInteger(udg_AS,1,1)
    set y3 = LoadInteger(udg_AS,2,1)
    set y4 = LoadInteger(udg_AS,3,1)
    call SaveInteger(udg_GS,x1,y1,1)
    call SaveInteger(udg_GS,x2,y2,1)
    call SaveInteger(udg_GS,x3,y3,1)
    call SaveInteger(udg_GS,x4,y4,1)
endfunction
function NextStatusToGameNextStatus takes nothing returns nothing
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    local integeri
    local integerj
   
    set i=0
    //赋初值
    loop
      exitwhen(i>=4)
      set j=0
      loop
            exitwhen (j>=4)
            call SaveInteger(udg_NGS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
   
    set x1 = LoadInteger(udg_NS,0,0)
    set x2 = LoadInteger(udg_NS,1,0)
    set x3 = LoadInteger(udg_NS,2,0)
    set x4 = LoadInteger(udg_NS,3,0)
    set y1 = LoadInteger(udg_NS,0,1)
    set y2 = LoadInteger(udg_NS,1,1)
    set y3 = LoadInteger(udg_NS,2,1)
    set y4 = LoadInteger(udg_NS,3,1)
    call SaveInteger(udg_NGS,x1,y1,1)
    call SaveInteger(udg_NGS,x2,y2,1)
    call SaveInteger(udg_NGS,x3,y3,1)
    call SaveInteger(udg_NGS,x4,y4,1)
endfunction
function RectStatusToActiveStatus takes integer udg_which returns nothing
   
    if(udg_which==1) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,1)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,2)
      call SaveInteger(udg_AS,2,1,5)
      call SaveInteger(udg_AS,3,0,3)
      call SaveInteger(udg_AS,3,1,5)
    endif
    if(udg_which==2) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,1)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,0)
      call SaveInteger(udg_AS,2,1,6)
      call SaveInteger(udg_AS,3,0,1)
      call SaveInteger(udg_AS,3,1,6)
    endif
    if(udg_which==3) then
      call SaveInteger(udg_AS,0,0,1)
      call SaveInteger(udg_AS,0,1,4)
      call SaveInteger(udg_AS,1,0,0)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,1)
      call SaveInteger(udg_AS,2,1,5)
      call SaveInteger(udg_AS,3,0,1)
      call SaveInteger(udg_AS,3,1,6)
    endif
    if(udg_which==4) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,1)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,1)
      call SaveInteger(udg_AS,2,1,6)
      call SaveInteger(udg_AS,3,0,2)
      call SaveInteger(udg_AS,3,1,6)
    endif
    if(udg_which==5) then
      call SaveInteger(udg_AS,0,0,1)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,2)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,0)
      call SaveInteger(udg_AS,2,1,6)
      call SaveInteger(udg_AS,3,0,1)
      call SaveInteger(udg_AS,3,1,6)
    endif
    if(udg_which==6) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,0)
      call SaveInteger(udg_AS,1,1,6)
      call SaveInteger(udg_AS,2,0,1)
      call SaveInteger(udg_AS,2,1,6)
      call SaveInteger(udg_AS,3,0,2)
      call SaveInteger(udg_AS,3,1,6)
    endif
    if(udg_which==7) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,1)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,2)
      call SaveInteger(udg_AS,2,1,5)
      call SaveInteger(udg_AS,3,0,0)
      call SaveInteger(udg_AS,3,1,6)
    endif
endfunction
function RectStatusToNextStatus takes integer udg_which returns nothing
   
    if(udg_which==1) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,1)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,2)
      call SaveInteger(udg_NS,2,1,1)
      call SaveInteger(udg_NS,3,0,3)
      call SaveInteger(udg_NS,3,1,1)
    endif
    if(udg_which==2) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,1)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,0)
      call SaveInteger(udg_NS,2,1,2)
      call SaveInteger(udg_NS,3,0,1)
      call SaveInteger(udg_NS,3,1,2)
    endif
    if(udg_which==3) then
      call SaveInteger(udg_NS,0,0,1)
      call SaveInteger(udg_NS,0,1,0)
      call SaveInteger(udg_NS,1,0,0)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,1)
      call SaveInteger(udg_NS,2,1,1)
      call SaveInteger(udg_NS,3,0,1)
      call SaveInteger(udg_NS,3,1,2)
    endif
    if(udg_which==4) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,1)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,1)
      call SaveInteger(udg_NS,2,1,2)
      call SaveInteger(udg_NS,3,0,2)
      call SaveInteger(udg_NS,3,1,2)
    endif
    if(udg_which==5) then
      call SaveInteger(udg_NS,0,0,1)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,2)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,0)
      call SaveInteger(udg_NS,2,1,2)
      call SaveInteger(udg_NS,3,0,1)
      call SaveInteger(udg_NS,3,1,2)
    endif
    if(udg_which==6) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,0)
      call SaveInteger(udg_NS,1,1,2)
      call SaveInteger(udg_NS,2,0,1)
      call SaveInteger(udg_NS,2,1,2)
      call SaveInteger(udg_NS,3,0,2)
      call SaveInteger(udg_NS,3,1,2)
    endif
    if(udg_which==7) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,1)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,2)
      call SaveInteger(udg_NS,2,1,1)
      call SaveInteger(udg_NS,3,0,0)
      call SaveInteger(udg_NS,3,1,2)
    endif
endfunction

function LevelCheck takes integer score returns integer
    local integer level=1
    local integer i
    set i=2
    loop
      exitwhen i>=10
      if (score>=udg_UpScore) then
            set level=level+1
      endif
      set i=i+1
    endloop
   
    return level
endfunction


function PrintNumS takes integer x,integer y,integer numreturns nothing
   
    if (num==0) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,1)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,1)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,1)
      call SaveInteger(udg_SS,x+2,y+0,1)
      call SaveInteger(udg_SS,x+2,y+1,0)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,1)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,1)
      call SaveInteger(udg_SS,x+4,y+1,1)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==1) then
      call SaveInteger(udg_SS,x+0,y+0,0)
      call SaveInteger(udg_SS,x+0,y+1,0)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,0)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,1)
      call SaveInteger(udg_SS,x+2,y+0,0)
      call SaveInteger(udg_SS,x+2,y+1,0)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,0)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,0)
      call SaveInteger(udg_SS,x+4,y+1,0)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==2) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,1)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,0)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,1)
      call SaveInteger(udg_SS,x+2,y+0,1)
      call SaveInteger(udg_SS,x+2,y+1,1)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,1)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,0)
      call SaveInteger(udg_SS,x+4,y+0,1)
      call SaveInteger(udg_SS,x+4,y+1,1)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==3) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,1)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,0)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,1)
      call SaveInteger(udg_SS,x+2,y+0,1)
      call SaveInteger(udg_SS,x+2,y+1,1)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,0)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,1)
      call SaveInteger(udg_SS,x+4,y+1,1)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==4) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,0)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,1)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,1)
      call SaveInteger(udg_SS,x+2,y+0,1)
      call SaveInteger(udg_SS,x+2,y+1,1)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,0)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,0)
      call SaveInteger(udg_SS,x+4,y+1,0)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==5) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,1)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,1)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,0)
      call SaveInteger(udg_SS,x+2,y+0,1)
      call SaveInteger(udg_SS,x+2,y+1,1)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,0)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,1)
      call SaveInteger(udg_SS,x+4,y+1,1)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==6) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,1)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,1)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,0)
      call SaveInteger(udg_SS,x+2,y+0,1)
      call SaveInteger(udg_SS,x+2,y+1,1)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,1)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,1)
      call SaveInteger(udg_SS,x+4,y+1,1)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==7) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,1)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,0)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,1)
      call SaveInteger(udg_SS,x+2,y+0,0)
      call SaveInteger(udg_SS,x+2,y+1,0)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,0)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,0)
      call SaveInteger(udg_SS,x+4,y+1,0)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==8) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,1)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,1)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,1)
      call SaveInteger(udg_SS,x+2,y+0,1)
      call SaveInteger(udg_SS,x+2,y+1,1)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,1)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,1)
      call SaveInteger(udg_SS,x+4,y+1,1)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
    if (num==9) then
      call SaveInteger(udg_SS,x+0,y+0,1)
      call SaveInteger(udg_SS,x+0,y+1,1)
      call SaveInteger(udg_SS,x+0,y+2,1)
      call SaveInteger(udg_SS,x+1,y+0,1)
      call SaveInteger(udg_SS,x+1,y+1,0)
      call SaveInteger(udg_SS,x+1,y+2,1)
      call SaveInteger(udg_SS,x+2,y+0,1)
      call SaveInteger(udg_SS,x+2,y+1,1)
      call SaveInteger(udg_SS,x+2,y+2,1)
      call SaveInteger(udg_SS,x+3,y+0,0)
      call SaveInteger(udg_SS,x+3,y+1,0)
      call SaveInteger(udg_SS,x+3,y+2,1)
      call SaveInteger(udg_SS,x+4,y+0,1)
      call SaveInteger(udg_SS,x+4,y+1,1)
      call SaveInteger(udg_SS,x+4,y+2,1)
    endif
   
    //return
endfunction


function PrintNumL takes integer x,integer y,integer numreturns nothing
   
    if (num==0) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,1)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,1)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,1)
      call SaveInteger(udg_LS,x+2,y+0,1)
      call SaveInteger(udg_LS,x+2,y+1,0)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,1)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,1)
      call SaveInteger(udg_LS,x+4,y+1,1)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==1) then
      call SaveInteger(udg_LS,x+0,y+0,0)
      call SaveInteger(udg_LS,x+0,y+1,0)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,0)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,1)
      call SaveInteger(udg_LS,x+2,y+0,0)
      call SaveInteger(udg_LS,x+2,y+1,0)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,0)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,0)
      call SaveInteger(udg_LS,x+4,y+1,0)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==2) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,1)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,0)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,1)
      call SaveInteger(udg_LS,x+2,y+0,1)
      call SaveInteger(udg_LS,x+2,y+1,1)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,1)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,0)
      call SaveInteger(udg_LS,x+4,y+0,1)
      call SaveInteger(udg_LS,x+4,y+1,1)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==3) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,1)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,0)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,1)
      call SaveInteger(udg_LS,x+2,y+0,1)
      call SaveInteger(udg_LS,x+2,y+1,1)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,0)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,1)
      call SaveInteger(udg_LS,x+4,y+1,1)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==4) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,0)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,1)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,1)
      call SaveInteger(udg_LS,x+2,y+0,1)
      call SaveInteger(udg_LS,x+2,y+1,1)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,0)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,0)
      call SaveInteger(udg_LS,x+4,y+1,0)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==5) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,1)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,1)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,0)
      call SaveInteger(udg_LS,x+2,y+0,1)
      call SaveInteger(udg_LS,x+2,y+1,1)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,0)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,1)
      call SaveInteger(udg_LS,x+4,y+1,1)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==6) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,1)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,1)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,0)
      call SaveInteger(udg_LS,x+2,y+0,1)
      call SaveInteger(udg_LS,x+2,y+1,1)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,1)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,1)
      call SaveInteger(udg_LS,x+4,y+1,1)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==7) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,1)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,0)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,1)
      call SaveInteger(udg_LS,x+2,y+0,0)
      call SaveInteger(udg_LS,x+2,y+1,0)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,0)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,0)
      call SaveInteger(udg_LS,x+4,y+1,0)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==8) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,1)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,1)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,1)
      call SaveInteger(udg_LS,x+2,y+0,1)
      call SaveInteger(udg_LS,x+2,y+1,1)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,1)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,1)
      call SaveInteger(udg_LS,x+4,y+1,1)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
    if (num==9) then
      call SaveInteger(udg_LS,x+0,y+0,1)
      call SaveInteger(udg_LS,x+0,y+1,1)
      call SaveInteger(udg_LS,x+0,y+2,1)
      call SaveInteger(udg_LS,x+1,y+0,1)
      call SaveInteger(udg_LS,x+1,y+1,0)
      call SaveInteger(udg_LS,x+1,y+2,1)
      call SaveInteger(udg_LS,x+2,y+0,1)
      call SaveInteger(udg_LS,x+2,y+1,1)
      call SaveInteger(udg_LS,x+2,y+2,1)
      call SaveInteger(udg_LS,x+3,y+0,0)
      call SaveInteger(udg_LS,x+3,y+1,0)
      call SaveInteger(udg_LS,x+3,y+2,1)
      call SaveInteger(udg_LS,x+4,y+0,1)
      call SaveInteger(udg_LS,x+4,y+1,1)
      call SaveInteger(udg_LS,x+4,y+2,1)
    endif
   
    //return
endfunction



function InvalidateCurrent takes nothing returns nothing
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    local integerb1
    local integerb2
    local integerb3
    local integerb4
    local image fp
    set x1 = LoadInteger(udg_AS,0,0)
    set x2 = LoadInteger(udg_AS,1,0)
    set x3 = LoadInteger(udg_AS,2,0)
    set x4 = LoadInteger(udg_AS,3,0)
    set y1 = LoadInteger(udg_AS,0,1)
    set y2 = LoadInteger(udg_AS,1,1)
    set y3 = LoadInteger(udg_AS,2,1)
    set y4 = LoadInteger(udg_AS,3,1)
    set b1= LoadInteger(udg_GS,x1,y1)
    set b2= LoadInteger(udg_GS,x2,y2)
    set b3= LoadInteger(udg_GS,x3,y3)
    set b4= LoadInteger(udg_GS,x4,y4)
    if (b1>=1) then
      set fp=LoadImageHandle(udg_FP,x1,y1)
      call ShowImage(fp,true)
    else
      set fp=LoadImageHandle(udg_FP,x1,y1)
      call ShowImage(fp,false)
    endif
    if (b2>=1) then
      set fp=LoadImageHandle(udg_FP,x2,y2)
      call ShowImage(fp,true)
    else
      set fp=LoadImageHandle(udg_FP,x2,y2)
      call ShowImage(fp,false)
    endif
    if (b3>=1) then
      set fp=LoadImageHandle(udg_FP,x3,y3)
      call ShowImage(fp,true)
    else
      set fp=LoadImageHandle(udg_FP,x3,y3)
      call ShowImage(fp,false)
    endif
    if (b4>=1) then
      set fp=LoadImageHandle(udg_FP,x4,y4)
      call ShowImage(fp,true)
    else
      set fp=LoadImageHandle(udg_FP,x4,y4)
      call ShowImage(fp,false)
    endif
   
   
    set fp=null
   
endfunction


function InvalidateRect takes nothing returns nothing
   
    local integeri
    local integerin
    local integerj
    local integerjn
    local integerb
    local image fp
   
    set i=0
    set in=udg_iRow-1
    loop
      exitwhen i>in
      set j=0
      set jn=udg_iCol-1
      loop
            exitwhen j>jn
            set b=LoadInteger(udg_GS,i,j)
            if (b>=1) then
                set fp=LoadImageHandle(udg_FP,i,j)
                call ShowImage(fp,true)
            else
                set fp=LoadImageHandle(udg_FP,i,j)
                call ShowImage(fp,false)
            endif
            
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set fp=null
   
    //return
endfunction
function InvalidateNext takes nothing returns nothing
   
    local integeri
    local integerin
    local integerj
    local integerjn
    local integerb
    local image fp
   
    set i=0
    set in=3
    loop
      exitwhen i>in
      set j=0
      set jn=3
      loop
            exitwhen j>jn
            set b=LoadInteger(udg_NGS,i,j)
            if (b>=1) then
                set fp=LoadImageHandle(udg_NP,i,j)
                call ShowImage(fp,true)
            else
                set fp=LoadImageHandle(udg_NP,i,j)
                call ShowImage(fp,false)
            endif
            
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set fp=null
   
    //return
endfunction
function InvalidateLevel takes nothing returns nothing
   
    local integeri
    local integerin
    local integerj
    local integerjn
    local integerb
    local image fp
   
    set i=0
    set in=4
    loop
      exitwhen i>in
      set j=0
      set jn=2
      loop
            exitwhen j>jn
            set b=LoadInteger(udg_LS,i,j)
            if (b>=1) then
                set fp=LoadImageHandle(udg_LP,i,j)
                call ShowImage(fp,true)
            else
                set fp=LoadImageHandle(udg_LP,i,j)
                call ShowImage(fp,false)
            endif
            
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set fp=null
   
    //return
endfunction
function InvalidateScore takes nothing returns nothing
   
    local integeri
    local integerin
    local integerj
    local integerjn
    local integerb
    local image fp
   
    set i=0
    set in=4
    loop
      exitwhen i>in
      set j=0
      set jn=14
      loop
            exitwhen j>jn
            set b=LoadInteger(udg_SS,i,j)
            if (b>=1) then
                set fp=LoadImageHandle(udg_SP,i,j)
                call ShowImage(fp,true)
            else
                set fp=LoadImageHandle(udg_SP,i,j)
                call ShowImage(fp,false)
            endif
            
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set fp=null
   
    //return
endfunction
function SetScore takes integer score returns nothing
    local integer s0
    local integer s1
    local integer s2
    local integer s3
    local integer s4
    local integer s
    if(score<=99999) then
      set s=score
      set s0=ModuloInteger(s,10)
      set s=(s-s0)/10
      set s1=ModuloInteger(s,10)
      set s=(s-s1)/10
      set s2=ModuloInteger(s,10)
      set s=(s-s2)/10
      set s3=ModuloInteger(s,10)
      set s=(s-s3)/10
      set s4=ModuloInteger(s,10)
    else
      set s0=9
      set s1=9
      set s2=9
      set s3=9
      set s4=9
    endif
   
   
    call PrintNumS(0,0,s4)
    call PrintNumS(0,3,s3)
    call PrintNumS(0,6,s2)
    call PrintNumS(0,9,s1)
    call PrintNumS(0,12,s0)
    call InvalidateScore()
   
   
    //return
endfunction
function SetLevel takes integer level returns nothing
    call PrintNumL(0,0,level)
    setudg_LevelTime=1.00-0.1*(level-1)
    setudg_Up=TRUE
    call InvalidateLevel()
   
    //return
endfunction



function FlashLine takes nothing returns nothing
    local integer i
    local integer j
    local image fp
    if (udg_bloop) then
      set i=0
      loop
            exitwhen i>=udg_iRow
            
            if(udg_bS==TRUE) then
                set j=0
                loop
                  exitwhen j>=udg_iCol
                  set fp=LoadImageHandle(udg_FP,i,j)
                  call ShowImage(fp,TRUE)
                  
                  
                  set j=j+1
                endloop
            endif
            set i=i+1
      endloop
      
    else
      set i=0
      loop
            exitwhen i>=udg_iRow
            
            if(udg_bS==TRUE) then
                set j=0
                loop
                  exitwhen j>=udg_iCol
                  set fp=LoadImageHandle(udg_FP,i,j)
                  call ShowImage(fp,FALSE)
                  
                  
                  set j=j+1
                endloop
            endif
            set i=i+1
      endloop
    endif
    set udg_bloop=not udg_bloop
   
   
    set fp=null
   
    //return
endfunction

function ActiveIsBottom takes nothing returns nothing
   
    //到底有两种概念:1是已到底部,2是下面碰到了另外的方块
   
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integerx
    local integerxx
    local integeryy
    local integeri
    local integerj
    local integerk
    local integer clevel
    local integer iMuch=0
    local real   tr
    local boolean bIsSucced
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      set udg_bABrun=TRUE
      set x1 = LoadInteger(udg_AS,0,0)
      set x2 = LoadInteger(udg_AS,1,0)
      set x3 = LoadInteger(udg_AS,2,0)
      set x4 = LoadInteger(udg_AS,3,0)
      
      //已到底
      //如果下面碰到了另外的方块
      //一个方块分为四个小方块,只有这样的小方块下面有另外的方块才算到底,这样的小方块满足条件如下:
      //它的下面不再有本方块的另外的小方块
      //用算法描述为:y坐标相等的一组小方块中的最下面的哪个小方块, 我称之为接触面
      
      if (x1>=(udg_iRow-1) or(x2>=udg_iRow-1) or (x3>=udg_iRow-1) or (x4>=udg_iRow-1))   then
            set udg_isBottom = TRUE
      else
            set i=0
            loop
                exitwhen i>=4
                if(LoadInteger(udg_IF,udg_currentRect,i) > -1) then
                  set x=LoadInteger(udg_IF,udg_currentRect,i)
                  set xx=LoadInteger(udg_AS,x,0)+1
                  set yy=LoadInteger(udg_AS,x,1)
                  if (LoadInteger(udg_GS,xx,yy)>=1) then
                        set udg_isBottom = TRUE
                  endif
                endif
                set i=i+1
            endloop
      endif
      
      //本次销掉的行数
      
      //计分规则:一次销掉一行,加100分,一次销掉两行,加400分,三行,900分
      //例如销掉x行,则分数为:x*(x*100)
      
      
      //判断是否已得分
      
      
      
      if (udg_isBottom) then
            
            //       set i=0
            ///      loop
            //          exitwhen i>=udg_iRow
            //          set bIsSucced = TRUE
            //         set udg_bS=TRUE
            //         set j=0
            //       loop
            //       exitwhen j>=udg_iCol
            //      if (LoadInteger(udg_GS,i,j)==0) then
            //          set bIsSucced = FALSE
            ///          set udg_bS=FALSE
            //      endif
            //            set j=j+1
            //      endloop
            //      if (bIsSucced) then
            //          set udg_bFlash=TRUE
            //         call PauseTimer(udg_GTimer)
            //         set udg_bloop=false
            //          set udg_k=0
            //      call TimerStart(udg_Flash,0.1,true,function FlashLine)
            //
            //         call PolledWait(0.6)
            //      call PauseTimer(udg_Flash)
            //      call ResumeTimer(udg_GTimer)
            //      set udg_bFlash=FALSE
            
            //      endif
            //       set i=i+1
            //       endloop
            
            set i=0
            loop
                exitwhen i>=udg_iRow
                set bIsSucced = TRUE
               
                set j=0
                loop
                  exitwhen j>=udg_iCol
                  if (LoadInteger(udg_GS,i,j)==0) then
                        set bIsSucced = FALSE
                        
                  endif
                  set j=j+1
                endloop
                if (bIsSucced) then
                  set k=i
                  loop
                        exitwhen k<=0
                        set j=0
                        
                        
                        loop
                            exitwhen j>=udg_iCol
                            call SaveInteger(udg_GS,k,j,LoadInteger(udg_GS,k-1,j))
                            set j=j+1
                        endloop
                        
                        set k=k-1
                  endloop
                  set j=0
                  loop
                        exitwhen j>=udg_iCol
                        call SaveInteger(udg_GS,0,j,0)
                        
                        set j=j+1
                  endloop
                  setiMuch=iMuch+1
                endif
               
               
               
               
                set i=i+1
            endloop
            
            
            
            
            
            if (iMuch>0) then
               
                if(iMuch<4) then
                  call PlaySoundBJ( gg_snd_deblock)
                else
                  call PlaySoundBJ( gg_snd_tetris)
                endif
                //刷新游戏区域
               
                call   InvalidateRect()
               
                //   //刷新分数区域
                set udg_iPerformance =udg_iPerformance+iMuch * iMuch * udg_Value
                call SetScore(udg_iPerformance)
                set clevel=LevelCheck(udg_iPerformance)
                if(clevel>udg_iLevel)then
                  if (udg_iLevel<=5 andclevel>=6) then
                        callStopMusic(TRUE)
                        call ClearMapMusicBJ()
                        call SetMapMusicIndexedBJ( gg_snd_BWing, 0 )
                        call PlayMusicBJ( gg_snd_BWing )
                  endif
                  call PlaySoundBJ( gg_snd_levelup)
                  setudg_iLevel=clevel
                  call SetLevel(udg_iLevel)
                  
                endif
               
            endif
            
      endif
      set udg_bABrun=FALSE
    endif
   
endfunction






function LeftIsLimit takes nothing returns boolean
   
   
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    local booleanbb=TRUE
   
    set x1 = LoadInteger(udg_AS,0,0)
    set x2 = LoadInteger(udg_AS,1,0)
    set x3 = LoadInteger(udg_AS,2,0)
    set x4 = LoadInteger(udg_AS,3,0)
    set y1 = LoadInteger(udg_AS,0,1)
    set y2 = LoadInteger(udg_AS,1,1)
    set y3 = LoadInteger(udg_AS,2,1)
    set y4 = LoadInteger(udg_AS,3,1)
    if(udg_currentRect==1) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 or LoadInteger(udg_GS,x3,y3-1)>=1 or LoadInteger(udg_GS,x4,y4-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==11) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==2) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==3) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==31) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 or LoadInteger(udg_GS,x3,y3-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==32) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 orLoadInteger(udg_GS,x3,y3-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==33) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 orLoadInteger(udg_GS,x4,y4-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==4) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 orLoadInteger(udg_GS,x4,y4-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==41) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==5) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 or LoadInteger(udg_GS,x3,y3-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==51) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1or LoadInteger(udg_GS,x3,y3-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==6) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1or LoadInteger(udg_GS,x3,y3-1)>=1 or LoadInteger(udg_GS,x4,y4-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==61) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==62) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 or LoadInteger(udg_GS,x3,y3-1)>=1) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==63) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1or LoadInteger(udg_GS,x3,y3-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==7) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 or LoadInteger(udg_GS,x3,y3-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==71) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==72) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1 or LoadInteger(udg_GS,x2,y2-1)>=1 or LoadInteger(udg_GS,x3,y3-1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==73) then
      if (LoadInteger(udg_GS,x1,y1-1)>=1or LoadInteger(udg_GS,x4,y4-1)>=1 ) then
            set bb=FALSE
      endif
    endif
   
   
   
   
    return bb
   
endfunction
function RightIsLimit takes nothing returns boolean
   
   
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    local booleanbb=TRUE
    set x1 = LoadInteger(udg_AS,0,0)
    set x2 = LoadInteger(udg_AS,1,0)
    set x3 = LoadInteger(udg_AS,2,0)
    set x4 = LoadInteger(udg_AS,3,0)
    set y1 = LoadInteger(udg_AS,0,1)
    set y2 = LoadInteger(udg_AS,1,1)
    set y3 = LoadInteger(udg_AS,2,1)
    set y4 = LoadInteger(udg_AS,3,1)
   
    if(udg_currentRect==1) then
      if (LoadInteger(udg_GS,x1,y1+1)>=1 or LoadInteger(udg_GS,x2,y2+1)>=1 or LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==11) then
      if (LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==2) then
      if (LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==3) then
      if (LoadInteger(udg_GS,x2,y2+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==31) then
      if (LoadInteger(udg_GS,x1,y1+1)>=1or LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==32) then
      if (LoadInteger( udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==33) then
      if ( LoadInteger(udg_GS,x2,y2+1)>=1 or LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==4) then
      if (LoadInteger(udg_GS,x1,y1+1)>=1or LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==41) then
      if ( LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==5) then
      if ( LoadInteger(udg_GS,x2,y2+1)>=1 or LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==51) then
      if ( LoadInteger(udg_GS,x2,y2+1)>=1or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==6) then
      if ( LoadInteger(udg_GS,x2,y2+1)>=1 or LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==61) then
      if (LoadInteger(udg_GS,x2,y2+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==62) then
      if (LoadInteger(udg_GS,x1,y1+1)>=1 or LoadInteger(udg_GS,x2,y2+1)>=1or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==63) then
      if ( LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==7) then
      if (LoadInteger(udg_GS,x2,y2+1)>=1 or LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==71) then
      if (LoadInteger(udg_GS,x1,y1+1)>=1or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==72) then
      if (LoadInteger(udg_GS,x2,y2+1)>=1 or LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    if(udg_currentRect==73) then
      if (LoadInteger(udg_GS,x3,y3+1)>=1 or LoadInteger(udg_GS,x4,y4+1)>=1 ) then
            set bb=FALSE
      endif
    endif
    return bb
   
   
endfunction

function RectDown takes nothing returns nothing
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      call ActiveIsBottom()
      if (not udg_isBottom) then
            //清除以前的方块
            
            
            set x1 = LoadInteger(udg_AS,0,0)
            set x2 = LoadInteger(udg_AS,1,0)
            set x3 = LoadInteger(udg_AS,2,0)
            set x4 = LoadInteger(udg_AS,3,0)
            set y1 = LoadInteger(udg_AS,0,1)
            set y2 = LoadInteger(udg_AS,1,1)
            set y3 = LoadInteger(udg_AS,2,1)
            set y4 = LoadInteger(udg_AS,3,1)
            call SaveInteger(udg_GS,x1,y1,0)
            call SaveInteger(udg_GS,x2,y2,0)
            call SaveInteger(udg_GS,x3,y3,0)
            call SaveInteger(udg_GS,x4,y4,0)
            call InvalidateCurrent()
            
            //方块下落
            set x1=x1+1
            set x2=x2+1
            set x3=x3+1
            set x4=x4+1
            call SaveInteger(udg_AS,0,0,x1)
            call SaveInteger(udg_AS,1,0,x2)
            call SaveInteger(udg_AS,2,0,x3)
            call SaveInteger(udg_AS,3,0,x4)
            call SaveInteger(udg_GS,x1,y1,1)
            call SaveInteger(udg_GS,x2,y2,1)
            call SaveInteger(udg_GS,x3,y3,1)
            call SaveInteger(udg_GS,x4,y4,1)
            call InvalidateCurrent()
      else
            call PlaySoundBJ( gg_snd_bottom )
            
      endif
    endif
endfunction

function RectChange takes nothing returns nothing
   
   
    //先预先变形,然后判断变形后的方块是否有空间,如有足够空间,则进行实际变形,否则不变
    local integerxx1
    local integerxx2
    local integerxx3
    local integerxx4
    local integeryy1
    local integeryy2
    local integeryy3
    local integeryy4
    local integeriscurrentRect
    //local booleanbb=TRUE
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      set x1 = LoadInteger(udg_AS,0,0)
      set x2 = LoadInteger(udg_AS,1,0)
      set x3 = LoadInteger(udg_AS,2,0)
      set x4 = LoadInteger(udg_AS,3,0)
      set y1 = LoadInteger(udg_AS,0,1)
      set y2 = LoadInteger(udg_AS,1,1)
      set y3 = LoadInteger(udg_AS,2,1)
      set y4 = LoadInteger(udg_AS,3,1)
      
      
      
      
      
      //变形后位置在数组中的存放顺序仍需遵循先左后右,在同一列中先上后下
      set xx1=x1
      set xx2=x2
      set xx3=x3
      set xx4=x4
      set yy1=y1
      set yy2=y2
      set yy3=y3
      set yy4=y4
      
      if(udg_currentRect==1) then
            set xx1=x1+1
            set yy1=y1-1
            set xx3=x3-1
            set yy3=y3+1
            set xx4=x4-2
            set yy4=y4+2
            set iscurrentRect=11
      endif
      if(udg_currentRect==11) then
            set xx1=x1-1
            set yy1=y1+1
            set xx3=x3+1
            set yy3=y3-1
            set xx4=x4+2
            set yy4=y4-2
            set iscurrentRect=1
      endif
      if(udg_currentRect==2) then
            set iscurrentRect=2
      endif
      if(udg_currentRect==3) then
            set xx1=x2
            set yy1=y2
            set xx2=x3
            set xx3=x3+1
            set iscurrentRect=31
      endif
      if(udg_currentRect==31) then
            set xx1=x2
            set yy1=y1-1
            set iscurrentRect=32
      endif
      if(udg_currentRect==32) then
            set xx2=x2-1
            set xx3=x2
            set xx4=x3
            set yy4=y3
            set iscurrentRect=33
      endif
      if(udg_currentRect==33) then
            
            
            set xx4=x4-1
            set yy4=y4+1
            set iscurrentRect=3
      endif
      
      if(udg_currentRect==4) then
            set xx1=x4
            set yy2=y3
            set xx3=x4
            set xx4=x2
            set yy4=y4+1
            set iscurrentRect=41
      endif
      if(udg_currentRect==41) then
            set xx1=x1-2
            set yy2=y1
            set xx3=x2
            set xx4=x3
            set yy4=y3
            set iscurrentRect=4
      endif
      if(udg_currentRect==5) then
            set yy1=y1-1
            set xx2=x1
            set xx3=x2
            set yy3=y2
            set xx4=x2
            set iscurrentRect=51
      endif
      if(udg_currentRect==51) then
            set yy1=y2
            set xx2=x3
            set xx3=x3-2
            set yy3=y4
            set xx4=x2
            set iscurrentRect=5
      endif
      if(udg_currentRect==6) then
            set xx1=x1+1
            set xx2=x4
            set yy2=y1
            set xx4=x3
            set yy4=y4+1
            set iscurrentRect=61
      endif
      if(udg_currentRect==61) then
            set xx1=x1-1
            set yy1=y3
            set xx2=x3
            set yy2=y3
            set xx3=x2
            set xx4=x2
            set iscurrentRect=62
      endif
      if(udg_currentRect==62) then
            set xx1=x2
            set yy1=y1-1
            set xx3=x1
            set yy3=y4
            set xx4=x2
            set iscurrentRect=63
      endif
      if(udg_currentRect==63) then
            set xx1=x3
            set xx2=x3
            set xx3=x2
            set yy3=y2
            set xx4=x4+1
            set yy4=y2
            set iscurrentRect=6
      endif
      if(udg_currentRect==7) then
            set yy1=y1-1
            set yy2=y2-1
            set xx3=x2
            set xx4=x2
            set iscurrentRect=71
      endif
      if(udg_currentRect==71) then
            set xx1=x1+2
            set xx2=x1
            set yy2=y3
            set xx4=x4+1
            set yy4=y3
            set iscurrentRect=72
      endif
      if(udg_currentRect==72) then
            set xx1=x3
            set xx2=x3
            set yy3=y3+1
            set yy4=y4+1
            set iscurrentRect=73
      endif
      if(udg_currentRect==73) then
            set xx1=x1-1
            set yy1=y2
            set xx3=x4
            set yy3=y2
            set xx4=x4-2
            set iscurrentRect=7
      endif
      
      
      
      
      //如果变形后所在的区域内无其他方块,则表示有足够空间,可以变形
      //且不能超越边界
      call SaveInteger(udg_GS,x1,y1,0)
      call SaveInteger(udg_GS,x2,y2,0)
      call SaveInteger(udg_GS,x3,y3,0)
      call SaveInteger(udg_GS,x4,y4,0)
      if (LoadInteger(udg_GS,xx1,yy1)==0 and LoadInteger(udg_GS,xx2,yy2)==0 and LoadInteger(udg_GS,xx3,yy3)==0 andLoadInteger(udg_GS,xx4,yy4)==0 and yy1>=0 and yy4<=(udg_iCol-1) and xx1>=0 and xx2>=0 and xx3>=0 and xx4>=0 and xx1<=udg_iRow and xx2<=udg_iRow and xx3<=udg_iRow and xx4<=udg_iRow ) then
            
            call InvalidateCurrent()
            
            call SaveInteger(udg_AS,0,0,xx1)
            call SaveInteger(udg_AS,1,0,xx2)
            call SaveInteger(udg_AS,2,0,xx3)
            call SaveInteger(udg_AS,3,0,xx4)
            call SaveInteger(udg_AS,0,1,yy1)
            call SaveInteger(udg_AS,1,1,yy2)
            call SaveInteger(udg_AS,2,1,yy3)
            call SaveInteger(udg_AS,3,1,yy4)
            call SaveInteger(udg_GS,xx1,yy1,1)
            call SaveInteger(udg_GS,xx2,yy2,1)
            call SaveInteger(udg_GS,xx3,yy3,1)
            call SaveInteger(udg_GS,xx4,yy4,1)
            
            
            call InvalidateCurrent()
            
            //改变形状代码
            set udg_currentRect = iscurrentRect
            
      else
            call SaveInteger(udg_GS,x1,y1,1)
            call SaveInteger(udg_GS,x2,y2,1)
            call SaveInteger(udg_GS,x3,y3,1)
            call SaveInteger(udg_GS,x4,y4,1)
      endif
      //判断是否已到底
      call PlaySoundBJ( gg_snd_change)
      call ActiveIsBottom()
    endif
endfunction
function RectArrow takes integer tp returns nothing
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      set x1 = LoadInteger(udg_AS,0,0)
      set x2 = LoadInteger(udg_AS,1,0)
      set x3 = LoadInteger(udg_AS,2,0)
      set x4 = LoadInteger(udg_AS,3,0)
      set y1 = LoadInteger(udg_AS,0,1)
      set y2 = LoadInteger(udg_AS,1,1)
      set y3 = LoadInteger(udg_AS,2,1)
      set y4 = LoadInteger(udg_AS,3,1)
      
      //如果方块已到底则不能再移动
      if (tp==0) then
            call PlaySoundBJ( gg_snd_move )
            if(y1>0 and LeftIsLimit() and (not udg_isBottom)) then
                call SaveInteger(udg_GS,x1,y1,0)
                call SaveInteger(udg_GS,x2,y2,0)
                call SaveInteger(udg_GS,x3,y3,0)
                call SaveInteger(udg_GS,x4,y4,0)
                call InvalidateCurrent()
                set y1=y1-1
                set y2=y2-1
                set y3=y3-1
                set y4=y4-1
                call SaveInteger(udg_AS,0,1,y1)
                call SaveInteger(udg_AS,1,1,y2)
                call SaveInteger(udg_AS,2,1,y3)
                call SaveInteger(udg_AS,3,1,y4)
                call SaveInteger(udg_GS,x1,y1,1)
                call SaveInteger(udg_GS,x2,y2,1)
                call SaveInteger(udg_GS,x3,y3,1)
                call SaveInteger(udg_GS,x4,y4,1)
                call InvalidateCurrent()
               
            endif
            
      endif
      if (tp==1) then
            call PlaySoundBJ( gg_snd_move )
            if(y4<(udg_iCol-1) and RightIsLimit() and (not udg_isBottom)) then
                call SaveInteger(udg_GS,x1,y1,0)
                call SaveInteger(udg_GS,x2,y2,0)
                call SaveInteger(udg_GS,x3,y3,0)
                call SaveInteger(udg_GS,x4,y4,0)
                call InvalidateCurrent()
                set y1=y1+1
                set y2=y2+1
                set y3=y3+1
                set y4=y4+1
                call SaveInteger(udg_AS,0,1,y1)
                call SaveInteger(udg_AS,1,1,y2)
                call SaveInteger(udg_AS,2,1,y3)
                call SaveInteger(udg_AS,3,1,y4)
                call SaveInteger(udg_GS,x1,y1,1)
                call SaveInteger(udg_GS,x2,y2,1)
                call SaveInteger(udg_GS,x3,y3,1)
                call SaveInteger(udg_GS,x4,y4,1)
                call InvalidateCurrent()
               
            endif
            
      endif
      
      if (tp==2) then
            call PlaySoundBJ( gg_snd_down )
            call RectDown()
            
      endif
    endif
   
endfunction


function GameOver takes nothing returns nothing
    local integer i
    local integer j
    call PauseTimer(udg_GTimer)
    call StopMusic(FALSE)
    call ClearMapMusic()
    call PlaySoundBJ( gg_snd_gameover )
    set i=0
    loop
      exitwhen i>=udg_iRow
      set j=0
      loop
            exitwhen j>=udg_iCol
            
            call SaveInteger(udg_GS,i,j,1)
            set j=j+1
      endloop
      set i=i+1
    endloop
    call SaveInteger(udg_GS,0,1,0)
    call SaveInteger(udg_GS,0,6,0)
    call SaveInteger(udg_GS,0,8,0)
    call SaveInteger(udg_GS,1,2,0)
    call SaveInteger(udg_GS,1,3,0)
    call SaveInteger(udg_GS,1,7,0)
    call SaveInteger(udg_GS,2,2,0)
    call SaveInteger(udg_GS,3,2,0)
    call SaveInteger(udg_GS,3,7,0)
    call SaveInteger(udg_GS,4,1,0)
    call SaveInteger(udg_GS,4,7,0)
    call SaveInteger(udg_GS,5,2,0)
    call SaveInteger(udg_GS,6,7,0)
    call SaveInteger(udg_GS,6,8,0)
    call SaveInteger(udg_GS,7,2,0)
    call SaveInteger(udg_GS,8,2,0)
    call SaveInteger(udg_GS,8,7,0)
    call SaveInteger(udg_GS,8,8,0)
    call SaveInteger(udg_GS,9,2,0)
    call SaveInteger(udg_GS,10,1,0)
    call SaveInteger(udg_GS,10,3,0)
    call SaveInteger(udg_GS,10,7,0)
    call SaveInteger(udg_GS,11,2,0)
    call SaveInteger(udg_GS,11,7,0)
    call SaveInteger(udg_GS,12,2,0)
    call SaveInteger(udg_GS,12,7,0)
    call SaveInteger(udg_GS,13,2,0)
    call SaveInteger(udg_GS,14,1,0)
    call SaveInteger(udg_GS,14,3,0)
    call SaveInteger(udg_GS,14,6,0)
    call SaveInteger(udg_GS,14,8,0)
    call SaveInteger(udg_GS,15,8,0)
    call SaveInteger(udg_GS,16,2,0)
    call SaveInteger(udg_GS,16,3,0)
    call SaveInteger(udg_GS,16,7,0)
    call SaveInteger(udg_GS,17,8,0)
    call SaveInteger(udg_GS,18,2,0)
    call SaveInteger(udg_GS,18,3,0)
    call SaveInteger(udg_GS,18,7,0)
    call SaveInteger(udg_GS,19,7,0)
    set i=0
    loop
      exitwhen i>=udg_iRow
      
      
      
      call SaveInteger(udg_GS,i,0,0)
      call SaveInteger(udg_GS,i,4,0)
      call SaveInteger(udg_GS,i,5,0)
      call SaveInteger(udg_GS,i,9,0)
      
      set i=i+1
    endloop
   
    call InvalidateRect()
    set i=0
   
    loop
      exitwhen(i>=100)
      set j=0
      loop
            exitwhen (j>=100)
            call SaveInteger(udg_GS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
   
    loop
      exitwhen(i>=4)
      set j=0
      loop
            exitwhen (j>=4)
            call SaveInteger(udg_NGS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
   
    loop
      exitwhen(i>=5)
      set j=0
      loop
            exitwhen (j>=15)
            call SaveInteger(udg_LS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
   
    loop
      exitwhen(i>=5)
      set j=0
      loop
            exitwhen (j>=15)
            call SaveInteger(udg_SS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    // call EnableTrigger( gg_trg_GameStart )
    //return
endfunction

function OnTimer takes nothing returns nothing
   
    //如果原来的方块已到底或游戏刚开始,则掉下一个新的方块
    local integer i
    local integer j
    local integer k
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      if (udg_isBottom) then
            
            set udg_icurrentStatus = udg_inextStatus
            set udg_inextStatus = GetRandomInt(1,7)//得到下一次的方块样式
            set udg_currentRect = udg_icurrentStatus   //当前落下的方块的形状代码
            call RectStatusToActiveStatus( udg_icurrentStatus )
            call ActiveStatusToGameStatus()
            set udg_isBottom = FALSE
            call ActiveIsBottom()
            
            
            call InvalidateCurrent()
            
            //在屏幕右边显示下一次将会出来的方块的模样
            call RectStatusToNextStatus( udg_inextStatus )
            call NextStatusToGameNextStatus()
            call InvalidateNext()
            
            //判断游戏是否已结束: 碰了底,且第1行有小方块
            if (udg_isBottom)   then
               
                set i=0
                loop
                  exitwhen (i>=udg_iCol or udg_bGameEnd)
                  
                  if (LoadInteger(udg_GS,0,i)>=1)   then
                        set udg_bGameEnd = TRUE
                        set udg_isBottom=FALSE
                        call DisableTrigger( gg_trg_OnKeyLeft )
                        call DisableTrigger( gg_trg_OnKeyRight )
                        call DisableTrigger( gg_trg_OnKeyDown )
                        call DisableTrigger( gg_trg_OnKeyUp )
                        //call PauseTimer(udg_GTimer)
                        call GameOver()
                        call ShowInterfaceForceOn( GetPlayersAll(), 6.49 )
                        
                        
                        
                  endif
                  set i=i+1
                endloop
            endif
            if (udg_Up) then
                set udg_Up=FALSE
                call TimerStart(udg_GTimer,udg_LevelTime,true,function OnTimer)
            endif
      else//当前方块下降
            if (not udg_bGameEnd ) then
               
               
                call RectDown()
            endif
      endif
    endif
endfunction




//***************************************************************************
//*
//*Triggers
//*
//***************************************************************************

//===========================================================================
// Trigger: 对战初始化
//
// 默认的对所有玩家的对战游戏初始化
//===========================================================================
function Trig________________u_Actions takes nothing returns nothing
    call MeleeStartingVisibility()
    call MeleeStartingHeroLimit()
    call MeleeStartingResources()
    call FogEnableOff()
    call FogMaskEnableOff()
    call EnableDawnDusk( false )
    call CHWRECTView()
    call InitDraw0()
    call InitDraw()
    set udg_CenterUnit = gg_unit_e001_0002
    call ShowUnitHide( udg_CenterUnit )
    call CameraSetupApplyForPlayer( true, gg_cam_center, Player(6), 0 )
    call SetCameraTargetControllerNoZForPlayer( Player(6), udg_CenterUnit, 0, 0, false )
    call PolledWait( 0.10 )
    call InitDraw2()
    call PolledWait( 0.01 )
    call StopMusicBJ( false )
    call ClearMapMusicBJ()
    call PlaySoundBJ( gg_snd_LittleKing )
    call QuestMessageBJ( GetPlayersAll(), bj_QUESTMESSAGE_ALWAYSHINT, "TRIGSTR_055" )
endfunction

//===========================================================================
function InitTrig________________u takes nothing returns nothing
    set gg_trg________________u = CreateTrigger()
    call TriggerAddAction( gg_trg________________u, function Trig________________u_Actions )
endfunction

//===========================================================================
// Trigger: OnKeyLeft
//===========================================================================
function Trig_OnKeyLeft_Conditions takes nothing returns boolean
    if ( not ( udg_bFlash == false ) ) then
      return false
    endif
    if ( not ( udg_bABrun == false ) ) then
      return false
    endif
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_OnKeyLeft_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_OnKeyLeft )
    call DisableTrigger( gg_trg_OnKeyRight )
    call DisableTrigger( gg_trg_OnKeyDown )
    call DisableTrigger( gg_trg_OnKeyUp )
    call RectArrow(0)
    call StartTimerBJ( udg_LTimer, true, 0.10 )
    call EnableTrigger( gg_trg_OffKeyLeft )
    call EnableTrigger( gg_trg_left )
endfunction

//===========================================================================
function InitTrig_OnKeyLeft takes nothing returns nothing
    set gg_trg_OnKeyLeft = CreateTrigger()
    call DisableTrigger( gg_trg_OnKeyLeft )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_OnKeyLeft, Player(6), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
    call TriggerAddCondition( gg_trg_OnKeyLeft, Condition( function Trig_OnKeyLeft_Conditions ) )
    call TriggerAddAction( gg_trg_OnKeyLeft, function Trig_OnKeyLeft_Actions )
endfunction

//===========================================================================
// Trigger: OffKeyLeft
//===========================================================================
function Trig_OffKeyLeft_Func004C takes nothing returns boolean
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_OffKeyLeft_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_OffKeyLeft )
    call DisableTrigger( gg_trg_left )
    call PauseTimerBJ( true, udg_LTimer )
    if ( Trig_OffKeyLeft_Func004C() ) then
      call EnableTrigger( gg_trg_OnKeyLeft )
      call EnableTrigger( gg_trg_OnKeyRight )
      call EnableTrigger( gg_trg_OnKeyUp )
      call EnableTrigger( gg_trg_OnKeyDown )
    else
      call DoNothing()
    endif
endfunction

//===========================================================================
function InitTrig_OffKeyLeft takes nothing returns nothing
    set gg_trg_OffKeyLeft = CreateTrigger()
    call DisableTrigger( gg_trg_OffKeyLeft )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_OffKeyLeft, Player(6), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_LEFT )
    call TriggerAddAction( gg_trg_OffKeyLeft, function Trig_OffKeyLeft_Actions )
endfunction

//===========================================================================
// Trigger: left
//===========================================================================
function Trig_left_Conditions takes nothing returns boolean
    if ( not ( udg_bFlash == false ) ) then
      return false
    endif
    if ( not ( udg_bABrun == false ) ) then
      return false
    endif
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_left_Actions takes nothing returns nothing
    call RectArrow(0)
endfunction

//===========================================================================
function InitTrig_left takes nothing returns nothing
    set gg_trg_left = CreateTrigger()
    call DisableTrigger( gg_trg_left )
    call TriggerRegisterTimerExpireEventBJ( gg_trg_left, udg_LTimer )
    call TriggerAddCondition( gg_trg_left, Condition( function Trig_left_Conditions ) )
    call TriggerAddAction( gg_trg_left, function Trig_left_Actions )
endfunction

//===========================================================================
// Trigger: OnKeyRight
//===========================================================================
function Trig_OnKeyRight_Conditions takes nothing returns boolean
    if ( not ( udg_bFlash == false ) ) then
      return false
    endif
    if ( not ( udg_bABrun == false ) ) then
      return false
    endif
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_OnKeyRight_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_OnKeyRight )
    call DisableTrigger( gg_trg_OnKeyLeft )
    call DisableTrigger( gg_trg_OnKeyDown )
    call DisableTrigger( gg_trg_OnKeyUp )
    call RectArrow(1)
    call StartTimerBJ( udg_RTimer, true, 0.10 )
    call EnableTrigger( gg_trg_OffKeRight )
    call EnableTrigger( gg_trg_right )
endfunction

//===========================================================================
function InitTrig_OnKeyRight takes nothing returns nothing
    set gg_trg_OnKeyRight = CreateTrigger()
    call DisableTrigger( gg_trg_OnKeyRight )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_OnKeyRight, Player(6), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
    call TriggerAddCondition( gg_trg_OnKeyRight, Condition( function Trig_OnKeyRight_Conditions ) )
    call TriggerAddAction( gg_trg_OnKeyRight, function Trig_OnKeyRight_Actions )
endfunction

//===========================================================================
// Trigger: OffKeRight
//===========================================================================
function Trig_OffKeRight_Func004C takes nothing returns boolean
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_OffKeRight_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_OffKeRight )
    call DisableTrigger( gg_trg_right )
    call PauseTimerBJ( true, udg_RTimer )
    if ( Trig_OffKeRight_Func004C() ) then
      call EnableTrigger( gg_trg_OnKeyLeft )
      call EnableTrigger( gg_trg_OnKeyRight )
      call EnableTrigger( gg_trg_OnKeyUp )
      call EnableTrigger( gg_trg_OnKeyDown )
    else
      call DoNothing()
    endif
endfunction

//===========================================================================
function InitTrig_OffKeRight takes nothing returns nothing
    set gg_trg_OffKeRight = CreateTrigger()
    call DisableTrigger( gg_trg_OffKeRight )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_OffKeRight, Player(6), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_RIGHT )
    call TriggerAddAction( gg_trg_OffKeRight, function Trig_OffKeRight_Actions )
endfunction

//===========================================================================
// Trigger: right
//===========================================================================
function Trig_right_Conditions takes nothing returns boolean
    if ( not ( udg_bFlash == false ) ) then
      return false
    endif
    if ( not ( udg_bABrun == false ) ) then
      return false
    endif
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_right_Actions takes nothing returns nothing
    call RectArrow(1)
endfunction

//===========================================================================
function InitTrig_right takes nothing returns nothing
    set gg_trg_right = CreateTrigger()
    call DisableTrigger( gg_trg_right )
    call TriggerRegisterTimerExpireEventBJ( gg_trg_right, udg_RTimer )
    call TriggerAddCondition( gg_trg_right, Condition( function Trig_right_Conditions ) )
    call TriggerAddAction( gg_trg_right, function Trig_right_Actions )
endfunction

//===========================================================================
// Trigger: OnKeyDown
//===========================================================================
function Trig_OnKeyDown_Conditions takes nothing returns boolean
    if ( not ( udg_bFlash == false ) ) then
      return false
    endif
    if ( not ( udg_bABrun == false ) ) then
      return false
    endif
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_OnKeyDown_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_OnKeyLeft )
    call DisableTrigger( gg_trg_OnKeyRight )
    call DisableTrigger( gg_trg_OnKeyDown )
    call DisableTrigger( gg_trg_OnKeyUp )
    call RectArrow(2)
    call StartTimerBJ( udg_DTimer, true, 0.05 )
    call EnableTrigger( gg_trg_OffKeDown )
    call EnableTrigger( gg_trg_down )
endfunction

//===========================================================================
function InitTrig_OnKeyDown takes nothing returns nothing
    set gg_trg_OnKeyDown = CreateTrigger()
    call DisableTrigger( gg_trg_OnKeyDown )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_OnKeyDown, Player(6), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
    call TriggerAddCondition( gg_trg_OnKeyDown, Condition( function Trig_OnKeyDown_Conditions ) )
    call TriggerAddAction( gg_trg_OnKeyDown, function Trig_OnKeyDown_Actions )
endfunction

//===========================================================================
// Trigger: OffKeDown
//===========================================================================
function Trig_OffKeDown_Func004C takes nothing returns boolean
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_OffKeDown_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_OffKeDown )
    call DisableTrigger( gg_trg_down )
    call PauseTimerBJ( true, udg_DTimer )
    if ( Trig_OffKeDown_Func004C() ) then
      call EnableTrigger( gg_trg_OnKeyLeft )
      call EnableTrigger( gg_trg_OnKeyRight )
      call EnableTrigger( gg_trg_OnKeyUp )
      call EnableTrigger( gg_trg_OnKeyDown )
    else
      call DoNothing()
    endif
endfunction

//===========================================================================
function InitTrig_OffKeDown takes nothing returns nothing
    set gg_trg_OffKeDown = CreateTrigger()
    call DisableTrigger( gg_trg_OffKeDown )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_OffKeDown, Player(6), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_DOWN )
    call TriggerAddAction( gg_trg_OffKeDown, function Trig_OffKeDown_Actions )
endfunction

//===========================================================================
// Trigger: down
//===========================================================================
function Trig_down_Conditions takes nothing returns boolean
    if ( not ( udg_bFlash == false ) ) then
      return false
    endif
    if ( not ( udg_bABrun == false ) ) then
      return false
    endif
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_down_Actions takes nothing returns nothing
    call RectArrow(2)
endfunction

//===========================================================================
function InitTrig_down takes nothing returns nothing
    set gg_trg_down = CreateTrigger()
    call DisableTrigger( gg_trg_down )
    call TriggerRegisterTimerExpireEventBJ( gg_trg_down, udg_DTimer )
    call TriggerAddCondition( gg_trg_down, Condition( function Trig_down_Conditions ) )
    call TriggerAddAction( gg_trg_down, function Trig_down_Actions )
endfunction

//===========================================================================
// Trigger: OnKeyUp
//===========================================================================
function Trig_OnKeyUp_Conditions takes nothing returns boolean
    if ( not ( udg_bFlash == false ) ) then
      return false
    endif
    if ( not ( udg_bABrun == false ) ) then
      return false
    endif
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_OnKeyUp_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_OnKeyUp )
    call DisableTrigger( gg_trg_OnKeyLeft )
    call DisableTrigger( gg_trg_OnKeyRight )
    call DisableTrigger( gg_trg_OnKeyDown )
    call RectChange()
    call EnableTrigger( gg_trg_OffKeUp )
endfunction

//===========================================================================
function InitTrig_OnKeyUp takes nothing returns nothing
    set gg_trg_OnKeyUp = CreateTrigger()
    call DisableTrigger( gg_trg_OnKeyUp )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_OnKeyUp, Player(6), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
    call TriggerAddCondition( gg_trg_OnKeyUp, Condition( function Trig_OnKeyUp_Conditions ) )
    call TriggerAddAction( gg_trg_OnKeyUp, function Trig_OnKeyUp_Actions )
endfunction

//===========================================================================
// Trigger: OffKeUp
//===========================================================================
function Trig_OffKeUp_Func002C takes nothing returns boolean
    if ( not ( udg_bGameEnd == false ) ) then
      return false
    endif
    return true
endfunction

function Trig_OffKeUp_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_OffKeUp )
    if ( Trig_OffKeUp_Func002C() ) then
      call EnableTrigger( gg_trg_OnKeyLeft )
      call EnableTrigger( gg_trg_OnKeyRight )
      call EnableTrigger( gg_trg_OnKeyUp )
      call EnableTrigger( gg_trg_OnKeyDown )
    else
      call DoNothing()
    endif
endfunction

//===========================================================================
function InitTrig_OffKeUp takes nothing returns nothing
    set gg_trg_OffKeUp = CreateTrigger()
    call DisableTrigger( gg_trg_OffKeUp )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_OffKeUp, Player(6), bj_KEYEVENTTYPE_RELEASE, bj_KEYEVENTKEY_UP )
    call TriggerAddAction( gg_trg_OffKeUp, function Trig_OffKeUp_Actions )
endfunction

//===========================================================================
// Trigger: GameStart
//===========================================================================
function Trig_GameStart_Conditions takes nothing returns boolean
    if ( not ( udg_bGameEnd == true ) ) then
      return false
    endif
    return true
endfunction

function Trig_GameStart_Actions takes nothing returns nothing
    set udg_bFlash = false
    set udg_iLevel = 1
    set udg_iPerformance = 0
    call SetScore(udg_iPerformance)
    call SetLevel(udg_iLevel)
    set udg_isBottom = true
    set udg_Up = false
    set udg_bGameEnd = false
    set udg_bABrun = false
    call InvalidateRect()
    set udg_LevelTime = 1.00
    call CameraSetupApplyForPlayer( true, gg_cam_center, Player(6), 0 )
    call SetCameraTargetControllerNoZForPlayer( Player(6), udg_CenterUnit, 0, 0, false )
    call ShowInterfaceForceOff( GetPlayersAll(), 4.19 )
    call PlaySoundBJ( gg_snd_bigin )
    call WaitForSoundBJ( gg_snd_bigin, 0 )
    call SetUserControlForceOn( GetPlayersAll() )
    call TimerStart(udg_GTimer,udg_LevelTime,true,function OnTimer)
    call EnableTrigger( gg_trg_OnKeyLeft )
    call EnableTrigger( gg_trg_OnKeyRight )
    call EnableTrigger( gg_trg_OnKeyUp )
    call EnableTrigger( gg_trg_OnKeyDown )
    call ClearMapMusicBJ()
    call SetMapMusicIndexedBJ( gg_snd_russia, 0 )
    call PlayMusicBJ( gg_snd_russia )
endfunction

//===========================================================================
function InitTrig_GameStart takes nothing returns nothing
    set gg_trg_GameStart = CreateTrigger()
    call TriggerRegisterPlayerChatEvent( gg_trg_GameStart, Player(6), "START", true )
    call TriggerAddCondition( gg_trg_GameStart, Condition( function Trig_GameStart_Conditions ) )
    call TriggerAddAction( gg_trg_GameStart, function Trig_GameStart_Actions )
endfunction

//===========================================================================
function InitCustomTriggers takes nothing returns nothing
    call InitTrig________________u()
    call InitTrig_OnKeyLeft()
    call InitTrig_OffKeyLeft()
    call InitTrig_left()
    call InitTrig_OnKeyRight()
    call InitTrig_OffKeRight()
    call InitTrig_right()
    call InitTrig_OnKeyDown()
    call InitTrig_OffKeDown()
    call InitTrig_down()
    call InitTrig_OnKeyUp()
    call InitTrig_OffKeUp()
    call InitTrig_GameStart()
endfunction

//===========================================================================
function RunInitializationTriggers takes nothing returns nothing
    call ConditionalTriggerExecute( gg_trg________________u )
endfunction

//***************************************************************************
//*
//*Players
//*
//***************************************************************************

function InitCustomPlayerSlots takes nothing returns nothing

    // Player 6
    call SetPlayerStartLocation( Player(6), 0 )
    call ForcePlayerStartLocation( Player(6), 0 )
    call SetPlayerColor( Player(6), ConvertPlayerColor(6) )
    call SetPlayerRacePreference( Player(6), RACE_PREF_HUMAN )
    call SetPlayerRaceSelectable( Player(6), false )
    call SetPlayerController( Player(6), MAP_CONTROL_USER )

endfunction

function InitCustomTeams takes nothing returns nothing
    // Force: TRIGSTR_006
    call SetPlayerTeam( Player(6), 0 )

endfunction

//***************************************************************************
//*
//*Main Initialization
//*
//***************************************************************************

//===========================================================================
function main takes nothing returns nothing
    call SetCameraBounds( -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
    call SetDayNightModels( "Environment\\\\DNC\\\\DNCLordaeron\\\\DNCLordaeronTerrain\\\\DNCLordaeronTerrain.mdl", "Environment\\\\DNC\\\\DNCLordaeron\\\\DNCLordaeronUnit\\\\DNCLordaeronUnit.mdl" )
    call NewSoundEnvironment( "Default" )
    call SetAmbientDaySound( "IceCrownDay" )
    call SetAmbientNightSound( "IceCrownNight" )
    call SetMapMusic( "Music", true, 0 )
    call InitSounds()
    call CreateCameras()
    call CreateAllUnits()
    call InitBlizzard()
    call InitGlobals()
    call InitCustomTriggers()
    call RunInitializationTriggers()

endfunction

//***************************************************************************
//*
//*Map Configuration
//*
//***************************************************************************

function config takes nothing returns nothing
    call SetMapName( "TRIGSTR_001" )
    call SetMapDescription( "TRIGSTR_003" )
    call SetPlayers( 1 )
    call SetTeams( 1 )
    call SetGamePlacement( MAP_PLACEMENT_USE_MAP_SETTINGS )

    call DefineStartLocation( 0, -448.0, -832.0 )

    // Player setup
    call InitCustomPlayerSlots()
    call InitCustomTeams()
endfunction

活宝 发表于 2010-1-21 11:52:58

彩虹版新增函数


function SetColorG takes integer x ,integer y,integer color returns nothing
    local image fp
    set fp=LoadImageHandle(udg_FP,x,y)
    if (color==0) then
      call SetImageColor(fp,0,0,0,0)
    endif
    if (color==1) then
      call SetImageColor(fp,255,0,0,255)
    endif
    if (color==2) then
      call SetImageColor(fp,255,128,0,255)
    endif
    if (color==3) then
      call SetImageColor(fp,255,255,0,255)
    endif
    if (color==4) then
      call SetImageColor(fp,0,255,0,255)
    endif
    if (color==5) then
      call SetImageColor(fp,0,255,255,255)
    endif
    if (color==6) then
      call SetImageColor(fp,0,0,255,255)
    endif
    if (color==7) then
      call SetImageColor(fp,255,0,255,255)
    endif
    set fp=null
    //return
endfunction
function SetColorN takes integer x ,integer y,integer color returns nothing
    local image fp
    set fp=LoadImageHandle(udg_NP,x,y)
    if (color==0) then
      call SetImageColor(fp,0,0,0,0)
    endif
    if (color==1) then
      call SetImageColor(fp,255,0,0,255)
    endif
    if (color==2) then
      call SetImageColor(fp,255,128,0,255)
    endif
    if (color==3) then
      call SetImageColor(fp,255,255,0,255)
    endif
    if (color==4) then
      call SetImageColor(fp,0,255,0,255)
    endif
    if (color==5) then
      call SetImageColor(fp,0,255,255,255)
    endif
    if (color==6) then
      call SetImageColor(fp,0,0,255,255)
    endif
    if (color==7) then
      call SetImageColor(fp,255,0,255,255)
    endif
    set fp=null
    //return
endfunction

更新的函数

function RectStatusToActiveStatus takes integer udg_which returns nothing
   
    if(udg_which==1) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,1)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,2)
      call SaveInteger(udg_AS,2,1,5)
      call SaveInteger(udg_AS,3,0,3)
      call SaveInteger(udg_AS,3,1,5)
      call SaveInteger(udg_GC,0,5,1)
      call SaveInteger(udg_GC,1,5,1)
      call SaveInteger(udg_GC,2,5,1)
      call SaveInteger(udg_GC,3,5,1)
    endif
    if(udg_which==2) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,1)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,0)
      call SaveInteger(udg_AS,2,1,6)
      call SaveInteger(udg_AS,3,0,1)
      call SaveInteger(udg_AS,3,1,6)
      call SaveInteger(udg_GC,0,5,2)
      call SaveInteger(udg_GC,1,5,2)
      call SaveInteger(udg_GC,0,6,2)
      call SaveInteger(udg_GC,1,6,2)
    endif
    if(udg_which==3) then
      call SaveInteger(udg_AS,0,0,1)
      call SaveInteger(udg_AS,0,1,4)
      call SaveInteger(udg_AS,1,0,0)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,1)
      call SaveInteger(udg_AS,2,1,5)
      call SaveInteger(udg_AS,3,0,1)
      call SaveInteger(udg_AS,3,1,6)
      call SaveInteger(udg_GC,1,4,3)
      call SaveInteger(udg_GC,0,5,3)
      call SaveInteger(udg_GC,1,5,3)
      call SaveInteger(udg_GC,1,6,3)
    endif
    if(udg_which==4) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,1)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,1)
      call SaveInteger(udg_AS,2,1,6)
      call SaveInteger(udg_AS,3,0,2)
      call SaveInteger(udg_AS,3,1,6)
      call SaveInteger(udg_GC,0,5,4)
      call SaveInteger(udg_GC,1,5,4)
      call SaveInteger(udg_GC,1,6,4)
      call SaveInteger(udg_GC,2,6,4)
    endif
    if(udg_which==5) then
      call SaveInteger(udg_AS,0,0,1)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,2)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,0)
      call SaveInteger(udg_AS,2,1,6)
      call SaveInteger(udg_AS,3,0,1)
      call SaveInteger(udg_AS,3,1,6)
      call SaveInteger(udg_GC,1,5,5)
      call SaveInteger(udg_GC,2,5,5)
      call SaveInteger(udg_GC,0,6,5)
      call SaveInteger(udg_GC,1,6,5)
    endif
    if(udg_which==6) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,0)
      call SaveInteger(udg_AS,1,1,6)
      call SaveInteger(udg_AS,2,0,1)
      call SaveInteger(udg_AS,2,1,6)
      call SaveInteger(udg_AS,3,0,2)
      call SaveInteger(udg_AS,3,1,6)
      call SaveInteger(udg_GC,0,5,6)
      call SaveInteger(udg_GC,0,6,6)
      call SaveInteger(udg_GC,1,6,6)
      call SaveInteger(udg_GC,2,6,6)
    endif
    if(udg_which==7) then
      call SaveInteger(udg_AS,0,0,0)
      call SaveInteger(udg_AS,0,1,5)
      call SaveInteger(udg_AS,1,0,1)
      call SaveInteger(udg_AS,1,1,5)
      call SaveInteger(udg_AS,2,0,2)
      call SaveInteger(udg_AS,2,1,5)
      call SaveInteger(udg_AS,3,0,0)
      call SaveInteger(udg_AS,3,1,6)
      call SaveInteger(udg_GC,0,5,7)
      call SaveInteger(udg_GC,1,5,7)
      call SaveInteger(udg_GC,2,5,7)
      call SaveInteger(udg_GC,0,6,7)
    endif
endfunction
function RectStatusToNextStatus takes integer udg_which returns nothing
   
    if(udg_which==1) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,1)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,2)
      call SaveInteger(udg_NS,2,1,1)
      call SaveInteger(udg_NS,3,0,3)
      call SaveInteger(udg_NS,3,1,1)
      call SaveInteger(udg_NC,0,1,1)
      call SaveInteger(udg_NC,1,1,1)
      call SaveInteger(udg_NC,2,1,1)
      call SaveInteger(udg_NC,3,1,1)
    endif
    if(udg_which==2) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,1)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,0)
      call SaveInteger(udg_NS,2,1,2)
      call SaveInteger(udg_NS,3,0,1)
      call SaveInteger(udg_NS,3,1,2)
      call SaveInteger(udg_NC,0,1,2)
      call SaveInteger(udg_NC,1,1,2)
      call SaveInteger(udg_NC,0,2,2)
      call SaveInteger(udg_NC,1,2,2)
    endif
    if(udg_which==3) then
      call SaveInteger(udg_NS,0,0,1)
      call SaveInteger(udg_NS,0,1,0)
      call SaveInteger(udg_NS,1,0,0)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,1)
      call SaveInteger(udg_NS,2,1,1)
      call SaveInteger(udg_NS,3,0,1)
      call SaveInteger(udg_NS,3,1,2)
      call SaveInteger(udg_NC,1,0,3)
      call SaveInteger(udg_NC,0,1,3)
      call SaveInteger(udg_NC,1,1,3)
      call SaveInteger(udg_NC,1,2,3)
    endif
    if(udg_which==4) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,1)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,1)
      call SaveInteger(udg_NS,2,1,2)
      call SaveInteger(udg_NS,3,0,2)
      call SaveInteger(udg_NS,3,1,2)
      call SaveInteger(udg_NC,0,1,4)
      call SaveInteger(udg_NC,1,1,4)
      call SaveInteger(udg_NC,1,2,4)
      call SaveInteger(udg_NC,2,2,4)
    endif
    if(udg_which==5) then
      call SaveInteger(udg_NS,0,0,1)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,2)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,0)
      call SaveInteger(udg_NS,2,1,2)
      call SaveInteger(udg_NS,3,0,1)
      call SaveInteger(udg_NS,3,1,2)
      call SaveInteger(udg_NC,1,1,5)
      call SaveInteger(udg_NC,2,1,5)
      call SaveInteger(udg_NC,0,2,5)
      call SaveInteger(udg_NC,1,2,5)
    endif
    if(udg_which==6) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,0)
      call SaveInteger(udg_NS,1,1,2)
      call SaveInteger(udg_NS,2,0,1)
      call SaveInteger(udg_NS,2,1,2)
      call SaveInteger(udg_NS,3,0,2)
      call SaveInteger(udg_NS,3,1,2)
      call SaveInteger(udg_NC,0,1,6)
      call SaveInteger(udg_NC,0,2,6)
      call SaveInteger(udg_NC,1,2,6)
      call SaveInteger(udg_NC,2,2,6)
    endif
    if(udg_which==7) then
      call SaveInteger(udg_NS,0,0,0)
      call SaveInteger(udg_NS,0,1,1)
      call SaveInteger(udg_NS,1,0,1)
      call SaveInteger(udg_NS,1,1,1)
      call SaveInteger(udg_NS,2,0,2)
      call SaveInteger(udg_NS,2,1,1)
      call SaveInteger(udg_NS,3,0,0)
      call SaveInteger(udg_NS,3,1,2)
      call SaveInteger(udg_NC,0,1,7)
      call SaveInteger(udg_NC,1,1,7)
      call SaveInteger(udg_NC,2,1,7)
      call SaveInteger(udg_NC,0,2,7)
    endif
endfunction
function InvalidateCurrent takes nothing returns nothing
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    local integerb1
    local integerb2
    local integerb3
    local integerb4
    local integerc1
    local integerc2
    local integerc3
    local integerc4
    local image fp
    set x1 = LoadInteger(udg_AS,0,0)
    set x2 = LoadInteger(udg_AS,1,0)
    set x3 = LoadInteger(udg_AS,2,0)
    set x4 = LoadInteger(udg_AS,3,0)
    set y1 = LoadInteger(udg_AS,0,1)
    set y2 = LoadInteger(udg_AS,1,1)
    set y3 = LoadInteger(udg_AS,2,1)
    set y4 = LoadInteger(udg_AS,3,1)
    set b1= LoadInteger(udg_GS,x1,y1)
    set b2= LoadInteger(udg_GS,x2,y2)
    set b3= LoadInteger(udg_GS,x3,y3)
    set b4= LoadInteger(udg_GS,x4,y4)
    set c1= LoadInteger(udg_GC,x1,y1)
    set c2= LoadInteger(udg_GC,x2,y2)
    set c3= LoadInteger(udg_GC,x3,y3)
    set c4= LoadInteger(udg_GC,x4,y4)
    if (b1>=1) then
      set fp=LoadImageHandle(udg_FP,x1,y1)
      call SetColorG(x1,y1,c1)
      call ShowImage(fp,true)
    else
      set fp=LoadImageHandle(udg_FP,x1,y1)
      call ShowImage(fp,false)
    endif
    if (b2>=1) then
      set fp=LoadImageHandle(udg_FP,x2,y2)
      call SetColorG(x2,y2,c2)
      call ShowImage(fp,true)
    else
      set fp=LoadImageHandle(udg_FP,x2,y2)
      call ShowImage(fp,false)
    endif
    if (b3>=1) then
      set fp=LoadImageHandle(udg_FP,x3,y3)
      call SetColorG(x3,y3,c3)
      call ShowImage(fp,true)
    else
      set fp=LoadImageHandle(udg_FP,x3,y3)
      call ShowImage(fp,false)
    endif
    if (b4>=1) then
      set fp=LoadImageHandle(udg_FP,x4,y4)
      call SetColorG(x4,y4,c4)
      call ShowImage(fp,true)
    else
      set fp=LoadImageHandle(udg_FP,x4,y4)
      call ShowImage(fp,false)
    endif
   
   
    set fp=null
   
endfunction


function InvalidateRect takes nothing returns nothing
   
    local integeri
    local integerin
    local integerj
    local integerjn
    local integerb
    local integerc
    local image fp
   
    set i=0
    set in=udg_iRow-1
    loop
      exitwhen i>in
      set j=0
      set jn=udg_iCol-1
      loop
            exitwhen j>jn
            set b=LoadInteger(udg_GS,i,j)
            set c=LoadInteger(udg_GC,i,j)
            if (b>=1) then
                set fp=LoadImageHandle(udg_FP,i,j)
                call SetColorG(i,j,c)
                call ShowImage(fp,true)
            else
                set fp=LoadImageHandle(udg_FP,i,j)
                call ShowImage(fp,false)
            endif
            
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set fp=null
   
    //return
endfunction
function InvalidateNext takes nothing returns nothing
   
    local integeri
    local integerin
    local integerj
    local integerjn
    local integerb
    local integerc
    local image fp
   
    set i=0
    set in=3
    loop
      exitwhen i>in
      set j=0
      set jn=3
      loop
            exitwhen j>jn
            set b=LoadInteger(udg_NGS,i,j)
            set c=LoadInteger(udg_NC,i,j)
            if (b>=1) then
                set fp=LoadImageHandle(udg_NP,i,j)
                call SetColorN(i,j,c)
                call ShowImage(fp,true)
            else
                set fp=LoadImageHandle(udg_NP,i,j)
                call ShowImage(fp,false)
            endif
            
            
            
            
            set j=j+1
      endloop
      set i=i+1
    endloop
    set fp=null
   
    //return
endfunction


function ActiveIsBottom takes nothing returns nothing
   
    //到底有两种概念:1是已到底部,2是下面碰到了另外的方块
   
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integerx
    local integerxx
    local integeryy
    local integeri
    local integerj
    local integerk
    local integer clevel
    local integer iMuch=0
    local real   tr
    local boolean bIsSucced
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      set udg_bABrun=TRUE
      set x1 = LoadInteger(udg_AS,0,0)
      set x2 = LoadInteger(udg_AS,1,0)
      set x3 = LoadInteger(udg_AS,2,0)
      set x4 = LoadInteger(udg_AS,3,0)
      
      //已到底
      //如果下面碰到了另外的方块
      //一个方块分为四个小方块,只有这样的小方块下面有另外的方块才算到底,这样的小方块满足条件如下:
      //它的下面不再有本方块的另外的小方块
      //用算法描述为:y坐标相等的一组小方块中的最下面的哪个小方块, 我称之为接触面
      
      if (x1>=(udg_iRow-1) or(x2>=udg_iRow-1) or (x3>=udg_iRow-1) or (x4>=udg_iRow-1))   then
            set udg_isBottom = TRUE
      else
            set i=0
            loop
                exitwhen i>=4
                if(LoadInteger(udg_IF,udg_currentRect,i) > -1) then
                  set x=LoadInteger(udg_IF,udg_currentRect,i)
                  set xx=LoadInteger(udg_AS,x,0)+1
                  set yy=LoadInteger(udg_AS,x,1)
                  if (LoadInteger(udg_GS,xx,yy)>=1) then
                        set udg_isBottom = TRUE
                  endif
                endif
                set i=i+1
            endloop
      endif
      
      //本次销掉的行数
      
      //计分规则:一次销掉一行,加100分,一次销掉两行,加400分,三行,900分
      //例如销掉x行,则分数为:x*(x*100)
      
      
      //判断是否已得分
      
      
      
      if (udg_isBottom) then
            
            //       set i=0
            ///      loop
            //          exitwhen i>=udg_iRow
            //          set bIsSucced = TRUE
            //         set udg_bS=TRUE
            //         set j=0
            //       loop
            //       exitwhen j>=udg_iCol
            //      if (LoadInteger(udg_GS,i,j)==0) then
            //          set bIsSucced = FALSE
            ///          set udg_bS=FALSE
            //      endif
            //            set j=j+1
            //      endloop
            //      if (bIsSucced) then
            //          set udg_bFlash=TRUE
            //         call PauseTimer(udg_GTimer)
            //         set udg_bloop=false
            //          set udg_k=0
            //      call TimerStart(udg_Flash,0.1,true,function FlashLine)
            //
            //         call PolledWait(0.6)
            //      call PauseTimer(udg_Flash)
            //      call ResumeTimer(udg_GTimer)
            //      set udg_bFlash=FALSE
            
            //      endif
            //       set i=i+1
            //       endloop
            
            set i=0
            loop
                exitwhen i>=udg_iRow
                set bIsSucced = TRUE
               
                set j=0
                loop
                  exitwhen j>=udg_iCol
                  if (LoadInteger(udg_GS,i,j)==0) then
                        set bIsSucced = FALSE
                        
                  endif
                  set j=j+1
                endloop
                if (bIsSucced) then
                  set k=i
                  loop
                        exitwhen k<=0
                        set j=0
                        
                        
                        loop
                            exitwhen j>=udg_iCol
                            call SaveInteger(udg_GS,k,j,LoadInteger(udg_GS,k-1,j))
                            call SaveInteger(udg_GC,k,j,LoadInteger(udg_GC,k-1,j))
                            set j=j+1
                        endloop
                        
                        set k=k-1
                  endloop
                  set j=0
                  loop
                        exitwhen j>=udg_iCol
                        call SaveInteger(udg_GS,0,j,0)
                        
                        set j=j+1
                  endloop
                  setiMuch=iMuch+1
                endif
               
               
               
               
                set i=i+1
            endloop
            
            
            
            
            
            if (iMuch>0) then
               
                if(iMuch<4) then
                  call PlaySoundBJ( gg_snd_deblock)
                else
                  call PlaySoundBJ( gg_snd_tetris)
                endif
                //刷新游戏区域
               
                call   InvalidateRect()
               
                //   //刷新分数区域
                set udg_iPerformance =udg_iPerformance+iMuch * iMuch * udg_Value
                call SetScore(udg_iPerformance)
                set clevel=LevelCheck(udg_iPerformance)
                if(clevel>udg_iLevel)then
                  if (udg_iLevel<=5 andclevel>=6) then
                        callStopMusic(TRUE)
                        call ClearMapMusicBJ()
                        call SetMapMusicIndexedBJ( gg_snd_BWing, 0 )
                        call PlayMusicBJ( gg_snd_BWing )
                  endif
                  call PlaySoundBJ( gg_snd_levelup)
                  setudg_iLevel=clevel
                  call SetLevel(udg_iLevel)
                  
                endif
               
            endif
            
      endif
      set udg_bABrun=FALSE
    endif
   
endfunction


function RectDown takes nothing returns nothing
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    local integerc1
    local integerc2
    local integerc3
    local integerc4
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      call ActiveIsBottom()
      if (not udg_isBottom) then
            //清除以前的方块
            
            
            set x1 = LoadInteger(udg_AS,0,0)
            set x2 = LoadInteger(udg_AS,1,0)
            set x3 = LoadInteger(udg_AS,2,0)
            set x4 = LoadInteger(udg_AS,3,0)
            set y1 = LoadInteger(udg_AS,0,1)
            set y2 = LoadInteger(udg_AS,1,1)
            set y3 = LoadInteger(udg_AS,2,1)
            set y4 = LoadInteger(udg_AS,3,1)
            set c1= LoadInteger(udg_GC,x1,y1)
            set c2= LoadInteger(udg_GC,x2,y2)
            set c3= LoadInteger(udg_GC,x3,y3)
            set c4= LoadInteger(udg_GC,x4,y4)
            call SaveInteger(udg_GS,x1,y1,0)
            call SaveInteger(udg_GS,x2,y2,0)
            call SaveInteger(udg_GS,x3,y3,0)
            call SaveInteger(udg_GS,x4,y4,0)
            call InvalidateCurrent()
            
            //方块下落
            set x1=x1+1
            set x2=x2+1
            set x3=x3+1
            set x4=x4+1
            call SaveInteger(udg_AS,0,0,x1)
            call SaveInteger(udg_AS,1,0,x2)
            call SaveInteger(udg_AS,2,0,x3)
            call SaveInteger(udg_AS,3,0,x4)
            call SaveInteger(udg_GC,x1,y1,c1)
            call SaveInteger(udg_GC,x2,y2,c2)
            call SaveInteger(udg_GC,x3,y3,c3)
            call SaveInteger(udg_GC,x4,y4,c4)
            call SaveInteger(udg_GS,x1,y1,1)
            call SaveInteger(udg_GS,x2,y2,1)
            call SaveInteger(udg_GS,x3,y3,1)
            call SaveInteger(udg_GS,x4,y4,1)
            
            call InvalidateCurrent()
      else
            call PlaySoundBJ( gg_snd_bottom )
            
      endif
    endif
endfunction

function RectChange takes nothing returns nothing
   
   
    //先预先变形,然后判断变形后的方块是否有空间,如有足够空间,则进行实际变形,否则不变
    local integerxx1
    local integerxx2
    local integerxx3
    local integerxx4
    local integeryy1
    local integeryy2
    local integeryy3
    local integeryy4
    local integeriscurrentRect
    //local booleanbb=TRUE
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    local integerc1
    local integerc2
    local integerc3
    local integerc4
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      set x1 = LoadInteger(udg_AS,0,0)
      set x2 = LoadInteger(udg_AS,1,0)
      set x3 = LoadInteger(udg_AS,2,0)
      set x4 = LoadInteger(udg_AS,3,0)
      set y1 = LoadInteger(udg_AS,0,1)
      set y2 = LoadInteger(udg_AS,1,1)
      set y3 = LoadInteger(udg_AS,2,1)
      set y4 = LoadInteger(udg_AS,3,1)
      set c1= LoadInteger(udg_GC,x1,y1)
      set c2= LoadInteger(udg_GC,x2,y2)
      set c3= LoadInteger(udg_GC,x3,y3)
      set c4= LoadInteger(udg_GC,x4,y4)
      
      
      
      
      //变形后位置在数组中的存放顺序仍需遵循先左后右,在同一列中先上后下
      set xx1=x1
      set xx2=x2
      set xx3=x3
      set xx4=x4
      set yy1=y1
      set yy2=y2
      set yy3=y3
      set yy4=y4
      
      if(udg_currentRect==1) then
            set xx1=x1+1
            set yy1=y1-1
            set xx3=x3-1
            set yy3=y3+1
            set xx4=x4-2
            set yy4=y4+2
            set iscurrentRect=11
      endif
      if(udg_currentRect==11) then
            set xx1=x1-1
            set yy1=y1+1
            set xx3=x3+1
            set yy3=y3-1
            set xx4=x4+2
            set yy4=y4-2
            set iscurrentRect=1
      endif
      if(udg_currentRect==2) then
            set iscurrentRect=2
      endif
      if(udg_currentRect==3) then
            set xx1=x2
            set yy1=y2
            set xx2=x3
            set xx3=x3+1
            set iscurrentRect=31
      endif
      if(udg_currentRect==31) then
            set xx1=x2
            set yy1=y1-1
            set iscurrentRect=32
      endif
      if(udg_currentRect==32) then
            set xx2=x2-1
            set xx3=x2
            set xx4=x3
            set yy4=y3
            set iscurrentRect=33
      endif
      if(udg_currentRect==33) then
            
            
            set xx4=x4-1
            set yy4=y4+1
            set iscurrentRect=3
      endif
      
      if(udg_currentRect==4) then
            set xx1=x4
            set yy2=y3
            set xx3=x4
            set xx4=x2
            set yy4=y4+1
            set iscurrentRect=41
      endif
      if(udg_currentRect==41) then
            set xx1=x1-2
            set yy2=y1
            set xx3=x2
            set xx4=x3
            set yy4=y3
            set iscurrentRect=4
      endif
      if(udg_currentRect==5) then
            set yy1=y1-1
            set xx2=x1
            set xx3=x2
            set yy3=y2
            set xx4=x2
            set iscurrentRect=51
      endif
      if(udg_currentRect==51) then
            set yy1=y2
            set xx2=x3
            set xx3=x3-2
            set yy3=y4
            set xx4=x2
            set iscurrentRect=5
      endif
      if(udg_currentRect==6) then
            set xx1=x1+1
            set xx2=x4
            set yy2=y1
            set xx4=x3
            set yy4=y4+1
            set iscurrentRect=61
      endif
      if(udg_currentRect==61) then
            set xx1=x1-1
            set yy1=y3
            set xx2=x3
            set yy2=y3
            set xx3=x2
            set xx4=x2
            set iscurrentRect=62
      endif
      if(udg_currentRect==62) then
            set xx1=x2
            set yy1=y1-1
            set xx3=x1
            set yy3=y4
            set xx4=x2
            set iscurrentRect=63
      endif
      if(udg_currentRect==63) then
            set xx1=x3
            set xx2=x3
            set xx3=x2
            set yy3=y2
            set xx4=x4+1
            set yy4=y2
            set iscurrentRect=6
      endif
      if(udg_currentRect==7) then
            set yy1=y1-1
            set yy2=y2-1
            set xx3=x2
            set xx4=x2
            set iscurrentRect=71
      endif
      if(udg_currentRect==71) then
            set xx1=x1+2
            set xx2=x1
            set yy2=y3
            set xx4=x4+1
            set yy4=y3
            set iscurrentRect=72
      endif
      if(udg_currentRect==72) then
            set xx1=x3
            set xx2=x3
            set yy3=y3+1
            set yy4=y4+1
            set iscurrentRect=73
      endif
      if(udg_currentRect==73) then
            set xx1=x1-1
            set yy1=y2
            set xx3=x4
            set yy3=y2
            set xx4=x4-2
            set iscurrentRect=7
      endif
      
      
      
      
      //如果变形后所在的区域内无其他方块,则表示有足够空间,可以变形
      //且不能超越边界
      call SaveInteger(udg_GS,x1,y1,0)
      call SaveInteger(udg_GS,x2,y2,0)
      call SaveInteger(udg_GS,x3,y3,0)
      call SaveInteger(udg_GS,x4,y4,0)
      if (LoadInteger(udg_GS,xx1,yy1)==0 and LoadInteger(udg_GS,xx2,yy2)==0 and LoadInteger(udg_GS,xx3,yy3)==0 andLoadInteger(udg_GS,xx4,yy4)==0 and yy1>=0 and yy4<=(udg_iCol-1) and xx1>=0 and xx2>=0 and xx3>=0 and xx4>=0 and xx1<=udg_iRow and xx2<=udg_iRow and xx3<=udg_iRow and xx4<=udg_iRow ) then
            
            call InvalidateCurrent()
            
            call SaveInteger(udg_AS,0,0,xx1)
            call SaveInteger(udg_AS,1,0,xx2)
            call SaveInteger(udg_AS,2,0,xx3)
            call SaveInteger(udg_AS,3,0,xx4)
            call SaveInteger(udg_AS,0,1,yy1)
            call SaveInteger(udg_AS,1,1,yy2)
            call SaveInteger(udg_AS,2,1,yy3)
            call SaveInteger(udg_AS,3,1,yy4)
            call SaveInteger(udg_GC,xx1,yy1,c1)
            call SaveInteger(udg_GC,xx2,yy2,c2)
            call SaveInteger(udg_GC,xx3,yy3,c3)
            call SaveInteger(udg_GC,xx4,yy4,c4)
            call SaveInteger(udg_GS,xx1,yy1,1)
            call SaveInteger(udg_GS,xx2,yy2,1)
            call SaveInteger(udg_GS,xx3,yy3,1)
            call SaveInteger(udg_GS,xx4,yy4,1)
            
            
            call InvalidateCurrent()
            
            //改变形状代码
            set udg_currentRect = iscurrentRect
            
      else
            call SaveInteger(udg_GS,x1,y1,1)
            call SaveInteger(udg_GS,x2,y2,1)
            call SaveInteger(udg_GS,x3,y3,1)
            call SaveInteger(udg_GS,x4,y4,1)
      endif
      //判断是否已到底
      call PlaySoundBJ( gg_snd_change)
      call ActiveIsBottom()
    endif
endfunction
function RectArrow takes integer tp returns nothing
    local integerx1
    local integerx2
    local integerx3
    local integerx4
    local integery1
    local integery2
    local integery3
    local integery4
    local integerc1
    local integerc2
    local integerc3
    local integerc4
    if (udg_bGameEnd==FALSE and udg_bFlash==FALSE and udg_bABrun==FALSE) then
      set x1 = LoadInteger(udg_AS,0,0)
      set x2 = LoadInteger(udg_AS,1,0)
      set x3 = LoadInteger(udg_AS,2,0)
      set x4 = LoadInteger(udg_AS,3,0)
      set y1 = LoadInteger(udg_AS,0,1)
      set y2 = LoadInteger(udg_AS,1,1)
      set y3 = LoadInteger(udg_AS,2,1)
      set y4 = LoadInteger(udg_AS,3,1)
      set c1= LoadInteger(udg_GC,x1,y1)
      set c2= LoadInteger(udg_GC,x2,y2)
      set c3= LoadInteger(udg_GC,x3,y3)
      set c4= LoadInteger(udg_GC,x4,y4)
      
      //如果方块已到底则不能再移动
      if (tp==0) then
            call PlaySoundBJ( gg_snd_move )
            if(y1>0 and LeftIsLimit() and (not udg_isBottom)) then
                call SaveInteger(udg_GS,x1,y1,0)
                call SaveInteger(udg_GS,x2,y2,0)
                call SaveInteger(udg_GS,x3,y3,0)
                call SaveInteger(udg_GS,x4,y4,0)
                call InvalidateCurrent()
                set y1=y1-1
                set y2=y2-1
                set y3=y3-1
                set y4=y4-1
                call SaveInteger(udg_AS,0,1,y1)
                call SaveInteger(udg_AS,1,1,y2)
                call SaveInteger(udg_AS,2,1,y3)
                call SaveInteger(udg_AS,3,1,y4)
                call SaveInteger(udg_GC,x1,y1,c1)
            call SaveInteger(udg_GC,x2,y2,c2)
            call SaveInteger(udg_GC,x3,y3,c3)
            call SaveInteger(udg_GC,x4,y4,c4)
                call SaveInteger(udg_GS,x1,y1,1)
                call SaveInteger(udg_GS,x2,y2,1)
                call SaveInteger(udg_GS,x3,y3,1)
                call SaveInteger(udg_GS,x4,y4,1)
                call InvalidateCurrent()
               
            endif
            
      endif
      if (tp==1) then
            call PlaySoundBJ( gg_snd_move )
            if(y4<(udg_iCol-1) and RightIsLimit() and (not udg_isBottom)) then
                call SaveInteger(udg_GS,x1,y1,0)
                call SaveInteger(udg_GS,x2,y2,0)
                call SaveInteger(udg_GS,x3,y3,0)
                call SaveInteger(udg_GS,x4,y4,0)
                call InvalidateCurrent()
                set y1=y1+1
                set y2=y2+1
                set y3=y3+1
                set y4=y4+1
                call SaveInteger(udg_AS,0,1,y1)
                call SaveInteger(udg_AS,1,1,y2)
                call SaveInteger(udg_AS,2,1,y3)
                call SaveInteger(udg_AS,3,1,y4)
                call SaveInteger(udg_GC,x1,y1,c1)
                call SaveInteger(udg_GC,x2,y2,c2)
                call SaveInteger(udg_GC,x3,y3,c3)
                call SaveInteger(udg_GC,x4,y4,c4)
                call SaveInteger(udg_GS,x1,y1,1)
                call SaveInteger(udg_GS,x2,y2,1)
                call SaveInteger(udg_GS,x3,y3,1)
                call SaveInteger(udg_GS,x4,y4,1)
                call InvalidateCurrent()
               
            endif
            
      endif
      
      if (tp==2) then
            call PlaySoundBJ( gg_snd_down )
            call RectDown()
            
      endif
    endif
   
endfunction


function GameOver takes nothing returns nothing
    local integer i
    local integer j
    call PauseTimer(udg_GTimer)
    call StopMusic(FALSE)
    call ClearMapMusic()
    call PlaySoundBJ( gg_snd_gameover )
    set i=0
    loop
      exitwhen i>=udg_iRow
      set j=0
      loop
            exitwhen j>=udg_iCol
            
            call SaveInteger(udg_GS,i,j,1)
            call SaveInteger(udg_GC,i,j,3)
            set j=j+1
      endloop
      set i=i+1
    endloop
    call SaveInteger(udg_GS,0,1,0)
    call SaveInteger(udg_GS,0,6,0)
    call SaveInteger(udg_GS,0,8,0)
    call SaveInteger(udg_GS,1,2,0)
    call SaveInteger(udg_GS,1,3,0)
    call SaveInteger(udg_GS,1,7,0)
    call SaveInteger(udg_GS,2,2,0)
    call SaveInteger(udg_GS,3,2,0)
    call SaveInteger(udg_GS,3,7,0)
    call SaveInteger(udg_GS,4,1,0)
    call SaveInteger(udg_GS,4,7,0)
    call SaveInteger(udg_GS,5,2,0)
    call SaveInteger(udg_GS,6,7,0)
    call SaveInteger(udg_GS,6,8,0)
    call SaveInteger(udg_GS,7,2,0)
    call SaveInteger(udg_GS,8,2,0)
    call SaveInteger(udg_GS,8,7,0)
    call SaveInteger(udg_GS,8,8,0)
    call SaveInteger(udg_GS,9,2,0)
    call SaveInteger(udg_GS,10,1,0)
    call SaveInteger(udg_GS,10,3,0)
    call SaveInteger(udg_GS,10,7,0)
    call SaveInteger(udg_GS,11,2,0)
    call SaveInteger(udg_GS,11,7,0)
    call SaveInteger(udg_GS,12,2,0)
    call SaveInteger(udg_GS,12,7,0)
    call SaveInteger(udg_GS,13,2,0)
    call SaveInteger(udg_GS,14,1,0)
    call SaveInteger(udg_GS,14,3,0)
    call SaveInteger(udg_GS,14,6,0)
    call SaveInteger(udg_GS,14,8,0)
    call SaveInteger(udg_GS,15,8,0)
    call SaveInteger(udg_GS,16,2,0)
    call SaveInteger(udg_GS,16,3,0)
    call SaveInteger(udg_GS,16,7,0)
    call SaveInteger(udg_GS,17,8,0)
    call SaveInteger(udg_GS,18,2,0)
    call SaveInteger(udg_GS,18,3,0)
    call SaveInteger(udg_GS,18,7,0)
    call SaveInteger(udg_GS,19,7,0)
    set i=0
    loop
      exitwhen i>=udg_iRow
      
      
      
      call SaveInteger(udg_GS,i,0,0)
      call SaveInteger(udg_GS,i,4,0)
      call SaveInteger(udg_GS,i,5,0)
      call SaveInteger(udg_GS,i,9,0)
      
      set i=i+1
    endloop
   
    call InvalidateRect()
    set i=0
   
    loop
      exitwhen(i>=100)
      set j=0
      loop
            exitwhen (j>=100)
            call SaveInteger(udg_GS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
   
    loop
      exitwhen(i>=4)
      set j=0
      loop
            exitwhen (j>=4)
            call SaveInteger(udg_NGS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
   
    loop
      exitwhen(i>=5)
      set j=0
      loop
            exitwhen (j>=15)
            call SaveInteger(udg_LS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    set i=0
   
    loop
      exitwhen(i>=5)
      set j=0
      loop
            exitwhen (j>=15)
            call SaveInteger(udg_SS,i,j,0)
            set j=j+1
      endloop
      set i=i+1
    endloop
    // call EnableTrigger( gg_trg_GameStart )
    //return
endfunction

vivid 发表于 2010-1-21 12:08:08

hmmm,厉害……
加油!

actboy168 发表于 2010-1-21 12:32:30

那个绿字能隔一格,会看得清楚些。

既然做成彩色的,为什么不把不同的形状加不同颜色呢

eff 发表于 2010-1-21 12:32:38

超级玛丽可是很难做的

wfr_tc 发表于 2010-1-21 12:33:38

难道是用坐标????

活宝 发表于 2010-1-21 13:02:50

引用第6楼wfr_tc于2010-01-21 12:33发表的:
难道是用坐标???? images/back.gif


是的。
引用第4楼actboy168于2010-01-21 12:32发表的:
那个绿字能隔一格,会看得清楚些。

既然做成彩色的,为什么不把不同的形状加不同颜色呢 images/back.gif

嗯,好的,下次再改进。

hjistc 发表于 2010-1-21 13:29:24

...太可怕了....
这何等...高技术...
压力好大

活宝 发表于 2010-1-21 13:35:10

呃……其实最关键的技术是头目发明的,我只是改造了一下而已……

hjistc 发表于 2010-1-21 13:48:57

= = 头目那个...还比较好理解 = =
而俄罗斯方块的程序我完全不知道怎么回事了...
不过可能学编程的人做过 会比较熟悉 - -

活宝 发表于 2010-1-21 15:52:29

哦,我说的关键技术指的是图形引擎,要不是头目谁都很难想到原来还可以那样做。至于俄罗斯方块本身经过20多年应该已经是很成熟了的……

血戮魔动冰 发表于 2010-1-22 06:53:41

除了彩色方块以外我看见的都是白色。
连范围都没有看见。
1.24c的版本。

活宝 发表于 2010-1-22 09:58:14

咦?奇怪了,俺的也是1.24的(不过是1.24d,但对WE应该没影响啊)……
如果真的不能显示的话,您可以把那几个Draw函数拆开,然后用wait隔开试试……以前把它们放在一起的时候会出现超过函数执行上限的问题,后来拆成三段以后就再没出现过那样的问题了……

刀锋战士 发表于 2010-1-22 22:17:41

真好,又有另人耳目一新的地图出现.

gason 发表于 2010-1-22 22:20:05

嗯,希望论坛能越办越好。

活宝 发表于 2010-1-31 20:45:00

引用第12楼血戮魔动冰于2010-01-22 06:53发表的:
除了彩色方块以外我看见的都是白色。
连范围都没有看见。
1.24c的版本。 images/back.gif

噢,我想到了,不是版本的问题……好像是需要把游戏选项中的纹理质量设为“高”才能看得见背景……

hongchen 发表于 2010-3-26 19:56:06

相当的精彩,下载中..

hongchen 发表于 2010-3-26 20:37:32



无奈只打到6

活宝 发表于 2010-4-1 12:21:54

啊,新纪录。恭喜楼上了……
页: [1] 2
查看完整版本: [模拟][2D]小霸王系统演示之俄罗斯方块