回 帖 发 新 帖 刷新版面

主题:最强 扫雷 源码

虽然还没有做完(英雄版和帮助还没写,这些都是小问题),不过已经可以运行了。
是RPG的哦!还可以购买装备……
如果你是用的QuickBasic,可以试试改成鼠标控制

DEFINT A-Z

TYPE typeUser
    userName AS STRING * 8
    userLevel AS INTEGER
    userMoney AS LONG
    userTools AS LONG
    userLife AS INTEGER
    userIndex AS INTEGER
    userMode AS INTEGER
    userReserve AS STRING * 104
END TYPE

TYPE typeSize
    sizeWidth AS INTEGER
    sizeHeight AS INTEGER
END TYPE

TYPE typeElement
    gameData AS INTEGER
    gameState AS INTEGER
END TYPE

TYPE typePoint
    x AS INTEGER
    y AS INTEGER
END TYPE


TYPE typeMessage
    message AS INTEGER
    lpara AS INTEGER
    wpara AS INTEGER
END TYPE

DECLARE SUB LoadUser (uname$)
DECLARE SUB SaveUser ()
DECLARE SUB CreateBomb (x, y)
DECLARE FUNCTION isWin% ()
DECLARE FUNCTION isBomb% (x, y)
DECLARE FUNCTION isFlag% (x, y)
DECLARE FUNCTION isData% (x, y)
DECLARE FUNCTION GetGameData% (x, y)
DECLARE FUNCTION GetGameState% (x, y)
DECLARE FUNCTION GetToolsNum% (ts&)
DECLARE SUB SetToolsNum (ts&, num&)
DECLARE SUB SetGameData (x, y, d)
DECLARE SUB SetGameState (x, y, s)
DECLARE SUB InitDataStatic ()
DECLARE SUB InitDataDynamic ()
DECLARE SUB DataEngine (cmd$, lpara%, wpara%)
DECLARE SUB InterfaceEngine (cmd$, lpara%, wpara%)
DECLARE FUNCTION InputEngine$ (cmd$, msg$, x, y, l)
DECLARE SUB ColorEngine (cmd$, c, r, g, B)
DECLARE SUB Refresh ()
DECLARE SUB DrawBox (x, y, w, h, cb, cd)
DECLARE SUB FillBox (x, y, w, h, cb, cd, cf)
DECLARE SUB MainFrame ()

CONST CFileUser$ = "user.cb2"

CONST CMaxLevel% = 100

DIM SHARED AlphaMap%(34, 9)
DIM SHARED ObjectMap%(66, 8)
DIM SHARED GameCore(w, h) AS typeElement
DIM SHARED GameMonitor%(w, h)
DIM SHARED LevelBomb%(CMaxLevel%)
DIM SHARED LevelSize(CMaxLevel%) AS typeSize
DIM SHARED LevelTime%(CMaxLevel%)
DIM SHARED LevelLife%(CMaxLevel%)
DIM SHARED PriceTools%(7)
DIM SHARED SystemPalette%(48)
DIM SHARED LeftTop AS typePoint
DIM SHARED CurrentPoint AS typePoint
DIM SHARED CurrentUser AS typeUser
DIM SHARED bCreateBomb%
DIM SHARED iCounter%
DIM SHARED bNewUser%
DIM SHARED DynamicBombs%

'------------------------------------------
DATA 0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,7,8,0,0,0,0,0,0,0
DATA 0,0,7,0,0,0,0,7,8,0,0,0,7,0,0,0
DATA 0,0,0,7,0,7,7,7,7,7,0,7,8,0,0,0
DATA 0,0,0,0,7,7,7,7,7,7,7,8,0,0,0,0
DATA 0,0,0,7,7,15,15,7,7,7,7,7,0,0,0,0
DATA 0,0,0,7,7,15,15,7,7,7,7,7,8,0,0,0
DATA 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0
DATA 0,8,8,7,7,7,7,7,7,7,8,7,8,8,8,8
DATA 0,0,0,7,7,7,7,7,7,8,8,7,8,0,0,0
DATA 0,0,0,0,7,7,7,7,7,7,7,8,0,0,0,0
DATA 0,0,0,7,8,7,7,7,7,7,8,7,0,0,0,0
DATA 0,0,7,8,0,0,8,7,8,8,0,0,7,0,0,0
DATA 0,0,8,0,0,0,0,7,8,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,7,8,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0

'------------------------------------------
DATA 3,3,3,3,3,3,3,7,3,3,3,3,3,3,3,3
DATA 3,3,3,3,3,3,3,7,8,3,3,3,3,3,3,3
DATA 3,3,7,3,3,3,3,7,8,3,3,3,7,3,3,3
DATA 3,3,3,7,3,7,7,7,7,7,3,7,8,3,3,3
DATA 3,3,3,3,7,7,7,7,7,7,7,8,3,3,3,3
DATA 3,3,3,7,7,15,15,7,7,7,7,7,3,3,3,3
DATA 3,3,3,7,7,15,15,7,7,7,7,7,8,3,3,3
DATA 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,3
DATA 3,8,8,7,7,7,7,7,7,7,8,7,8,8,8,8
DATA 3,3,3,7,7,7,7,7,7,8,8,7,8,3,3,3
DATA 3,3,3,3,7,7,7,7,7,7,7,8,3,3,3,3
DATA 3,3,3,7,8,7,7,7,7,7,8,7,3,3,3,3
DATA 3,3,7,8,3,3,8,7,8,8,3,3,7,3,3,3
DATA 3,3,8,3,3,3,3,7,8,3,3,3,3,3,3,3
DATA 3,3,3,3,3,3,3,7,8,3,3,3,3,3,3,3
DATA 3,3,3,3,3,3,3,3,8,3,3,3,3,3,3,3

'------------------------------------------
DATA 0,0,15,8,8,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,15,8,3,8,0,0,0,0,0,0,0,0,0,0
DATA 0,0,15,8,3,3,8,0,0,0,0,0,0,0,0,0
DATA 0,0,15,8,3,3,3,8,0,0,0,0,0,0,0,0
DATA 0,0,15,8,3,3,3,3,8,0,0,0,0,0,0,0
DATA 0,0,15,8,3,3,3,3,3,8,0,0,0,0,0,0
DATA 0,0,15,8,3,3,3,3,3,3,8,0,0,0,0,0
DATA 0,0,15,8,3,3,3,3,3,3,3,8,0,0,0,0
DATA 0,0,15,8,3,3,3,3,3,3,3,3,8,0,0,0
DATA 0,0,15,8,8,8,8,8,8,8,8,8,8,8,0,0
DATA 0,0,15,8,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,15,8,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,15,8,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,15,8,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,15,15,8,8,0,0,0,0,0,0,0,0,0,0,0
DATA 15,8,8,8,8,8,0,0,0,0,0,0,0,0,0,0

