forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


GAMES: Checkers/Blackjack/Anti-aircraft

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Tue Dec 23, 2003 9:40 pm    Post subject: GAMES: Checkers/Blackjack/Anti-aircraft Reply with quote

Here's some games I wrote a while back (Checkers/Blackjack/Anti-aircraft)
that are incomplete in the archives (mods please leave the "code" tags):
____________________________________________________________________________________________________________________
CHECKERS
Code:

rem -- Uses @chr(227) for checkers, @chr(196) for kings --

rem -- Look for a sound file under 50k in size --
LIST CREATE, 1
LIST FILELIST, 1, @windir()\media\*.wav
if @greater(@count(1), 0)
   REPEAT
     if @greater(50000, @file(@item(1, %x), Z))
        %%wavfile = @item(1, %x)
     end
     %x = @succ(%x)
   UNTIL %%wavfile @equal(%x, @count(1))
end
LIST CLOSE, 1

OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
rem -- Don't show main, it's use is to create/recreate child dialog --
DIALOG CREATE,"Main Checker Dialog",0,0,0,0

rem -- Holds possible moves for a single piece --
LIST CREATE, 8

rem -- Holds all possible moves for all computer pieces --
LIST CREATE, 7

:Start/Restart
DIALOG CREATE,Checkers By Mac,-1,0,500,400
  DIALOG ADD,STYLE,Style1,,,,YELLOW
  DIALOG ADD,STYLE,Style2,Symbol,36,BC,,CYAN
  DIALOG ADD,STYLE,Style3,Arial,12,B,,LTBLUE
  DIALOG ADD,STYLE,Style4,MS Sans Serif,8,B
  DIALOG ADD,STYLE,Empty1,Symbol,28,BC,BROWN,LTGREEN
  DIALOG ADD,STYLE,Empty,Symbol,28,BC,BROWN,BROWN
  DIALOG ADD,STYLE,Red,Symbol,28,B,BROWN,RED
  DIALOG ADD,STYLE,Black,Symbol,28,B,BROWN,BLACK

  DIALOG ADD,TEXT,GameInfo,5,405,,,"Your Turn...",Style3
  DIALOG ADD,BUTTON,NewGame,30,405,90,20,"New Game",Style4
  DIALOG ADD,TEXT,Instructions,60,405,90,160,"Click red checker to activate it (3 dots), then click a destination square (you can multiple jump). Clicking it again deactivates it so the computer can play. It has very basic AI, so don't cheat!"

  DIALOG ADD,TEXT,Board,0,0,400,400,,Style1

  rem -- Squares numbers, their XY, who's piece/type if occupied --
  rem -- BC = black checker, RC = red checker, NO = No checker --
  rem -- BK = black king, RK = red king --
  %x = 50
  %y = 0
  %n = 1
  REPEAT
    if @greater(10, %n)
       %n = 0%n
    end
    rem -- Background squares to see where checker moved from --
    DIALOG ADD,TEXT,B%n,%y,%x,50,50,"*",Empty1

    rem -- Black checkers --
    if @greater(13, %n)
       DIALOG ADD,TEXT,S%n,%y,%x,50,50," "@chr(227)" "|%n|%x|%y|BC,Black,CLICK
    end
    rem -- Blank Squares --
    if @both(@greater(%n, 12), @greater(21, %n))
       DIALOG ADD,TEXT,S%n,%y,%x,50,50,|%n|%x|%y|NO,Empty,CLICK
    end
    rem -- Red checkers --
    if @greater(%n, 20)
       DIALOG ADD,TEXT,S%n,%y,%x,50,50," "@chr(227)" "|%n|%x|%y|RC,Red,CLICK
    end
    %n = @succ(%n)
    %x = @sum(%x, 100)
    if @greater(%x, 350)
       %y = @sum(%y, 50)
       %x = 0
       if @equal(%y, 100)@equal(%y, 200)@equal(%y, 300)
          %x = 50
       end
    end
  UNTIL @greater(%n, 32)

  rem -- Dots to highlight player active piece --
  DIALOG ADD,TEXT,HL,0,0,50,50,@chr(188),TRANSPARENT,Style2,CLICK
  DIALOG HIDE,HL
DIALOG SHOW

rem -- Total checkers --
%%playernum = 12
%%compnum = 12

rem -- Active player checker --
%%checker = ""

if %%wavfile
   PLAY %%wavfile
end

:EVLOOP
  rem -- Let everything catch up --
  WAIT .2
  WAIT EVENT
  %e = @event()
  if @equal(@substr(%e, 1), "S")
     goto ClickSquare
  end
  goto %e

:NewGameBUTTON
  if @ask(Abandon this game?@tab())
     DIALOG SELECT, 1
     DIALOG CLOSE
     goto Start/Restart
  end
  goto EVLOOP

:HLCLICK
  %%checker = ""
  DIALOG HIDE, HL
  if %%playermoved
     goto ComputerPlay
  end
  goto EVLOOP

:ClickSquare
  %%square = @substr(%e, 1, 3)
  PARSE ";%%SQnum;%%SQx;%%SQy;%%SQstatus", @dlgtext(%%square)
  rem -- If red piece --
  if @equal(%%SQstatus, RC)@equal(%%SQstatus, RK)
     %%checker = %%square
     PARSE ";%%startSQ;%%startSQx;%%startSQy;%%caller", @dlgtext(%%checker)
     DIALOG SHOW, HL
     DIALOG SETPOS, HL, %%startSQy, %%startSQx
  end
  rem -- If empty square --
  if @equal(%%SQstatus, NO)
     if %%checker
        GOSUB CheckBoard
        if @greater(@count(8), 0)
           LIST SEEK, 8, 0
           if @match(8, %%square)
              GOSUB MovePiece
              %%playermoved = 1
           else
              INFO You cannot move there!@tab()
           end
        else
           INFO You cannot move there!@tab()
        end
     end
  end
  goto EVLOOP