'------------------------------------------
DATA 0,0,0,0,15,15,15,15,0,0,0,0,0,0,0,0
DATA 0,0,15,15,8,8,8,8,15,15,0,0,0,0,0,0
DATA 0,15,8,8,1,1,1,1,1,8,8,0,0,0,0,0
DATA 0,15,8,1,15,15,15,1,1,15,8,0,0,0,0,0
DATA 15,8,1,15,15,15,1,1,1,1,15,8,0,0,0,0
DATA 15,8,1,15,15,1,1,1,1,1,15,8,0,0,0,0
DATA 15,8,1,15,1,1,1,1,15,1,15,8,0,0,0,0
DATA 15,8,1,1,1,1,1,15,15,1,15,8,0,0,0,0
DATA 0,15,8,1,1,1,15,1,1,15,8,0,0,0,0,0
DATA 0,15,15,15,1,1,1,15,15,15,8,1,0,0,0,0
DATA 0,0,8,8,15,15,15,15,8,8,1,15,1,0,0,0
DATA 0,0,0,0,8,8,8,8,0,4,4,1,15,1,0,0
DATA 0,0,0,0,0,0,0,0,0,0,4,4,1,15,1,0
DATA 0,0,0,0,0,0,0,0,0,0,0,4,4,1,15,1
DATA 0,0,0,0,0,0,0,0,0,0,0,0,4,4,1,1
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,1

'------------------------------------------
DATA 0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0
DATA 0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0
DATA 0,0,0,4,4,4,0,0,0,0,0,0,0,0,0,0
DATA 0,0,1,1,1,1,4,0,0,0,0,0,0,0,0,0
DATA 0,1,15,15,1,4,4,4,0,0,0,0,0,0,0,0
DATA 0,1,15,1,1,4,4,4,0,0,0,0,0,0,0,0
DATA 0,1,15,1,1,4,4,4,0,0,0,0,0,0,0,0
DATA 0,1,15,1,1,4,4,4,0,0,0,0,0,0,0,0
DATA 0,1,3,3,3,3,4,4,0,0,0,0,0,0,0,0
DATA 0,1,15,15,15,3,0,4,1,1,1,0,0,0,0,0
DATA 14,1,3,3,3,3,4,4,15,15,15,1,4,0,2,2
DATA 14,1,15,1,1,4,4,4,1,1,1,1,4,4,2,2
DATA 14,1,15,1,1,4,8,4,1,1,1,1,4,4,2,2
DATA 14,1,1,1,1,4,8,4,4,4,4,4,4,4,2,2
DATA 14,1,1,1,1,8,8,4,4,4,4,4,4,0,2,2
DATA 0,14,4,4,4,4,4,14,14,14,14,14,0,0,0,0

'------------------------------------------
DATA 0,0,4,4,4,4,4,4,4,4,4,4,0,0,0,0
DATA 0,0,4,7,7,7,7,7,7,7,7,7,7,0,0,0
DATA 0,0,7,7,7,0,3,3,3,0,0,0,7,7,0,0
DATA 0,0,0,0,0,13,13,13,13,13,0,0,7,7,0,0
DATA 0,0,0,0,7,8,8,8,8,8,7,0,0,0,0,0
DATA 0,0,0,7,15,15,8,8,8,7,8,7,0,0,0,0
DATA 0,0,8,8,15,15,7,8,7,8,7,8,8,0,0,0
DATA 0,0,7,8,15,8,8,8,8,8,8,8,7,0,0,0
DATA 0,0,8,8,7,8,7,8,7,8,7,8,8,0,0,0
DATA 0,0,7,8,8,8,8,8,8,8,8,8,7,0,0,0
DATA 0,0,8,8,7,8,7,8,7,8,7,8,8,0,0,0
DATA 0,0,7,8,8,8,8,8,8,8,8,8,7,0,0,0
DATA 0,0,8,8,7,8,7,8,7,8,15,8,8,0,0,0
DATA 0,0,0,7,8,7,8,8,8,7,8,7,0,0,0,0
DATA 0,0,0,0,7,8,8,8,8,8,7,0,0,0,0,0
DATA 0,0,0,0,0,7,7,7,7,7,0,0,0,0,0,0

'------------------------------------------
DATA 0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0
DATA 0,7,7,1,1,15,15,15,15,15,15,1,1,7,7,0
DATA 0,7,1,15,15,15,15,15,15,15,15,15,15,1,7,0
DATA 0,1,15,15,15,15,15,3,15,15,15,15,15,15,1,0
DATA 0,1,15,15,15,15,15,3,8,15,15,15,15,15,1,0
DATA 1,15,15,15,15,15,15,3,8,15,15,15,15,15,15,1
DATA 1,15,15,15,15,15,15,3,8,15,15,15,15,15,15,1
DATA 1,15,15,15,15,15,15,3,3,3,3,3,3,15,15,1
DATA 1,15,15,15,15,15,15,15,8,8,8,8,8,8,15,1
DATA 1,15,15,15,15,15,15,15,15,15,15,15,15,15,15,1
DATA 1,15,15,15,15,15,15,15,15,15,15,15,15,15,15,1
DATA 0,1,15,15,15,15,15,15,15,15,15,15,15,15,1,0
DATA 0,1,15,15,15,15,15,15,15,15,15,15,15,15,1,0
DATA 0,7,1,15,15,15,15,15,15,15,15,15,15,1,7,0
DATA 0,7,7,1,1,15,15,15,15,15,15,1,1,7,7,0
DATA 0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0

CLEAR , , 5000
SCREEN 12
InitDataStatic

DO
    InterfaceEngine "login", 0, 0
    CurrentUser.userName = InputEngine$("input", "User Name:", 30, 10, 8)
   
    SELECT CASE RTRIM$(LTRIM$(CurrentUser.userName))
    CASE "End"
        InterfaceEngine "end", 0, 0
        ColorEngine "restore", 0, 0, 0, 0
        COLOR 15
        END
    CASE "Help"
        InterfaceEngine "help", 0, 0
        tmp$ = InputEngine$("pause", "", 0, 0, 0)
    CASE "Top"
        InterfaceEngine "top", 0, 0
        tmp$ = InputEngine$("pause", "", 0, 0, 0)
    CASE ELSE
        DO
            InterfaceEngine "menu", 30, 20
            SELECT CASE VAL(InputEngine$("menu", "3", 28, 20, 25))
            CASE 0
                LoadUser CurrentUser.userName
                DO
                    InterfaceEngine "menu rpg", 30, 20
                    SELECT CASE VAL(InputEngine$("menu", "4", 30, 20, 22))
                    CASE 0
                        IF CurrentUser.userLife = 0 THEN
                            tmp$ = InputEngine$("enter", "Sorry, you are dead!", 0, 0, 0)
                        ELSE
                            InterfaceEngine "init", 0, 0
                            InitDataDynamic
                            MainFrame
                        END IF
                    CASE 1
                        InterfaceEngine "shop", 0, 0
                        bsel% = 1
                        ssel% = 1
                        DO
                            ikey$ = INKEY$
                            IF ikey$ <> "" THEN
                                SELECT CASE LCASE$(ikey$)
                                CASE "b"
                                    InterfaceEngine "active buy", 0, 0
                                    DO
                                        bsel% = VAL(InputEngine$(STR$(bsel% - 1), "3", 3, 6, 2))
                                        SELECT CASE bsel%
                                        CASE IS < 0
                                            bsel% = -bsel%
                                            EXIT DO
                                        CASE ELSE
                                            IF CurrentUser.userMoney >= PriceTools%(bsel% - 1) AND GetToolsNum%(bsel% - 1) < 15 THEN
                                                SetToolsNum bsel% - 1, GetToolsNum%(bsel% - 1) + 1
                                                CurrentUser.userMoney = CurrentUser.userMoney - PriceTools%(bsel% - 1)
                                            END IF
                                        END SELECT
                                        InterfaceEngine "shop dynamic", 0, 0
                                    LOOP
                                    InterfaceEngine "disactive", 0, 0
                                CASE "s"
                                    InterfaceEngine "active sell", 0, 0
                                    DO
                                        ssel% = VAL(InputEngine$(STR$(ssel% - 1), "3", 3, 21, 2))
                                        SELECT CASE ssel%
                                        CASE IS < 0
                                            ssel% = -ssel%
                                            EXIT DO
                                        CASE ELSE
                                            IF GetToolsNum%(ssel% - 1) > 0 THEN
                                                SetToolsNum ssel% - 1, GetToolsNum%(ssel% - 1) - 1
                                                CurrentUser.userMoney = CurrentUser.userMoney + PriceTools%(ssel% - 1) * .75
                                            END IF
                                        END SELECT
                                        InterfaceEngine "shop dynamic", 0, 0
                                    LOOP
                                    InterfaceEngine "disactive", 0, 0
                                CASE CHR$(27)
                                    EXIT DO
                                END SELECT
                            END IF
                        LOOP
                    CASE 2
                        IF CurrentUser.userLife = 0 THEN
                            tmp$ = InputEngine$("enter", "Sorry, you can't save a dead state!", 0, 0, 0)
                        ELSEIF InputEngine$("y/n", "Do you want to save?", 0, 0, 0) = "y" THEN
                            SaveUser
                            tmp$ = InputEngine$("enter", "Save OK!", 0, 0, 0)
                        END IF
                    CASE 3
                        IF InputEngine$("y/n", "Do you want to load?", 0, 0, 0) = "y" THEN
                            LoadUser CurrentUser.userName
                            tmp$ = InputEngine$("enter", "Load OK!", 0, 0, 0)
                        END IF
                    CASE 4
                        EXIT DO
                    END SELECT
                LOOP
                CLS
            CASE 1
                InterfaceEngine "death", 0, 20
                CurrentUser.userLevel = VAL(InputEngine$("input digital", "Please input the level that you want to challenge:", 15, 15, 2))
                CurrentUser.userLife = LevelLife%(CurrentUser.userLevel)
                CurrentUser.userMoney = 0
                CurrentUser.userTools = 0
                CurrentUser.userMode = 1
                SELECT CASE VAL(InputEngine$("menu", "2", 30, 20, 22))
                CASE 0
                    InterfaceEngine "init", 0, 0
                    InitDataDynamic
                    MainFrame
                CASE 1
                    EXIT DO
                END SELECT
            CASE 2
                InterfaceEngine "help", 0, 0
                tmp$ = InputEngine$("pause", "", 0, 0, 0)
            CASE 3
                EXIT DO
            END SELECT
        LOOP
    END SELECT
LOOP

SUB ColorEngine (cmd$, c, r, g, B)
    OUT &H3C6, 15
    SELECT CASE LCASE$(cmd$)
    CASE "black"
        FOR I = 0 TO 15
            OUT &H3C8, I
            OUT &H3C9, 0: OUT &H3C9, 0: OUT &H3C9, 0
        NEXT
    CASE "set"
        OUT &H3C8, c
        OUT &H3C9, r: OUT &H3C9, g: OUT &H3C9, B
    CASE "get"
        OUT &H3C7, c
        r = INP(&H3C9): g = INP(&H3C9): B = INP(&H3C9)
    CASE "save"
        FOR I = 0 TO 15
            ColorEngine "get", 0, SystemPalette%(I * 3), SystemPalette%(I * 3 + 1), SystemPalette%(I * 3 + 2)
        NEXT
    CASE "restore"
        FOR I = 0 TO 15
            ColorEngine "set", 0, SystemPalette%(I * 3), SystemPalette%(I * 3 + 1), SystemPalette%(I * 3 + 2)
        NEXT
    END SELECT
END SUB

SUB CreateBomb (x, y)
    IF bCreateBomb% = 1 THEN EXIT SUB
    tmpSize% = LevelSize(CurrentUser.userLevel).sizeWidth * LevelSize(CurrentUser.userLevel).sizeHeight - 1
    DIM tmpBombPos%(tmpSize%)
    DIM tmpBomb%(tmpSize%)
    FOR I = 0 TO tmpSize%
        tmpBombPos%(I) = I
        tmpBomb%(I) = 0
    NEXT
    notPos% = y * LevelSize(CurrentUser.userLevel).sizeWidth + x
    FOR I = 1 TO LevelBomb%(CurrentUser.userLevel)
        DO
            realPos% = INT(RND * (tmpSize% + 1))
        LOOP UNTIL realPos% <> notPos%
        tmpBomb%(tmpBombPos%(realPos%)) = -1
        SWAP tmpBombPos%(realPos%), tmpBombPos%(tmpSize%)
        tmpSize% = tmpSize% - 1
    NEXT
    FOR I = 0 TO LevelSize(CurrentUser.userLevel).sizeWidth - 1
        FOR j = 0 TO LevelSize(CurrentUser.userLevel).sizeHeight - 1
            GameCore(I, j).gameData = tmpBomb%(j * LevelSize(CurrentUser.userLevel).sizeWidth + I)
            GameCore(I, j).gameState = 0
        NEXT
    NEXT
    FOR I = 0 TO LevelSize(CurrentUser.userLevel).sizeWidth - 1
        FOR j = 0 TO LevelSize(CurrentUser.userLevel).sizeHeight - 1
            IF GameCore(I, j).gameData = 0 THEN
                DataEngine "bombs", I, j
                GameCore(I, j).gameData = iCounter
            END IF
        NEXT
    NEXT
    DynamicBombs% = LevelBomb%(CurrentUser.userLevel)
    bCreateBomb% = 1
END SUB