:ComputerPlay
  DIALOG SET, GameInfo, "Thinking..."
  WAIT
  LIST CLEAR, 7
  rem -- Check all computer pieces for possible moves --
  %x = 1
  REPEAT
    if @greater(10, %x)
       %x = 0%x
    end
    PARSE ";%%startSQ;%%startSQx;%%startSQy;%%caller", @dlgtext(S%x)
    if @equal(%%caller, "BC")@equal(%%caller, "BK")
       GOSUB CheckBoard
    end
    %x = @succ(%x)
  UNTIL @greater(%x, 32)
  rem -- Check jumps or multiple jumps --
  if @greater(@count(7), 0)
     %j = ""
     :CheckJumps
     %%OK = ""
     if @greater(@count(7), 0)
        LIST ASSIGN, 8, 7
        LIST SEEK, 8, 0
        %x = 0
        REPEAT
          if @greater(@pos("JUMP", @item(8,%x)), 0)
             %%OK = 1
             %j = 1
             %%randompick = @item(8, %x)
             PARSE "%%square;%%start", %%randompick
             PARSE ";%%startSQ;%%startSQx;%%startSQy;%%caller", @dlgtext(%%start)
             rem -- Kill multiple jumps if this jump makes a king --
             if @both(@equal(%%caller, BC), @greater(@substr(%%square, 2, 3), 28))
                %%OK = ""
             end
             GOSUB MovePiece
             LIST CLEAR, 7
             GOSUB CheckBoard
             %x = @pred(@count(8))
          end
          %x = @succ(%x)
        UNTIL @equal(%x, @count(8))
     end
     if %%OK
        goto CheckJumps
     end
     if %j
        goto ComputerPlayEnd
     end

     rem -- If can't jump, try to make a king --
     %x = 0
     %k = ""
     REPEAT
       PARSE "%a" , @item(8, %x)
       if @equal(%a, S29)@equal(%a, S30)@equal(%a, S31)@equal(%a, S32)
          %%randompick = @item(8, %x)
          PARSE "%%square;%%start", %%randompick
          PARSE ";%%startSQ;%%startSQx;%%startSQy;%%caller", @dlgtext(%%start)
          if @equal(%%caller, "BC")
             GOSUB MovePiece
             %x = @pred(@count(8))
             %k = 1
          end
       end
       %x = @succ(%x)
     UNTIL @equal(%x, @count(8))
     if %k
        goto ComputerPlayEnd
     end

     rem -- Just pick a random move --
     %x = 0
     REPEAT
       %%randompick = @item(8, %x)
       %r = @datetime()
       rem -- get last digit (use as random number)
       %r = @substr(%r, @len(%r))
       %x = @succ(%x)
       if @equal(%x, @count(8))
          %x = 0
       end
     UNTIL @equal(%r, 5)
     PARSE "%%square;%%start", %%randompick
     PARSE ";%%startSQ;%%startSQx;%%startSQy;%%caller", @dlgtext(%%start)
     GOSUB MovePiece
  end
  :ComputerPlayEnd
    if %%wavfile
       PLAY %%wavfile
    end
    DIALOG SET, GameInfo, "Your Turn..."
    %%playermoved = ""
    goto EVLOOP

:CLOSE
  EXIT
  STOP

rem ------------ GOSUB ROUTINES ------------

:CheckBoard
  rem -- Add all possible legal moves to LIST 8 --
  rem -- Uses %%caller, %%startSQ, %%startSQx, %%startSQy --
  LIST CLEAR, 8
  if @equal(%%caller,"BC")
     goto CheckBoardDown
  end
  :CheckBoardUp
    rem -- Up left --
    if @both(@greater(%%startSQ, 4), @greater(%%startSQx, 0))
       %%dir = L
       if @equal(@mod(%%startSQy, 100), 0)
          %%up1 = 4
          %%up2 = 5
       else
          %%up1 = 5
          %%up2 = 4
       end
       GOSUB CheckUp
    end
    rem -- Up right --
    if @both(@greater(%%startSQ, 4), @greater(350, %%startSQx))
       %%dir = R
       if @equal(@mod(%%startSQy, 100), 0)
          %%up1 = 3
          %%up2 = 4
       else
          %%up1 = 4
          %%up2 = 3
       end
       GOSUB CheckUp
    end
    if @equal(%%caller,"RC")
       goto CheckBoardEnd
    end
  :CheckBoardDown
    rem -- Down left --
    if @both(@greater(29, %%startSQ), @greater(%%startSQx, 0))
       %%dir = L
       if @equal(@mod(%%startSQy, 100), 0)
          %%dn1 = 4
          %%dn2 = 3
       else
          %%dn1 = 3
          %%dn2 = 4
       end
       GOSUB CheckDown
    end
    rem -- Down right --
    if @both(@greater(29, %%startSQ), @greater(350, %%startSQx))
       %%dir = R
       if @equal(@mod(%%startSQy, 100), 0)
          %%dn1 = 5
          %%dn2 = 4
       else
          %%dn1 = 4
          %%dn2 = 5
       end
       GOSUB CheckDown
    end
  :CheckBoardEnd
    exit

:CheckUp
  %z = @diff(%%startSQ, %%up1)
  GOSUB FormatZ
  PARSE ";%%tmp;;;%%piece", @dlgtext(S%z)
  if @equal(%%piece, "NO")
     LIST ADD, 8, S%%tmp|dud
     LIST ADD, 7, S%%tmp|S%%startSQ
  else
     rem -- If opponent is there, check for possible jump --
     if @not(@equal(@substr(%%piece, 1), @substr(%%caller, 1)))
        if @both(@equal(%%dir, "L"), @greater(100, %%startSQx)) @both(@equal(%%dir, "R"), @greater(%%startSQx, 250))
           goto CheckUpEnd
        end
        if @greater(%%startSQ, 8)
           %z = @diff(%z, %%up2)
           GOSUB FormatZ
           PARSE ";%%tmp;;;%%piece", @dlgtext(S%z)
           if @equal(%%piece, "NO")
              rem -- List piece to be removed if this move is used --
              %z = @sum(%z, %%up2)
              GOSUB FormatZ
              LIST ADD, 8, S%%tmp|dud|JUMP|%z
              LIST ADD, 7, S%%tmp|S%%startSQ|JUMP|%z
           end
        end
     end
  end
  :CheckUpEnd
    exit

:CheckDown
  %z = @sum(%%startSQ, %%dn1)
  GOSUB FormatZ
  PARSE ";%%tmp;;;%%piece", @dlgtext(S%z)
  if @equal(%%piece, "NO")
     LIST ADD, 8, S%%tmp|dud
     LIST ADD, 7, S%%tmp|S%%startSQ
  else
     rem -- If opponent is there, check for possible jump --
     if @not(@equal(@substr(%%piece, 1), @substr(%%caller, 1)))
        if @both(@equal(%%dir, "L"), @greater(100, %%startSQx)) @both(@equal(%%dir, "R"), @greater(%%startSQx, 250))
           goto CheckDownEnd
        end
        if @greater(25, %%startSQ)
            %z = @sum(%z, %%dn2)
            GOSUB FormatZ
            PARSE ";%%tmp;;;%%piece", @dlgtext(S%z)
            if @equal(%%piece, "NO")
               %z = @diff(%z, %%dn2)
               GOSUB FormatZ
               LIST ADD, 8, S%%tmp|dud|JUMP|%z
               LIST ADD, 7, S%%tmp|S%%startSQ|JUMP|%z
           end
        end
     end
  end
  :CheckDownEnd
    exit