SUB DataEngine (cmd$, lpara%, wpara%)
    SELECT CASE LCASE$(cmd$)
    CASE "open"
        IF GetGameState%(lpara%, wpara%) = 0 THEN
            DataEngine "open block", lpara%, wpara%
        ELSEIF GetGameState%(lpara%, wpara%) = -1 THEN
            DataEngine "open flag", lpara%, wpara%
        END IF
    CASE "open around"
        DataEngine "open block", lpara% - 1, wpara% - 1
        DataEngine "open block", lpara%, wpara% - 1
        DataEngine "open block", lpara% + 1, wpara% - 1
        DataEngine "open block", lpara% - 1, wpara%
        DataEngine "open block", lpara% + 1, wpara%
        DataEngine "open block", lpara% - 1, wpara% + 1
        DataEngine "open block", lpara%, wpara% + 1
        DataEngine "open block", lpara% + 1, wpara% + 1
    CASE "open block"
        IF isData(lpara%, wpara%) = 0 THEN EXIT SUB
        IF GetGameState%(lpara%, wpara%) = 0 THEN
            IF GetGameData%(lpara%, wpara%) = -1 THEN
                SetGameState lpara%, wpara%, -2
            ELSEIF GetGameData%(lpara%, wpara%) = 0 THEN
                SetGameState lpara%, wpara%, -1
                DataEngine "open around", lpara%, wpara%
            ELSE
                SetGameState lpara%, wpara%, -1
            END IF
        END IF
    CASE "open flag"
        DataEngine "flags", lpara%, wpara%
        IF iCounter% = GetGameData%(lpara%, wpara%) THEN
            DataEngine "open around", lpara%, wpara%
        END IF
    CASE "flag"
        IF GetGameState%(lpara%, wpara%) = 0 THEN
            SetGameState lpara%, wpara%, 1
        ELSEIF GetGameState%(lpara%, wpara%) = 1 THEN
            SetGameState lpara%, wpara%, 0
        END IF
    CASE "flags"
        iCounter% = 0
        iCounter% = iCounter% + isFlag%(lpara% - 1, wpara% - 1)
        iCounter% = iCounter% + isFlag%(lpara%, wpara% - 1)
        iCounter% = iCounter% + isFlag%(lpara% + 1, wpara% - 1)
        iCounter% = iCounter% + isFlag%(lpara% - 1, wpara%)
        iCounter% = iCounter% + isFlag%(lpara% + 1, wpara%)
        iCounter% = iCounter% + isFlag%(lpara% - 1, wpara% + 1)
        iCounter% = iCounter% + isFlag%(lpara%, wpara% + 1)
        iCounter% = iCounter% + isFlag%(lpara% + 1, wpara% + 1)
    CASE "bombs"
        iCounter% = 0
        iCounter% = iCounter% + isBomb%(lpara% - 1, wpara% - 1)
        iCounter% = iCounter% + isBomb%(lpara%, wpara% - 1)
        iCounter% = iCounter% + isBomb%(lpara% + 1, wpara% - 1)
        iCounter% = iCounter% + isBomb%(lpara% - 1, wpara%)
        iCounter% = iCounter% + isBomb%(lpara% + 1, wpara%)
        iCounter% = iCounter% + isBomb%(lpara% - 1, wpara% + 1)
        iCounter% = iCounter% + isBomb%(lpara%, wpara% + 1)
        iCounter% = iCounter% + isBomb%(lpara% + 1, wpara% + 1)
    CASE "bombeds"
        iCounter% = 0
        FOR I = 0 TO LevelSize(CurrentUser.userLevel).sizeWidth - 1
            FOR j = 0 TO LevelSize(CurrentUser.userLevel).sizeHeight - 1
                IF GetGameState%(I, j) = -2 THEN iCounter% = iCounter% + 1
            NEXT
        NEXT
    END SELECT
END SUB

SUB DrawBox (x, y, w, h, cb%, cd%)
    LINE (x, y)-(x + w - 1, y), cb%
    LINE (x, y)-(x, y + h - 1), cb%
    LINE (x + w - 1, y + h - 1)-(x + w - 1, y), cd%
    LINE (x + w - 1, y + h - 1)-(x, y + h - 1), cd%
END SUB

SUB FillBox (x, y, w, h, cb, cd, cf)
    DrawBox x, y, w, h, cb, cd
    LINE (x + 1, y + 1)-(x + w - 2, y + h - 2), cf%, BF
END SUB

FUNCTION GetGameData% (x, y)
    IF isData%(x, y) = 1 THEN GetGameData% = GameCore(x, y).gameData ELSE GetGameData% = 0
END FUNCTION

FUNCTION GetGameState% (x, y)
    IF isData%(x, y) = 1 THEN GetGameState% = GameCore(x, y).gameState ELSE GetGameState% = 0
END FUNCTION

FUNCTION GetToolsNum% (ts&)
    mask& = 15 * 2 ^ (ts& * 4)
    GetToolsNum% = (CurrentUser.userTools AND mask&) \ (2 ^ (ts& * 4))
END FUNCTION

SUB InitDataDynamic
    RANDOMIZE TIMER
    REDIM GameCore(LevelSize(CurrentUser.userLevel).sizeWidth - 1, LevelSize(CurrentUser.userLevel).sizeHeight - 1) AS typeElement
    REDIM GameMonitor%(LevelSize(CurrentUser.userLevel).sizeWidth - 1, LevelSize(CurrentUser.userLevel).sizeHeight - 1)
   
    FOR I = 0 TO LevelSize(CurrentUser.userLevel).sizeWidth - 1
        FOR j = 0 TO LevelSize(CurrentUser.userLevel).sizeHeight - 1
            GameMonitor%(I, j) = -2
        NEXT
    NEXT
   
    bCreateBomb% = 0

    LeftTop.x = (640 - LevelSize(CurrentUser.userLevel).sizeWidth * 20) \ 2
    LeftTop.y = (480 - LevelSize(CurrentUser.userLevel).sizeHeight * 20) \ 2

END SUB

SUB InitDataStatic
    DIM diff AS SINGLE
    diff = .08
    FOR I = 0 TO CMaxLevel%
        LevelSize(I).sizeWidth = 10 + I \ 5
        LevelSize(I).sizeHeight = 10 + I \ 10
        LevelBomb%(I) = LevelSize(I).sizeHeight * LevelSize(I).sizeWidth * diff
        LevelTime%(I) = 30 + I ^ 1.7
        LevelLife%(I) = SQR(I) + 1
        diff = diff + .003
    NEXT

    PriceTools%(0) = 80
    PriceTools%(1) = 100
    PriceTools%(2) = 500
    PriceTools%(3) = 100

    ColorEngine "save", 0, 0, 0, 0
    ColorEngine "black", 0, 0, 0, 0
    InterfaceEngine "alpha map", 0, 0
    InterfaceEngine "object map", 0, 0
    InterfaceEngine "object map", 1, 0
    InterfaceEngine "object map", 2, 0
    InterfaceEngine "object map", 3, 0
    InterfaceEngine "object map", 4, 0
    InterfaceEngine "object map", 5, 0
    InterfaceEngine "object map", 6, 0

    ColorEngine "set", 0, 48, 48, 48
    ColorEngine "set", 1, 0, 0, 63
    ColorEngine "set", 2, 0, 31, 0
    ColorEngine "set", 3, 63, 0, 0
    ColorEngine "set", 4, 0, 0, 31
    ColorEngine "set", 5, 31, 15, 0
    ColorEngine "set", 6, 0, 31, 31
    ColorEngine "set", 7, 0, 0, 0
    ColorEngine "set", 8, 31, 31, 31
    ColorEngine "set", 9, 31, 0, 0
    ColorEngine "set", 10, 0, 63, 0
    ColorEngine "set", 11, 0, 63, 63
    ColorEngine "set", 12, 63, 0, 63
    ColorEngine "set", 13, 63, 63, 0
    ColorEngine "set", 14, 15, 15, 15
    ColorEngine "set", 15, 63, 63, 63
END SUB

FUNCTION InputEngine$ (cmd$, msg$, x, y, l)
    SELECT CASE LCASE$(cmd$)
    CASE "menu"
        old% = 0
        sel% = 0
        DrawBox 8 * (x - 1) - 4, 16 * (y + old% * 2 - 1), (l + 1) * 8, 16, 15, 14
        DO
            ikey$ = INKEY$
            IF ikey$ <> "" THEN
                SELECT CASE LCASE$(ikey$)
                CASE CHR$(0) + "h"
                    IF sel% > 0 THEN sel% = sel% - 1
                CASE CHR$(0) + "p"
                    IF sel% < VAL(msg$) THEN sel% = sel% + 1
                CASE CHR$(13)
                    EXIT DO
                END SELECT
                DrawBox 8 * (x - 1) - 4, 16 * (y + old% * 2 - 1), (l + 1) * 8, 16, 0, 0
                DrawBox 8 * (x - 1) - 4, 16 * (y + sel% * 2 - 1), (l + 1) * 8, 16, 15, 14
                old% = sel%
            END IF
        LOOP
        InputEngine$ = STR$(sel%)
  
    CASE "input"
        LOCATE y, x: PRINT msg$;
        DrawBox 8 * (x + LEN(msg$)) - 4, 16 * (y - 1) - 1, 8 * (l + 1), 18, 14, 15
        InputEngine$ = InputEngine("get", "", x + LEN(msg$) + 1, y, l)
    CASE "input digital"
        LOCATE y, x: PRINT msg$;
        DrawBox 8 * (x + LEN(msg$)) - 4, 16 * (y - 1) - 1, 8 * (l + 1), 18, 14, 15
        InputEngine$ = InputEngine$("get digital", "", x + LEN(msg$) + 1, y, l)
    CASE "get digital"
        tmps$ = ""
        DO
            tmpc$ = INPUT$(1)
            IF ASC(tmpc$) >= ASC("0") AND ASC(tmpc$) <= ASC("9") AND LEN(tmps$) < l THEN tmps$ = tmps$ + tmpc$
            IF ASC(tmpc$) = 8 AND LEN(tmps$) > 0 THEN tmps$ = LEFT$(tmps$, LEN(tmps$) - 1)
            LOCATE y, x: PRINT tmps$ + SPACE$(l - LEN(tmps$))
        LOOP UNTIL tmpc$ = CHR$(13) AND tmps$ <> ""
        InputEngine$ = tmps$
    CASE "get"
        tmps$ = ""
        DO
            tmpc$ = INPUT$(1)
            IF ASC(tmpc$) >= 32 AND LEN(tmps$) < l THEN tmps$ = tmps$ + tmpc$
            IF ASC(tmpc$) = 8 AND LEN(tmps$) > 0 THEN tmps$ = LEFT$(tmps$, LEN(tmps$) - 1)
            LOCATE y, x: PRINT tmps$ + SPACE$(l - LEN(tmps$))
        LOOP UNTIL tmpc$ = CHR$(13) AND tmps$ <> ""
        InputEngine$ = tmps$
    CASE "y/n"
        l% = LEN(msg$)
        lt% = 320 - l% * 4 - 16
        DIM tmp%((l% + 2) * 112 + 2)
        GET (lt%, 204)-(lt% + (l% + 2) * 8 - 1, 259), tmp%
        InterfaceEngine "input box", lt%, l%
        InterfaceEngine msg$, 0, 14
        InterfaceEngine "y/n", 0, 16
        InputEngine$ = LCASE$(INPUT$(1))
        PUT (lt%, 204), tmp%, PSET
        ERASE tmp%
    CASE "enter"
        l% = LEN(msg$)
        lt% = 320 - l% * 4 - 16
        DIM tmp%((l% + 2) * 112 + 2)
        GET (lt%, 204)-(lt% + (l% + 2) * 8 - 1, 259), tmp%
        InterfaceEngine "input box", lt%, l%
        InterfaceEngine msg$, 0, 14
        InterfaceEngine "OK", 0, 16
        DO: LOOP UNTIL INPUT$(1) = CHR$(13)
        PUT (lt%, 204), tmp%, PSET
        ERASE tmp%
    CASE "pause"
        InputEngine$ = INPUT$(1)
    CASE ELSE
        old% = VAL(cmd$)
        sel% = VAL(cmd$)
        sign% = 0
        DrawBox 8 * (x - 1) - 4, 16 * (y + old% * 2 - 1) - 2, (l + 1) * 8, 20, 15, 14
        DO
            ikey$ = INKEY$
            IF ikey$ <> "" THEN
                SELECT CASE LCASE$(ikey$)
                CASE CHR$(0) + "h"
                    IF sel% > 0 THEN sel% = sel% - 1
                CASE CHR$(0) + "p"
                    IF sel% < VAL(msg$) THEN sel% = sel% + 1
                CASE CHR$(13)
                    sign% = 1
                    EXIT DO
                CASE CHR$(27)
                    sign% = -1
                    EXIT DO
                END SELECT
                DrawBox 8 * (x - 1) - 4, 16 * (y + old% * 2 - 1) - 2, (l + 1) * 8, 20, 0, 0
                DrawBox 8 * (x - 1) - 4, 16 * (y + sel% * 2 - 1) - 2, (l + 1) * 8, 20, 15, 14
                old% = sel%
            END IF
        LOOP
        InputEngine$ = STR$(sign% * (sel% + 1))
    END SELECT
END FUNCTION