:MovePiece
  rem -- Uses %%square, %%caller, %%startSQ, %%startSQx, %%startSQy --
  PARSE ";%%destSQ;%%destx;%%desty", @dlgtext(%%square)
  DIALOG REMOVE, S%%destSQ
  DIALOG REMOVE, S%%startSQ
  rem -- Replace destination square with appropriate checker or king --
  if @equal(%%caller, "RC")@equal(%%caller, "RK")
     DIALOG REMOVE, HL
     if @both(@equal(%%caller, "RC"), @greater(%%desty, 0))
        DIALOG ADD,TEXT,%%square,%%desty,%%destx,50,50," "@chr(227)" "|%%destSQ|%%destx|%%desty|RC,Red,CLICK
     else
        DIALOG ADD,TEXT,%%square,%%desty,%%destx,50,50," "@chr(196)" "|%%destSQ|%%destx|%%desty|RK,Red,CLICK
     end
     DIALOG ADD,TEXT,HL,%%desty,%%destx,50,50,@chr(188),TRANSPARENT,Style2,CLICK
  else
     if @both(@equal(%%caller, BC), @greater(350, %%desty))
        DIALOG ADD,TEXT,%%square,%%desty,%%destx,50,50," "@chr(227)" "|%%destSQ|%%destx|%%desty|BC,Black,CLICK
     else
        DIALOG ADD,TEXT,%%square,%%desty,%%destx,50,50," "@chr(196)" "|%%destSQ|%%destx|%%desty|BK,Black,CLICK
     end
  end
  if %%checker
     %%checker = %%square
     WAIT .1
  else
     WAIT
  end
  rem -- Replace old checker with blank square --
  DIALOG ADD,TEXT,S%%startSQ,%%startSQy,%%startSQx,50,50,|%%startSQ|%%startSQx|%%startSQy|NO,Empty,CLICK
  PARSE ";%%startSQ;%%startSQx;%%startSQy;%%caller", @dlgtext(%%square)
  PARSE "%a;%b;%c;%d", @item(8)
  if %c
     %%remove = S%d
     GOSUB RemoveJumpedPiece
  end
  exit

:RemoveJumpedPiece
  PARSE ";%a;%b;%c;%d", @dlgtext(%%remove)
  DIALOG REMOVE, %%remove
  if @equal(%d, BC)@equal(%d, BK)
     %%compnum = @pred(%%compnum)
  else
     %%playernum = @pred(%%playernum)
  end
  rem -- Replace checker with blank square --
  DIALOG ADD,TEXT,%%remove,%c,%b,50,50,|%a|%b|%c|NO,Empty,CLICK
  rem -- Check for winner --
  if @equal(%%compnum, 0)
     INFO YOU WON!@cr()@cr()Starting New Game...@tab()
     DIALOG SELECT, 1
     DIALOG CLOSE
     goto Start/Restart
  end
  if @equal(%%playernum, 0)
     INFO COMPUTER WON...@cr()@cr()Starting New Game...@tab()
     DIALOG SELECT, 1
     DIALOG CLOSE
     goto Start/Restart
  end
  exit

:FormatZ
  if @greater(10, %z)
     %z = 0%z
  end
  exit


BLACKJACK
Code:

OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac

rem -- Look for a sound file under 50k in size --
LIST CREATE, 1
LIST FILELIST, 1, @windir()\media\*.wav
if @greater(@count(1), 0)
   REPEAT
     if @greater(50000, @file(@item(1, %x), Z))
        %%wavfile = @item(1, %x)
     end
     %x = @succ(%x)
   UNTIL %%wavfile @equal(%x, @count(1))
end
LIST CLOSE, 1

rem -- Change these defaults to your preference --
%%cash = 1000
%%currency = Dollars
%%BetIncrement = 10

rem -- Design for card back --
%b = @chr(88)

DIALOG CREATE,"BlackJack by Mac",-1,0,600,400
  DIALOG ADD,STYLE,Style1,Arial,10,B,DKGREEN,WHITE
  DIALOG ADD,STYLE,Style2,MS Sans Serif,8,B
  DIALOG ADD,STYLE,Trim1,,,,WHITE
  DIALOG ADD,STYLE,Trim2,,,,BLACK
  DIALOG ADD,STYLE,BlackS,Symbol,12,B,WHITE,BLACK
  DIALOG ADD,STYLE,RedS,Symbol,12,B,WHITE,DKRED
  DIALOG ADD,STYLE,BlackC,Arial,13,B,WHITE,BLACK
  DIALOG ADD,STYLE,RedC,Arial,13,B,WHITE,DKRED
  DIALOG ADD,STYLE,Blue,Symbol,19,B,LTBLUE,WHITE

  DIALOG ADD,TEXT,Table,0,0,600,400,,Style1

  DIALOG ADD,TEXT,Dealername,5,30,,,"Dealer",Style1
  DIALOG ADD,TEXT,DealerScore,5,105,,,,Style1
  DIALOG ADD,TEXT,Stat,145,200,,,"Change bet now if desired...",Style1
  DIALOG ADD,TEXT,Playername,255,30,,,"Player",Style1
  DIALOG ADD,TEXT,PlayerScore,255,105,,,,Style1
  DIALOG ADD,TEXT,PlayerCash,255,200,,,Player has  %%cash  %%currency,Style1

  DIALOG ADD,BUTTON,NewGame,180,30,80,22,"New Game",Style2
  DIALOG ADD,BUTTON,Deal,180,30,80,22,"Deal Cards",Style2
  DIALOG ADD,BUTTON,Help,180,115,80,22,,,Style2

  DIALOG ADD,BUTTON,Hit,180,200,80,22,,Style2
  DIALOG ADD,BUTTON,Stay,180,285,80,22,,Style2
  DIALOG HIDE, Hit
  DIALOG HIDE, Stay

  DIALOG ADD,TEXT,BetAmount,183,380,,,"Bet is:  "%%BetIncrement %%currency,Style1
  DIALOG ADD,BUTTON,BetDown,210,420,40,22,"<",BlackC
  DIALOG ADD,BUTTON,BetUp,210,460,40,22,">",BlackC

  rem -- Dealer's hidden card --
  DIALOG ADD,TEXT,HiddenCardTrim,30,30,76,98,,Trim1
  DIALOG ADD,TEXT,HiddenCard,32,32,72,94,%b%b%b%b%b %b%b%b%b%b %b%b%b%b%b,Blue
  DIALOG HIDE, HiddenCardTrim
  DIALOG HIDE, HiddenCard
DIALOG SHOW

%%bet = %%BetIncrement

rem -- For player's cards --
LIST CREATE, 1
rem -- For dealer's cards --
LIST CREATE, 2

rem -- Card  deck --
LIST CREATE, 9
GOSUB BuildDeck

rem -- Load chars for card display --
LIST CREATE, 8
LIST LOADTEXT, 8,
"dud
"dud
"2
"3
"4
"5
"6
"7
"8
"9
"10
"J
"Q
"K
"A

:EVLOOP
  DIALOG SET, PlayerCash, Player has  %%cash  %%currency
:EVLOOP1
  WAIT EVENT
  goto @event()

:NewGameBUTTON
  DIALOG SET, Stat, "Change bet now if desired..."
  DIALOG CLEAR, PlayerScore
  DIALOG HIDE, Hit
  DIALOG HIDE, Stay
  if @greater(%%Pcardnum, 0)@greater(%%Dcardnum, 0)
     GOSUB ClearTable
  end
  LIST CLEAR, 1
  LIST CLEAR, 2
  %%deckpos = 0
  %%Pcardnum = 0
  %%Dcardnum = 0
  %%PlayerPoints = 0
  %%DealerPoints = 0
  %%gameover = ""
  DIALOG HIDE, NewGame
  DIALOG SHOW, Deal
  DIALOG SHOW, BetDown
  DIALOG SHOW, BetUp
  goto EVLOOP