SUB InterfaceEngine (cmd$, lpara%, wpara%)
    COLOR 8
    SELECT CASE LCASE$(cmd$)
    CASE "alpha map"
        DIM temp%(34)
        GET (0, 0)-(7, 15), temp%
        FOR I = 0 TO 9
            IF I > 0 THEN
                LOCATE 1, 1
                COLOR I
                IF I < 9 THEN PRINT HEX$(I) ELSE PRINT "?"
            END IF
            GET (0, 0)-(7, 15), AlphaMap%(0, I)
        NEXT
        PUT (0, 0), temp%, PSET
    CASE "object map"
        DIM temp%(66)
        DIM object%(15, 15)
        GET (0, 0)-(15, 15), temp%
        FOR I = 0 TO 15: FOR j = 0 TO 15
            READ object%(I, j)
            PSET (j, I), object%(I, j)
        NEXT: NEXT
        GET (0, 0)-(15, 15), ObjectMap%(0, lpara%)
        PUT (0, 0), temp%, PSET
    CASE "end"
        CLS
    CASE "help"
        CLS
        InterfaceEngine "Help for Bomb", 0, 2
        LINE (0, 40)-(639, 40), 8
        InterfaceEngine "Not finished", 0, 0
    CASE "top"
        CLS
        InterfaceEngine "Top 10", 0, 2
        LINE (0, 40)-(639, 40), 8
        InterfaceEngine "Name      Level     Life      Money", 0, 6
        DrawBox 120, 100, 400, 320, 14, 15
        InterfaceEngine "Not finished", 0, 0
    CASE "disactive"
        PAINT (0, 50), 0, 8
        PAINT (0, 250), 0, 8
    CASE "active buy"
        PAINT (0, 50), 15, 8
        PAINT (0, 250), 0, 8
    CASE "active sell"
        PAINT (0, 50), 0, 8
        PAINT (0, 250), 15, 8
    CASE "shop"
        CLS
        InterfaceEngine "Welcome to my world, " + LTRIM$(RTRIM$(CurrentUser.userName)), 0, 2
        LINE (0, 40)-(639, 40), 8
        LINE (72, 50)-(639, 50), 8
        LINE (0, 72)-(50, 72), 8
        LINE (72, 50)-(50, 72), 8
        LINE (0, 208)-(639, 208), 8
        LINE (0, 248)-(639, 248), 8
        LINE (117, 258)-(639, 258), 8
        LINE (0, 280)-(95, 280), 8
        LINE (117, 258)-(95, 280), 8
        LINE (0, 448)-(639, 448), 8
        InterfaceEngine "Shop ", 2, 4
        InterfaceEngine "Your State", 2, 17
        InterfaceEngine "User:" + CurrentUser.userName, 3, 19
        InterfaceEngine "Level:" + STR$(CurrentUser.userLevel), 23, 19
        InterfaceEngine "Life:" + STR$(CurrentUser.userLife) + "/" + STR$(LevelLife%(CurrentUser.userLevel)), 38, 19
        InterfaceEngine "Press 'S' to sell and press 'B' to buy", 2, 30
        InterfaceEngine "Price:" + STR$(PriceTools%(0)) + " , Function: Detect current position auto!", 6, 6
        InterfaceEngine "Price:" + STR$(PriceTools%(1)) + " , Function: Add life!", 6, 8
        InterfaceEngine "Price:" + STR$(PriceTools%(2)) + " , Function: Exposure the place around current position!", 6, 10
        InterfaceEngine "Price:" + STR$(PriceTools%(3)) + " , Function: Stop the timer for 10 seconds!", 6, 12
        PUT (16, 80), ObjectMap%(0, 3)
        PUT (16, 112), ObjectMap%(0, 4)
        PUT (16, 144), ObjectMap%(0, 5)
        PUT (16, 176), ObjectMap%(0, 6)
        PUT (16, 320), ObjectMap%(0, 3)
        PUT (16, 352), ObjectMap%(0, 4)
        PUT (16, 384), ObjectMap%(0, 5)
        PUT (16, 416), ObjectMap%(0, 6)
        InterfaceEngine "shop dynamic", 0, 0
    CASE "shop dynamic"
        InterfaceEngine "Money:" + STR$(CurrentUser.userMoney) + "     ", 58, 19
        InterfaceEngine STR$(GetToolsNum(0)), 6, 21
        InterfaceEngine STR$(GetToolsNum(1)), 6, 23
        InterfaceEngine STR$(GetToolsNum(2)), 6, 25
        InterfaceEngine STR$(GetToolsNum(3)), 6, 27
    CASE "death"
        CLS
        LINE (0, 280)-(639, 280), 8
        InterfaceEngine "Welcome to my world, " + LTRIM$(RTRIM$(CurrentUser.userName)), 0, 8
        InterfaceEngine "Go", 0, wpara%
        InterfaceEngine "Return", 0, wpara% + 2
    CASE "login"
        CLS
        InterfaceEngine "Welcome to bomb-world", 0, 2
        LINE (0, 40)-(639, 40), 8
        PAINT (0, 20), 15, 8
        LINE (0, 280)-(639, 280), 8
        LOCATE 20, 1: PRINT "Special user name:";
        LOCATE 21, 3: PRINT "End:  exit this game!";
        LOCATE 22, 3: PRINT "Top:  Top 10!"
        LOCATE 23, 3: PRINT "Help: view help document!";
        LOCATE 30, 55: PRINT "Copyright 2004 by HanJin";
    CASE "menu"
        CLS
        LINE (0, 280)-(639, 280), 8
        InterfaceEngine "Welcome to my world, " + LTRIM$(RTRIM$(CurrentUser.userName)), 0, 8
        InterfaceEngine "Start Game in PRG Mode", 0, wpara%
        InterfaceEngine "Start Game in Death Mode", 0, wpara% + 2
        InterfaceEngine "View the Help", 0, wpara% + 4
        InterfaceEngine "Logout", 0, wpara% + 6
    CASE "menu rpg"
        CLS
        LINE (0, 280)-(639, 280), 8
        InterfaceEngine "Welcome to my world, " + LTRIM$(RTRIM$(CurrentUser.userName)), 0, 3
        DrawBox 200, 64, 240, 208, 14, 15
        LOCATE 6, 28: PRINT "Level: "; CurrentUser.userLevel
        LOCATE 6, 44: PRINT "Life:  "; CurrentUser.userLife
        LOCATE 8, 28: PRINT "Money: "; CurrentUser.userMoney
        PUT (216, 144), ObjectMap%(0, 3)
        PUT (216, 176), ObjectMap%(0, 4)
        PUT (216, 208), ObjectMap%(0, 5)
        PUT (216, 240), ObjectMap%(0, 6)
        LOCATE 10, 31: PRINT GetToolsNum%(0)
        LOCATE 12, 31: PRINT GetToolsNum%(1)
        LOCATE 14, 31: PRINT GetToolsNum%(2)
        LOCATE 16, 31: PRINT GetToolsNum%(3)
        InterfaceEngine "Go", 0, wpara%
        InterfaceEngine "Shopping", 0, wpara% + 2
        InterfaceEngine "Save to disk", 0, wpara% + 4
        InterfaceEngine "Load from disk", 0, wpara% + 6
        InterfaceEngine "Return", 0, wpara% + 8
    CASE "init"
        CLS
        LOCATE 1, 3: PRINT "User:"; CurrentUser.userName
        LOCATE 1, 23: PRINT "Level:"; CurrentUser.userLevel
        LOCATE 1, 53: PRINT "Money:"; CurrentUser.userMoney
        LOCATE 1, 38: PRINT "Life:"
        PUT (24, 16), ObjectMap%(0, 0)
        PUT (128, 16), ObjectMap%(0, 3)
        PUT (232, 16), ObjectMap%(0, 4)
        PUT (336, 16), ObjectMap%(0, 5)
        PUT (440, 16), ObjectMap%(0, 6)
        InterfaceEngine "timer frame", 0, 0
        LINE (0, 35)-(639, 35), 8
    CASE "user"
        FillBox 340, 2, 52, 14, 14, 15, 0
        LINE (341, 3)-(341 + 49 * CurrentUser.userLife \ LevelLife%(CurrentUser.userLevel), 14), 3, BF
        LOCATE 2, 6: PRINT lpara%
        LOCATE 2, 19: PRINT GetToolsNum%(0)
        LOCATE 2, 32: PRINT GetToolsNum%(1)
        LOCATE 2, 45: PRINT GetToolsNum%(2)
        LOCATE 2, 58: PRINT GetToolsNum%(3)
    CASE "element"
        x = LeftTop.x + lpara% * 20
        y = LeftTop.y + wpara% * 20
        IF GetGameState%(lpara%, wpara%) >= 0 THEN cb% = 15: cd% = 14 ELSE cb% = 14: cd% = 15
        FillBox x, y, 20, 20, cb%, cd%, 0
        IF GetGameState%(lpara%, wpara%) = -2 THEN
            PUT (x + 2, y + 2), ObjectMap%(0, 1), PSET
        ELSEIF GetGameState%(lpara%, wpara%) = -1 THEN
            PUT (x + 6, y + 2), AlphaMap%(0, GetGameData%(lpara%, wpara%)), PSET
        ELSEIF GetGameState%(lpara%, wpara%) = 1 THEN
            PUT (x + 2, y + 2), ObjectMap%(0, 2), PSET
        END IF
    CASE "draw selector"
        x = LeftTop.x + lpara% * 20
        y = LeftTop.y + wpara% * 20
        LINE (x + 1, y + 1)-(x + 18, y + 18), 10, B
    CASE "clear selector"
        x = LeftTop.x + lpara% * 20
        y = LeftTop.y + wpara% * 20
        LINE (x + 1, y + 1)-(x + 18, y + 18), 0, B
    CASE "timer frame"
        DrawBox 20, 450, 600, 20, 14, 15
    CASE "timer"
        dw& = CLNG(598) * lpara% \ wpara%
        IF dw& > 598 THEN dw& = 598
        LINE (21, 451)-(21 + dw&, 468), 13, BF
    CASE "input box"
        FillBox lpara%, 204, (wpara% + 2) * 8, 56, 15, 14, 0
        LINE (lpara% + 4, 232)-(lpara% + (wpara% + 1) * 8, 232), 8
        LINE (lpara% + 4, 233)-(lpara% + (wpara% + 1) * 8, 233), 15
    CASE ELSE
        IF lpara% = 0 THEN lpara% = (80 - LEN(cmd$)) \ 2
        IF wpara% = 0 THEN wpara% = 15
        LOCATE wpara%, lpara%
        PRINT cmd$;
    END SELECT
END SUB

FUNCTION isBomb% (x, y)
    IF GetGameData%(x, y) = -1 THEN isBomb% = 1 ELSE isBomb% = 0
END FUNCTION

FUNCTION isData% (x, y)
    IF x < 0 OR y < 0 OR x > LevelSize(CurrentUser.userLevel).sizeWidth - 1 OR y > LevelSize(CurrentUser.userLevel).sizeHeight - 1 THEN isData% = 0 ELSE isData% = 1
END FUNCTION

FUNCTION isFlag% (x, y)
    IF GetGameState%(x, y) = 1 THEN isFlag% = 1 ELSE isFlag% = 0
END FUNCTION

FUNCTION isWin%
    isWin% = 1
    iCounter% = 0
    FOR I = 0 TO LevelSize(CurrentUser.userLevel).sizeWidth - 1
        FOR j = 0 TO LevelSize(CurrentUser.userLevel).sizeHeight - 1
            IF GetGameData%(I, j) >= 0 AND GetGameState%(I, j) <> -1 THEN isWin% = 0: EXIT FUNCTION
        NEXT
    NEXT
    FOR I = 0 TO LevelSize(CurrentUser.userLevel).sizeWidth - 1
        FOR j = 0 TO LevelSize(CurrentUser.userLevel).sizeHeight - 1
            IF GetGameData%(I, j) = -1 AND GetGameState%(I, j) = 0 THEN
                DataEngine "flag", I, j
                iCounter% = iCounter% + 1
            END IF
        NEXT
    NEXT
END FUNCTION

SUB LoadUser (uname$)
    DIM tmpUser AS typeUser
    OPEN CFileUser$ FOR RANDOM AS #1 LEN = LEN(tmpUser)
    GET #1, 1, tmpUser
    IF tmpUser.userIndex = 0 THEN
        tmpUser.userIndex = 1
        PUT #1, 1, tmpUser
    END IF
    CurrentUser.userName = ""
    FOR I = 2 TO tmpUser.userIndex
        GET #1, I, CurrentUser
        IF LCASE$(LTRIM$(RTRIM$(CurrentUser.userName))) = LCASE$(LTRIM$(RTRIM$(uname$))) THEN EXIT FOR
    NEXT
    CLOSE #1
    bNewUser% = 0
    IF LCASE$(LTRIM$(RTRIM$(CurrentUser.userName))) <> LCASE$(LTRIM$(RTRIM$(uname$))) THEN
        CurrentUser.userName = uname$
        CurrentUser.userLife = 1
        CurrentUser.userLevel = 0
        CurrentUser.userMoney = 0
        CurrentUser.userTools = 0
        CurrentUser.userMode = 0
        CurrentUser.userIndex = tmpUser.userIndex + 1
        bNewUser% = 1
    END IF
END SUB