:DealBUTTON
  DIALOG HIDE, Deal
  DIALOG SHOW, NewGame
  DIALOG HIDE, BetDown
  DIALOG HIDE, BetUp
  DIALOG SET, Stat, "Game in progress..."
  DIALOG SHOW, Hit
  DIALOG SHOW, Stay
  GOSUB ShuffleCards
  rem -- Give dealer 2 cards (1 hidden), player 2 cards --
  GOSUB GetPlayerCard
  GOSUB GetDealerCard
  GOSUB GetPlayerCard
  GOSUB GetDealerCard
  if @both(@equal(%%PlayerPoints, 21), @not(@equal(%%DealerPoints, 21)))
     DIALOG SET, Stat, PLAYER WINS WITH BLACKJACK!
     %%cash = @fadd(%%cash, @fmul(1.5, %%bet))
     GOSUB ShowDealerCards
  end
  if @both(@equal(%%DealerPoints, 21), @not(@equal(%%PlayerPoints, 21)))
     DIALOG SET, Stat, DEALER WINS WITH BLACKJACK!
     %%cash = @fsub(%%cash, %%bet)
     GOSUB ShowDealerCards
  end
  if @both(@equal(%%PlayerPoints, 21), @equal(%%DealerPoints, 21))
     DIALOG SET, Stat, "TIE GAME (PUSH),  NO WINNER..."
     GOSUB ShowDealerCards
  end
  goto EVLOOP

:HitBUTTON
  if %%gameover
     goto EVLOOP
  end
  if @greater(21, %%PlayerPoints)
     GOSUB GetPlayerCard
  end
  if @greater(%%PlayerPoints, 21)
     DIALOG SET, Stat, "YOU BUSTED!  DEALER WINS..."
     %%cash = @fsub(%%cash, %%bet)
     GOSUB ShowDealerCards
  end
  if @equal(%%PlayerPoints, 21)
     goto StayBUTTON
  end
  goto EVLOOP

:StayBUTTON
  if %%gameover
     goto EVLOOP
  end
  if @greater(17, %%DealerPoints)
     REPEAT
       GOSUB GetDealerCard
     UNTIL @greater(%%DealerPoints, 16)
  end
  GOSUB ShowDealerCards
  GOSUB CheckFinalScore
  goto EVLOOP

:BetDownBUTTON
  if @greater(%%bet, 0)
     %%bet = @fsub(%%bet, %%BetIncrement)
  end
  DIALOG SET, BetAmount, "Bet is:  "%%bet %%currency
  goto EVLOOP

:BetUpBUTTON
  %%bet = @fadd(%%bet, %%BetIncrement)
  DIALOG SET, BetAmount, "Bet is:  "%%bet %%currency
  goto EVLOOP

:HelpBUTTON
  DIALOG CREATE,"BlackJack Help by Mac",-1,0,550,380,NOTITLE
    DIALOG ADD,STYLE,HlpStyle,Courier New,10
    DIALOG ADD,LIST,HelpList,5,5,540,345,HlpStyle
    DIALOG ADD,BUTTON,OK,355,250,60,20
  DIALOG SHOW
  GOSUB LoadHelp
  goto EVLOOP1

:OKBUTTON
  DIALOG SELECT, 1
  DIALOG CLOSE
  rem -- Kill extra event --
  %z = @event()
  goto EVLOOP

:CLOSE
  EXIT

rem ----------------- GOSUB ROUTINES -----------------------

:ClearTable
  rem -- Remove all player and dealer cards (9 max) --
  %x = 1
  REPEAT
    if @greater(%%Pcardnum, %x)@equal(%%Pcardnum, %x)
       DIALOG REMOVE, P%xCardTrim
       DIALOG REMOVE, P%xCardC
       DIALOG REMOVE, P%xCardS
    end
    if @greater(%%Dcardnum, %x)@equal(%%Dcardnum, %x)
       if @equal(%x, 1)
          DIALOG HIDE, HiddenCardTrim
          DIALOG HIDE, HiddenCard
          if %%showhidden
             %%showhidden = ""
             DIALOG REMOVE, D%xCardTrim
             DIALOG REMOVE, D%xCardC
             DIALOG REMOVE, D%xCardS
          end
       else
          DIALOG REMOVE, D%xCardTrim
          DIALOG REMOVE, D%xCardC
          DIALOG REMOVE, D%xCardS
       end
    end
    %x = @succ(%x)
  UNTIL @greater(%x, 9)
  DIALOG SET, DealerScore, ""
  exit

:GetPlayerCard
  GOSUB GetCardInfo
  %%Pcardnum = @succ(%%Pcardnum)
  %z = %%Pcardnum
  DIALOG ADD,TEXT,P%zCardTrim,280,@prod(%z, 30),76,98,,Trim2
  if @equal(%%suit, @chr(168))@equal(%%suit, @chr(169))
     DIALOG ADD,TEXT,P%zCardC,281,@sum(@prod(%z, 30),1),74,96," "%%char@cr()@cr()@cr()@cr()"           "%%char,RedC
     DIALOG ADD,TEXT,P%zCardS,301,@sum(@prod(%z, 30),1),74,56," "%%suit@cr()@cr()"           "%%suit,RedS
  else
     DIALOG ADD,TEXT,P%zCardC,281,@sum(@prod(%z, 30),1),74,96," "%%char@cr()@cr()@cr()@cr()"           "%%char,BlackC
     DIALOG ADD,TEXT,P%zCardS,301,@sum(@prod(%z, 30),1),74,56," "%%suit@cr()@cr()"           "%%suit,BlackS
  end
  LIST ADD, 1, @item(9, %%deckpos)
  %%deckpos = @succ(%%deckpos)
  GOSUB CheckPlayerPoints
  exit

:GetDealerCard
  %%Dcardnum = @succ(%%Dcardnum)
  if @equal(%%Dcardnum, 1)
     DIALOG SHOW, HiddenCardTrim
     DIALOG SHOW, HiddenCard
  else
     rem -- Show another card --
     GOSUB GetCardInfo
     %z = %%Dcardnum
     DIALOG ADD,TEXT,D%zCardTrim,30,@sum(70,@prod(%z, 30)),76,98,,Trim2
     if @equal(%%suit, @chr(168))@equal(%%suit, @chr(169))
        DIALOG ADD,TEXT,D%zCardC,31,@sum(70,@prod(%z, 30),1),74,96," "%%char@cr()@cr()@cr()@cr()"           "%%char,RedC
        DIALOG ADD,TEXT,D%zCardS,51,@sum(70,@prod(%z, 30),1),74,56," "%%suit@cr()@cr()"           "%%suit,RedS
     else
        DIALOG ADD,TEXT,D%zCardC,31,@sum(70,@prod(%z, 30),1),74,96," "%%char@cr()@cr()@cr()@cr()"           "%%char,BlackC
        DIALOG ADD,TEXT,D%zCardS,51,@sum(70,@prod(%z, 30),1),74,56," "%%suit@cr()@cr()"           "%%suit,BlackS
     end
  end
  LIST ADD, 2, @item(9, %%deckpos)
  %%deckpos = @succ(%%deckpos)
  GOSUB CheckDealerPoints
  exit