SUB MainFrame
    tm! = TIMER: tmget! = 0: tmtmp! = 0
    sely% = 0: selx% = 0
    oldy% = 0: oldx% = 0
    Refresh
    InterfaceEngine "draw selector", selx%, sely%
    DO
        ikey$ = INKEY$
        IF ikey$ <> "" THEN
            SELECT CASE LCASE$(ikey$)
            CASE CHR$(0) + "h"
                IF sely% > 0 THEN sely% = sely% - 1
            CASE CHR$(0) + "k"
                IF selx% > 0 THEN selx% = selx% - 1
            CASE CHR$(0) + "m"
                IF selx% < LevelSize(CurrentUser.userLevel).sizeWidth - 1 THEN selx% = selx% + 1
            CASE CHR$(0) + "p"
                IF sely% < LevelSize(CurrentUser.userLevel).sizeHeight - 1 THEN sely% = sely% + 1
            CASE CHR$(13)
                DataEngine "flag", selx%, sely%
                DynamicBombs% = DynamicBombs% - 1
            CASE CHR$(32)
                CreateBomb selx%, sely%
                DataEngine "open", selx%, sely%
            CASE "1"
                IF GetToolsNum%(0) > 0 AND GetGameState%(selx%, sely%) = 0 THEN
                    IF isBomb%(selx%, sely%) = 1 THEN
                        DataEngine "flag", selx%, sely%
                    ELSE
                        CreateBomb selx%, sely%
                        DataEngine "open", selx%, sely%
                    END IF
                    SetToolsNum 0, GetToolsNum%(0) - 1
                END IF
            CASE "2"
                IF GetToolsNum%(1) > 0 AND CurrentUser.userLife < LevelLife(CurrentUser.userLevel) THEN
                    CurrentUser.userLife = CurrentUser.userLife + 1
                    SetToolsNum 1, GetToolsNum%(1) - 1
                END IF
            CASE "3"
                IF GetToolsNum%(2) > 0 THEN
                    FOR I = selx% - 1 TO selx% + 1: FOR j = sely% - 1 TO sely% + 1
                        IF isData%(I, j) = 1 THEN
                            IF isBomb%(I, j) = 1 THEN
                                IF GetGameState%(I, j) = 0 THEN DataEngine "flag", I, j
                            ELSE
                                CreateBomb I, j
                                DataEngine "open", I, j
                            END IF
                        END IF
                    NEXT: NEXT
                    SetToolsNum 2, GetToolsNum%(2) - 1
                END IF
            CASE "4"
                IF GetToolsNum%(3) > 0 THEN
                    tmget! = TIMER + 10
                    SetToolsNum 3, GetToolsNum%(3) - 1
                END IF
            CASE "h"
                tmtmp! = TIMER - tm!
                tmp$ = InputEngine$("enter", "Not Finished!", 0, 0, 0)
                tm! = TIMER - tmtmp!
            CASE CHR$(27)
                IF InputEngine$("y/n", "Are you sure to exit ?", 0, 0, 0) = "y" THEN EXIT DO
            END SELECT
            IF oldx% <> selx% OR oldy% <> sely% THEN
                InterfaceEngine "clear selector", oldx%, oldy%
                oldx% = selx%: oldy% = sely%
            END IF
            Refresh
            InterfaceEngine "draw selector", selx%, sely%
        END IF
        IF tmget! < TIMER THEN
            InterfaceEngine "timer", TIMER - tm!, LevelTime(CurrentUser.userLevel)
            tmtmp! = TIMER - tm!
            tmget! = 0
        ELSE
            tm! = TIMER - tmmp!
        END IF
        IF CurrentUser.userLife <= 0 THEN
            tmp$ = InputEngine$("enter", "Sorry, you dead!", 0, 0, 0)
            EXIT DO
        END IF
        IF TIMER - tm! > LevelTime(CurrentUser.userLevel) THEN
            tmp$ = InputEngine$("enter", "Sorry, time is up, YOU LOST!", 0, 0, 0)
            EXIT DO
        END IF
        IF isWin% = 1 THEN
            tm! = TIMER - tm!
            money% = LevelTime(CurrentUser.userLevel) - tm! + iCounter% * 6
            DataEngine "bombeds", 0, 0
            money% = money% \ (iCounter% + 1)
            Refresh
            CurrentUser.userMoney = CurrentUser.userMoney + money%
            CurrentUser.userLevel = CurrentUser.userLevel + 1
            tmp$ = InputEngine$("enter", "Congratulate, YOU WIN!", 0, 0, 0)
            IF CurrentUser.userMode = 0 THEN tmp$ = InputEngine$("enter", "Level up to" + STR$(CurrentUser.userLevel) + " and get" + STR$(money%) + " coin!", 0, 0, 0)
            EXIT DO
        END IF
    LOOP
END SUB

SUB Refresh
    FOR I = 0 TO LevelSize(CurrentUser.userLevel).sizeWidth - 1
        FOR j = 0 TO LevelSize(CurrentUser.userLevel).sizeHeight - 1
            IF GetGameState%(I, j) <> GameMonitor%(I, j) THEN
                IF GetGameState%(I, j) = -2 THEN CurrentUser.userLife = CurrentUser.userLife - 1
                InterfaceEngine "element", I, j
                GameMonitor%(I, j) = GetGameState%(I, j)
            END IF
        NEXT
    NEXT
    IF bCreateBomb% = 1 THEN
        InterfaceEngine "user", DynamicBombs%, 0
    ELSE
        InterfaceEngine "user", LevelBomb%(CurrentUser.userLevel), 0
    END IF
END SUB

SUB SaveUser
    DIM tmpUser AS typeUser
    OPEN CFileUser$ FOR RANDOM AS #1 LEN = LEN(CurrentUser)
    GET #1, 1, tmpUser
    tmpUser.userIndex = tmpUser.userIndex + bNewUser%
    PUT #1, 1, tmpUser
    PUT #1, CurrentUser.userIndex, CurrentUser
    CLOSE #1
END SUB

SUB SetGameData (x, y, d)
    IF isData%(x, y) = 1 THEN GameCore(x, y).gameData = d
END SUB

SUB SetGameState (x, y, s)
    IF isData%(x, y) = 1 THEN GameCore(x, y).gameState = s
END SUB

SUB SetToolsNum (ts&, num&)
    mask& = 15 * 2 ^ (ts& * 4)
    mask& = NOT mask&
    number& = num& * 2 ^ (ts& * 4)
    CurrentUser.userTools = CurrentUser.userTools AND mask& OR number&
END SUB

回复列表 (共12个回复)

沙发

高手就是高手,虽然在网吧看不到运行效果,但是程序的风格就够让新手学习的了

板凳

上楼的,你真会拍马屁。

3 楼

试了一下
除了是E文这一点,的确是好程序,希望要知道QB能干什么的同志都去运行一下。

4 楼

做中文太麻烦了,呵呵

5 楼

看看我掰的:
    http://www.copathway.com/copathway/project_view.asp?prj_id=1014

6 楼

呵呵,你做的还真象啊!:)

7 楼

妙!!!!!!!!!!
本菜鸟今日方知QB有如此大用。

8 楼

楼主真有雅兴,佩服!!!!!!

9 楼

老实说
我看到一大堆的 data 都会头痛
不过我的 dos 机上找不到游戏
只把剽窃一翻了
希望楼主别找我收版权费用

10 楼

光复制就用了半天!

我来回复

您尚未登录,请登录后再回复。点此登录或注册