:GetCardInfo
  %%value  = @substr(@item(9, %%deckpos),1,2)
  %%char = @item(8, %%value)
  if @equal(@substr(@item(9, %%deckpos),3), "c")
     %%suit = @chr(167)
  end   
  if @equal(@substr(@item(9, %%deckpos),3), "d")
     %%suit = @chr(168)
  end   
  if @equal(@substr(@item(9, %%deckpos),3), "h")
     %%suit = @chr(169)
  end   
  if @equal(@substr(@item(9, %%deckpos),3), "s")
     %%suit = @chr(170)
  end   
  exit

:CheckPlayerPoints
  %%PlayerPoints = 0
  %%ace = 0
  %x = 0
  REPEAT
    %y = @substr(@item(1, %x),1,2)
    if @both(@greater(%y, 10), @greater(14, %y))
       %y = 10
    end
    if @equal(%y, 14)
       %y = 0
       %%ace = @succ(%%ace)
    end
    %%PlayerPoints = @sum(%%PlayerPoints, %y)
    %x = @succ(%x)
  UNTIL @equal(%x, @count(1))
  %%Points = %%PlayerPoints
  GOSUB CheckAces
  %%PlayerPoints = %%Points
  DIALOG SET, PlayerScore, "Points = "%%PlayerPoints
  exit

:CheckDealerPoints
  %%DealerPoints = 0
  %%ace = 0
  %x = 0
  REPEAT
    %y = @substr(@item(2, %x),1,2)
    if @both(@greater(%y, 10), @greater(14, %y))
       %y = 10
    end
    if @equal(%y, 14)
       %y = 0
       %%ace = @succ(%%ace)
    end
    %%DealerPoints = @sum(%%DealerPoints, %y)
    %x = @succ(%x)
  UNTIL @equal(%x, @count(2))
  %%Points = %%DealerPoints
  GOSUB CheckAces
  %%DealerPoints = %%Points
  exit

:CheckAces
  rem -- Determine if aces = 1 or 11 points, only 1st can be 11) --
  if @equal(%%ace, 1)
     if @greater(11, %%Points)
        %%Points = @sum(%%Points, 11)
     else
        %%Points = @sum(%%Points, 1)
     end
  end
  if @equal(%%ace, 2)
     if @greater(10, %%Points)
        %%Points = @sum(%%Points, 12)
     else
        %%Points = @sum(%%Points, 2)
     end
  end
  if @equal(%%ace, 3)
     if @greater(9, %%Points)
        %%Points = @sum(%%Points, 13)
     else
        %%Points = @sum(%%Points, 3)
     end
  end
  if @equal(%%ace, 4)
     if @greater(7, %%Points)
        %%Points = @sum(%%Points, 14)
     else
        %%Points = @sum(%%Points, 4)
     end
  end
  exit

:CheckFinalScore
  if @greater(%%DealerPoints, 21)
     DIALOG SET, Stat, "YOU WIN!  DEALER BUSTED..."
     %%cash = @fadd(%%cash, %%bet)
     exit
  end
  if @greater(%%PlayerPoints, %%DealerPoints)
     DIALOG SET, Stat, "YOU WIN!"
     %%cash = @fadd(%%cash, %%bet)
     exit
  end
  if @greater(%%DealerPoints, %%PlayerPoints)
     DIALOG SET, Stat, "DEALER WINS..."
     %%cash = @fsub(%%cash, %%bet)
     exit
  end
  if @equal(%%DealerPoints, %%PlayerPoints)
     DIALOG SET, Stat, "TIE GAME (PUSH),  NO WINNER..."
     exit
  end
  exit

:ShowDealerCards
  rem -- Show dealer's hidden card and play sound if available --
  if %%wavfile
     PLAY %%wavfile
  end
  %%deckpos = 1
  GOSUB GetCardInfo
  %%showhidden = 1
  DIALOG ADD,TEXT,D1CardTrim,30,30,76,98,,Trim2
  if @equal(%%suit, @chr(168))@equal(%%suit, @chr(169))
     DIALOG ADD,TEXT,D1CardC,31,31,74,96," "%%char@cr()@cr()@cr()@cr()"           "%%char,RedC
     DIALOG ADD,TEXT,D1CardS,51,31,74,56," "%%suit@cr()@cr()"           "%%suit,RedS
  else
     DIALOG ADD,TEXT,D1CardC,31,31,74,96," "%%char@cr()@cr()@cr()@cr()"           "%%char,BlackC
     DIALOG ADD,TEXT,D1CardS,51,31,74,56," "%%suit@cr()@cr()"           "%%suit,BlackS
  end
  DIALOG SET, DealerScore, "Points = "%%DealerPoints
  %%gameover = 1
  exit

:BuildDeck
  %a = "cdhs"
  %x = 1
  REPEAT
    %n = 2
    %s = @substr(%a, %x)
    REPEAT
      if @greater(10, %n)
         %n = 0%n
      end
      LIST ADD, 9, %n%s
      %n = @succ(%n)
    UNTIL @greater(%n, 14)
    %x = @succ(%x)
  UNTIL @greater(%x, 4)
  exit

:ShuffleCards
  %y = 0
  :Shuffle
    %x = @diff(@count(9), 1)
    REPEAT
      rem -- get last 4 digits (use as rough random number) --
      %t = @datetime()
      %t = @substr(%t, @diff(@len(%t), 3), @len(%t))
      if @equal(@pos(".", %t), 0)
         rem -- card position --
         %p = @mod(%t, @sum(%x, 1))
         rem -- get card to swap --
         %c = @item(9, %p)
         rem -- card store --
         %s = @item(9, %x)
         LIST DELETE, 9
         LIST INSERT, 9, %c
         LIST SEEK, 9, %p
         LIST DELETE, 9
         LIST INSERT, 9, %s
         %x = @pred(%x)
      end
    UNTIL @greater(1, %x)
    %y = @succ(%y)
    rem -- Shuffle 2 times --
    if @greater(2, %y)
       goto Shuffle
    end
    exit

:LoadHelp
LIST LOADTEXT, HelpList,
"BlackJack (Casino Rules)
"
"Blackjack: 21 points on the first two cards.
"Bust: Going over 21 points.
"Hit: To receive another card.
"Stay: To refuse additional cards.
"Push: A tied score with no winner.
"
"Bets are placed before cards are dealt. Player bets that his
"hand will beat the dealer's hand without exceeding 21.
"
"The player and the dealer each receive two cards (one of the
"dealer's cards is face down). The player then decides if he
"wants a 'hit' or to 'stay'.
"
"An ace counts 1 or 11, a face card 10, and all other cards at
"their face value. A blackjack wins the bet unless the dealer
"also has a blackjack. Blackjacks pay you 1 1/2 times the bet.
"
"The dealer must draw a card if he's holding a value of 16 or
"under, and must stay if he's holding a value of 17 or over.
exit


ANTI-AIRCRAFT
Code:

rem -- You now also have a tank to deal with. Click on the tank or the
rem -- ground to launch mortars, and allow for the tank's movement.
rem -- It takes 3 tank shells to equal 1 bomb hit on your bunker.
rem -- Click on the plane to fire a missile at it. When the crosshair
rem -- is on target, a "*Lock*" message will appear. The plane drops
rem -- bombs at your bunker which shows an "x" for each hit. If you
rem -- get over 3 bomb hits, you lose the game. If you destroy 25
rem -- planes before your bunker goes, you win the game.
rem -- When you destroy the plane, it's bomb will disappear. This
rem -- could prevent a bomb hit if you're fast enough...
rem -- When you miss a "*Lock*", your missiles don't destroy the plane.
rem -- If you can't handle the standard game, you can upgrade your
rem -- missile speed with the "Missile Upgrade" checkbox. When you get
rem -- 3 bomb hits, it's probably a good idea to do this anyway...
rem -- Code Notes: Some things are moved off screen instead of using
rem -- DIALOG HIDE/SHOW. Some styles are used by 2 or more elements,
rem -- some use the foreground, some use the background, some use both.

OPTION SCALE, 96
OPTION DECIMALSEP, "."

%%missx = 232
%%missy = 345
%%mortx = 245
%%morty = 348
%%tankx = 500
%%tanky = 355
%%shellx = @sum(%%tankx, 4)
%%shelly = @diff(%%tanky,2)
TITLE By Mac
DIALOG CREATE,"Anti-Aircraft",-1,0,500,400
  rem -> If you don't have "Wingdings" font, rem this line --
  DIALOG ADD,STYLE,Style1,Wingdings,12,BC,,BLACK

  DIALOG ADD,STYLE,Style2,Arial,12,C,,BLACK
  DIALOG ADD,STYLE,Style3,Arial,8,C,CYAN,BLACK
  DIALOG ADD,STYLE,Style4,Arial,12,B,LTBLUE,RED
  DIALOG ADD,STYLE,Style5,Arial,12,B,BROWN,YELLOW
  DIALOG ADD,STYLE,Style6,Arial,8,C,BLACK,YELLOW

  DIALOG ADD,TEXT,Sky,25,0,500,275,,,Style3,CROSS,CLICK
  DIALOG ADD,TEXT,Ground,300,0,500,100,,,Style5,CROSS,CLICK
  DIALOG ADD,TEXT,Lock,0,600,36,,"*Lock*",,Style3,TRANSPARENT

  rem -- Set tankgun @sum(%%tankx, 10) for right side --
  DIALOG ADD,TEXT,Tank,%%tanky,%%tankx,14,7,"****",,Style6,CROSS,CLICK
  DIALOG ADD,TEXT,Shell,%%shelly,%%shellx,3,1,,,Style3
  DIALOG ADD,TEXT,Tanktop,@diff(%%tanky,3),@sum(%%tankx, 4),6,3,,,Style6,CROSS,CLICK
  DIALOG ADD,TEXT,Tankgun,@diff(%%tanky,2),%%tankx,4,1,,,Style6,CROSS,CLICK

  DIALOG ADD,TEXT,BunkerBase,355,228,44,10,,,Style6,CROSS,CLICK
  DIALOG ADD,TEXT,Bunker,350,230,40,15,,,Style6,CROSS,CLICK
  DIALOG ADD,TEXT,RadarMast,335,240,40,20,"|",,Style2,TRANSPARENT,CROSS,CLICK
  DIALOG ADD,TEXT,Radar,332,240,40,20,,,Style3,TRANSPARENT,CROSS,CLICK

  DIALOG ADD,TEXT,Mortar,%%morty,%%mortx,3,3,,,Style4,CROSS,CLICK
  DIALOG ADD,TEXT,Missile,%%missy,%%missx,,,"*",,Style4,TRANSPARENT,CROSS,CLICK
  DIALOG ADD,TEXT,Bomb,40,600,5,2,,,Style6

  DIALOG ADD,TEXT,BunkerXXX,330,220,60,40,,,Style5
  DIALOG HIDE, BunkerXXX

  rem -> If you don't have "Wingdings" font, rem this line and use the following line --
  DIALOG ADD,TEXT,Plane,0,600,12,15,@chr(81),,Style1,TRANSPARENT,CROSS,CLICK
  rem -> DIALOG ADD,TEXT,Plane,0,600,12,15,">",,Style2,TRANSPARENT,CROSS,CLICK

  DIALOG ADD,TEXT,Star1,400,500,,,"*",,Style2,TRANSPARENT
  DIALOG ADD,TEXT,Star2,400,500,,,"*",,Style2,TRANSPARENT
  DIALOG ADD,TEXT,Star3,400,500,,,"*",,Style2,TRANSPARENT

  DIALOG ADD,TEXT,Star4,400,500,,,"*",,Style2,TRANSPARENT
  DIALOG ADD,TEXT,Star5,400,500,,,"*",,Style2,TRANSPARENT
  DIALOG ADD,TEXT,Star6,400,500,,,"*",,Style2,TRANSPARENT

  DIALOG ADD,TEXT,TX1,5,5,,,"Speed"
  DIALOG ADD,BUTTON,Slow,2,40,16,20,"<"
  DIALOG ADD,BUTTON,Fast,2,57,16,20,">"
  DIALOG ADD,TEXT,TX2,5,100,,,"Hits:      Missed:           Games Won:      Games Lost:"
  DIALOG ADD,CHECK,CK1,5,400,,14,"Missile Upgrade",,CLICK
DIALOG SHOW

rem -- hits, misses, games won, games lost --
%h = 0
%m = 0
%w = 0
%l = 0

%%attack = "AIR"

%x = 5
%y = 40
%%timer = 0
%s = 200
%%drop = 5
%%incoming = 1
%%bx = %x
%%by = %y
%%mspeed = 1

:EVLOOP
  REPEAT
    if @equal(%%attack, "AIR")
      rem -- Get approx mouse pos on program window --
      PARSE "%%mx;%%my", @mousepos()
      %%mx = @diff(@diff(%%mx, @winpos("Anti-Aircraft", L)), 3)
      %%my = @diff(@diff(%%my, @winpos("Anti-Aircraft", T)), 22)
      rem -- Show Plane Lock --
      if @both(@greater(%%mx, %x), @greater(@sum(%x, 12), %%mx))
        if @both(@greater(%%my, %y), @greater(@sum(%y, 15), %%my))
          DIALOG SETPOS, Lock, @sum(%%my, 10), @diff(%%mx, 15)
        else
          DIALOG SETPOS, Lock, 400,500
        end
      else
        DIALOG SETPOS, Lock, 400,500
      end
      rem -- Allow extra 20 pixels for missile hit offscreen --
      if @greater(520, %x)
        %x = @succ(%x)
      else
        GOSUB Reset
        GOSUB Random
        %y = @prod(20, %r)
        %x = 1
        %%drop = %r
      end
      DIALOG SETPOS,Plane,%y,%x
      if @equal(%%drop, %x)
        %%incoming = 1
        %%bx = %x
        %%by = %y
      end
      rem -- Drop bomb, check for hit on bunker --
      if %%incoming
         DIALOG SETPOS,Bomb,%%by,%%bx
         %%bx = @succ(%%bx)
         %%by = @succ(%%by)
         if @greater(%%by, 355)
            %%incoming = ""
            DIALOG SETPOS,Bomb,400,500
            if @both(@greater(%%bx, 220), @greater(270, %%bx))
              GOSUB BunkerHit
            end
         end
      end
      DIALOG SETPOS,Missile,%%missy,%%missx
      rem -- Have missile chase plane --
      if %%fire
        if @greater(%%missx, %x)
          %%missx = @diff(%%missx, 1)
        end
        if @greater(%x, %%missx)
          %%missx = @sum(%%missx, 2)
        end
        if @greater(%%missy, %y)
          %%missy = @diff(%%missy, %%mspeed)
        else
          %%missy = %y
        end
      end
      rem -- Check for missile hit --
      if @both(@equal(%%missx, %x), @equal(%%missy, %y))@both(@equal(@sum(%%missx, 1), %x), @equal(%%missy, %y))
        if %%lock
          GOSUB DestroyPlane
        else
          %%fire = ""
          %m = @succ(%m)
          %%missx = 232
          %%missy = 345
          DIALOG SETPOS,Missile,%%missy,%%missx
        end
      end
    else
      if @equal(%%tankdir, L)
        rem -- Use %%timer var to slow tank --
        if @equal(@mod(%%timer, 5), 0)
          if @greater(%%tankx, 320)
            %%tankx = @pred(%%tankx)
            DIALOG SETPOS, Tank, %%tanky, %%tankx
            DIALOG SETPOS, Tanktop, @diff(%%tanky,3), @sum(%%tankx, 4)
            DIALOG SETPOS, Tankgun, @diff(%%tanky,2),%%tankx
          end
        end
        rem -- Fire tank shell --
        DIALOG SETPOS, Shell, %%shelly, %%shellx
        if @greater(%%shellx, 265)
          %%shellx = @pred(%%shellx)
        end
        if @both(@equal(@mod(%%timer, 200), 0), @greater(270, %%shellx))
          %%shellhit = 1
        end
      else
        rem -- Use %%timer var to slow tank --
        if @equal(@mod(%%timer, 5), 0)
          if @greater(180, %%tankx)
            %%tankx = @succ(%%tankx)
            DIALOG SETPOS, Tank, %%tanky, %%tankx
            DIALOG SETPOS, Tanktop, @diff(%%tanky,3), @sum(%%tankx, 4)
            DIALOG SETPOS, Tankgun, @diff(%%tanky,2),@sum(%%tankx, 10)
          end
        end
        rem -- Fire tank shell --
        DIALOG SETPOS, Shell, %%shelly, %%shellx
        if @greater(235, %%shellx)
          %%shellx = @succ(%%shellx)
        end
        if @both(@equal(@mod(%%timer, 200), 0), @greater(%%shellx, 230))
          %%shellhit = 1
        end
      end
      if %%shellhit
        %%shellhit = ""
        %%shellx = @sum(%%tankx, 6)
        %%tankscore = @succ(%%tankscore)
        if @equal(@mod(%%tankscore, 3), 0)
          GOSUB BunkerHit
        else
          %%bunkhit = 0
          %%bunkhitx = 250
          %%bunkhity = 345
        end
      end
      rem -- Check for mortar fired, and tank hit --
      DIALOG SETPOS,Mortar,%%morty,%%mortx
      if %%mortar
        if @equal(%%dir, R)
          %%mortx = @succ(%%mortx)
          if @greater(%%halfway, %%mortx)
            %%morty = @pred(%%morty)
          else
            %%morty = @succ(%%morty)
          end
        end
        if @equal(%%dir, L)
          %%mortx = @pred(%%mortx)
          if @greater(%%mortx, %%halfway)
            %%morty = @pred(%%morty)
          else
            %%morty = @succ(%%morty)
          end
        end
        rem -- Check if tank is hit --
        if @both(@greater(%%mortx, %%tankx), @greater(@sum(%%tankx,14), %%mortx))
          if @both(@greater(%%morty, @diff(%%tanky, 3)), @greater(@sum(%%tanky,7), %%morty))
            %%tankhit = 1
          end
        end
        if %%tankhit @equal(%%mortx, %%mortdestx)
          if @not(%%tankhit)
            %m = @succ(%m)
          end
          %%mhit = 0
          %%mhitx = %%mortx
          %%mhity = %%morty
          %%mortar = ""
          %%mortx = 245
          %%morty = 348
        end
      end
      rem -- Mortar explosion --
      if @greater(26, %%mhit)
        %%mhity = @pred(%%mhity)
        DIALOG SETPOS, Star1, %%mhity, @diff(%%mhitx, %%mhit)
        DIALOG SETPOS, Star2, %%mhity, %%mhitx
        DIALOG SETPOS, Star3, %%mhity, @sum(%%mhitx, %%mhit)
        %%mhit = @succ(%%mhit)
        if @greater(%%mhit, 25)
          DIALOG SETPOS, Star1, 400, 500
          DIALOG SETPOS, Star2, 400, 500
          DIALOG SETPOS, Star3, 400, 500
          if %%tankhit
            %h = @succ(%h)
            GOSUB CheckWin
            %%tankhit = ""
            %%tankscore = ""
            %%attack = "AIR"
            DIALOG SHOW, Plane
            DIALOG SETPOS, Tank, 400, 500
            DIALOG SETPOS, Tanktop, 400, 500
            DIALOG SETPOS, Tankgun, 400, 500
            DIALOG SETPOS, Shell, 400, 500
          end
        end
      end
    end
    rem -- Explosion on bunker --
    if @greater(26, %%bunkhit)
      %%bunkhity = @pred(%%bunkhity)
      DIALOG SETPOS, Star4, %%bunkhity, @diff(%%bunkhitx, %%bunkhit)
      DIALOG SETPOS, Star5, %%bunkhity, %%bunkhitx
      DIALOG SETPOS, Star6, %%bunkhity, @sum(%%bunkhitx, %%bunkhit)
      %%bunkhit = @succ(%%bunkhit)
      if @greater(%%bunkhit, 25)
        DIALOG SETPOS, Star4, 400, 500
        DIALOG SETPOS, Star5, 400, 500
        DIALOG SETPOS, Star6, 400, 500
      end
    end
    rem -- Radar rotation --
    if @equal(@mod(%%timer, 25), 0)
      %%rotate = 0
      if @equal(@dlgtext(Radar), "oo")
        DIALOG SET, Radar, "o"
      else
        DIALOG SET, Radar, "oo"
      end
    end
    GOSUB Delay
    DIALOG SET, TX2,Hits:%h"      "Missed:%m"           "Games Won:%w"      "Games Lost:%l
    %%timer = @succ(%%timer)
    if @greater(%%timer, 1000)
      %%timer = 0
    end
    %e = @event()
  UNTIL %e
  goto %e

:SlowBUTTON
  %s = @sum(%s, 20)
  goto EVLOOP

:FastBUTTON
  %s = @diff(%s, 20)
  if @greater(0, %s)
    %s = 0
  end
  goto EVLOOP

:CK1CLICK
  if @dlgtext(CK1)
    %%mspeed = 2
  else
    %%mspeed = 1
  end
  goto EVLOOP

:PlaneCLICK
  if @not(%%fire)
    %%lock = 1
    %%fire = 1
  end
  DIALOG SETPOS, Lock, 400, 500
  goto EVLOOP

:SkyCLICK
  if @equal(%%attack, "AIR")
    %%fire = 1
  end
  goto EVLOOP

:TankCLICK
:TanktopCLICK
:TankgunCLICK
:GroundCLICK
  if @both(@equal(%%attack, "GROUND"), @not(%%mortar))
    PARSE "%%mortdestx;%%mortdesty", @mousepos()
    %%mortdestx = @diff(@diff(%%mortdestx, @winpos("Anti-Aircraft", L)), 3)
    %%mortdesty = @diff(@diff(%%mortdesty, @winpos("Anti-Aircraft", T)), 22)
    rem -- Can't fire mortar too close --
    if @both(@greater(290, %%mortdestx), @greater(%%mortdestx, 210))
      goto EVLOOP
    end
    %%mortar = 1
    rem -- Figure simple tragectory using an adjusted halfway X --
    if @greater(%%mortdestx, %%mortx)
      %%dir = R
      %%halfway = @diff(%%mortdestx, @div(@diff(%%mortdestx, %%mortx), 2))
      if @greater(%%morty, %%mortdesty)
        %%ydiff = @diff(%%morty, %%mortdesty)
        %%halfway = @sum(%%halfway, @div(%%ydiff, 2))
      end
      if @greater(%%mortdesty, %%morty)
        %%ydiff = @diff(%%mortdesty, %%morty)
        %%halfway = @diff(%%halfway, @div(%%ydiff, 2))
      end
    else
      %%dir = L
      %%halfway = @diff(%%mortx, @div(@diff(%%mortx, %%mortdestx), 2))
      if @greater(%%morty, %%mortdesty)
        %%ydiff = @diff(%%morty, %%mortdesty)
        %%halfway = @diff(%%halfway, @div(%%ydiff, 2))
      end
      if @greater(%%mortdesty, %%morty)
        %%ydiff = @diff(%%mortdesty, %%morty)
        %%halfway = @sum(%%halfway, @div(%%ydiff, 2))
      end
    end
  end
  goto EVLOOP

:BunkerCLICK
:BunkerBaseCLICK
:MissileCLICK
:MortarCLICK
:RadarCLICK
:RadarMastCLICK
  goto EVLOOP

:CLOSE
  EXIT

  rem --------- GOSUB ------------

:BunkerHit
  %%bunkhit = 0
  %%bunkhitx = 250
  %%bunkhity = 345
  %%bombed = %%bombed"x"
  DIALOG SET, Bunker, %%bombed
  rem -- 4 hits and you're history --
  if @greater(@len(%%bombed), 3)
    DIALOG SHOW, BunkerXXX
    INFO The bunker was destroyed.@cr()@cr()Your next of kin will be notified...@tab()
    %l = @succ(%l)
    DIALOG CLEAR, Bunker
    GOSUB NewGame
    DIALOG HIDE, BunkerXXX
  end
  exit

:DestroyPlane
  GOSUB Reset
  DIALOG HIDE, Plane
  %h = @succ(%h)
  %i = 0
  REPEAT
    %y = @succ(%y)
    DIALOG SETPOS, Star1, %y, @diff(%x, %i)
    DIALOG SETPOS, Star2, %y, %x
    DIALOG SETPOS, Star3, %y, @sum(%x, %i)
    if @equal(@mod(%y, 25), 0)
      DIALOG SET, Radar, "oo"
    end
    if @equal(@mod(%y, 50), 0)
      DIALOG SET, Radar, "o"
    end
    %i = @succ(%i)
    GOSUB Delay
  UNTIL @greater(%i, 50)
  DIALOG SETPOS, Star1, 400, 500
  DIALOG SETPOS, Star2, 400, 500
  DIALOG SETPOS, Star3, 400, 500
  GOSUB Random
  %y = @prod(20, %r)
  %x = 1
  GOSUB CheckWin
  %%attack = "GROUND"
  GOSUB Random
  if @greater(%r, 5)
    %%tankdir = L
    %%tankx = 495
  else
    %%tankdir = R
    %%tankx = 5
  end
  %%tanky = 355
  %%shelly = @diff(%%tanky,2)
  %%shellx = @sum(%%tankx, 6)
  exit

:CheckWin
  rem -- Check for player win --
  if @greater(%h, 24)
    if @equal(%%mspeed, 1)
      INFO "You Won Commander!"@tab()
    else
      INFO "So you needed a missile upgrade to win..."@tab()
    end
    %w = @succ(%w)
    GOSUB NewGame
  end
  exit

:NewGame
  DIALOG CLEAR, Bunker
  %%bombed = ""
  %h = 0
  %m = 0
  if @equal(%%attack, "GROUND")
    %%mhit = 0
    %%tankhit = ""
    %%tankscore = ""
    %%attack = "AIR"
    DIALOG SHOW, Plane
    DIALOG SETPOS, Tank, 400, 500
    DIALOG SETPOS, Tanktop, 400, 500
    DIALOG SETPOS, Tankgun, 400, 500
    DIALOG SETPOS, Shell, 400, 500
  end
  %%bunkhit = 26
  %%mhit = 26
:Reset
  %%lock = ""
  %%fire = ""
  %%incoming = ""
  DIALOG SETPOS, Bomb, 400, 500
  %%missx = 232
  %%missy = 345
  DIALOG SETPOS,Missile,%%missy,%%missx
  %%mortar = ""
  %%mortx = 245
  %%morty = 348
  DIALOG SETPOS,Mortar,%%morty,%%mortx
  exit

:Delay
  %d = %s
  REPEAT
    %d = @pred(%d)
  UNTIL @greater(1, %d)
  exit

:Random
  rem -- Get random number using @datetime() with no parameters.
  %r = @datetime()
  rem -- Get last digit (use as random number)
  %r = @substr(%r, @len(%r))
  rem -- We want 2 minimim --
  if @greater(2, %r)
    goto Random
  end
  exit

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group