Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' The Gridmaster
- ' By Logan G. / "TheBaykun"
- ' September 25, 2013
- ' Instructions: bit.ly/15uraoo
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- RETINA on
- StartingMoney = 1250 '[Default: 1250]
- MaximumPrice = 2000 '[Default: 2000]
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- abcd:
- SLEEP 1
- BCOLOR 0,0,0
- TCOLOR 255,255,255
- PRINT "Loading."
- sw=ScreenWidth
- sh=ScreenHeight
- DIM gr(7,7),gr2(7,7)
- COLOR 150,150,150
- sz=50
- szz=40
- szzz=60
- FOR i=1 TO 7
- FOR j=1 TO 7
- SLEEP 0.01
- gr(i,j)=0
- gr2(i,j)=INT(1+(RND*(maximumprice-1)))
- 'PRINT gr2(i,j)
- IF i>1 AND i<7 AND j>1 AND j<7 THEN
- LINE (i*sz)-szzz,(j*sz)-szzz,(i*sz)-szzz,(j*sz)-szzz+sz,2
- LINE (i*sz)-szzz,(j*sz)-szzz,(i*sz)-szzz+sz,(j*sz)-szzz,2
- ENDIF
- NEXT
- NEXT
- CLS tty
- PRINT "Loading.."
- i=7
- j=7
- LINE (2*sz)-szzz,(j*sz)-szzz,(i*sz)-szzz,(j*sz)-szzz,2
- LINE (i*sz)-szzz,(2*sz)-szzz,(i*sz)-szzz,(j*sz)-szzz,2
- gr(2,2)=1 'you
- gr(6,6)=2 'enemy
- gr(3,2)=3
- gr(3,3)=3
- gr(2,3)=3
- '0: neutral, 1: you, 2: enemy, 3: adjacent
- cash=startingmoney
- ecash=startingmoney
- cells=1
- ecells=1
- enemyDef=0
- firstturn=1
- ca$="Welcome to Gridmaster."
- cb$="Tap an adjacent cell to begin."
- SLEEP 0.1
- CLS tty
- PRINT "Loading..."
- COLOR 0,200,0
- a=2
- b=2
- GOSUB drawRect
- COLOR 200,0,0
- a=6
- b=6
- GOSUB drawRect
- COLOR 75,75,75
- a=3
- b=2
- GOSUB drawRect
- a=3
- b=3
- GOSUB drawRect
- a=2
- b=3
- GOSUB drawRect
- GOSUB updateHUD
- GOSUB updateConsole
- SLEEP 0.1
- CLS tty
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- loopA:
- SLEEP 0.01
- CLS tty
- PRINT ""
- 'PRINT STR$(ecash)
- 'PAUSE ""
- IF cells=0 THEN
- cash=0
- ENDIF
- IF Touch>0 AND TouchX>30 AND TouchX<sw-45 AND TouchY<sh-85 AND TouchY>30 THEN
- tx=INT(2+(TouchX-30)/sz)
- ty=INT(2+(TouchY-30)/sz)
- IF ty=7 THEN
- ty=6
- ENDIF
- IF ty=1 THEN
- ty=2
- ENDIF
- IF tx=7 THEN
- tx=6
- ENDIF
- IF tx=1 THEN
- tx=2
- ENDIF
- IF gr(tx,ty)=3 THEN
- GOSUB attackCell
- GOSUB enemyAI
- ENDIF
- IF gr(tx,ty)=2 THEN
- yes=0
- FOR i=(tx-1) TO (tx+1)
- FOR j=(ty-1) TO (ty+1)
- IF gr(i,j)=1 THEN
- yes=1
- ENDIF
- NEXT
- NEXT
- IF yes=1 THEN
- GOSUB attackEnemy
- IF ecells=0 THEN
- ca$="The enemy has been defeated."
- enemyDef=1
- 'cb$="You are the Gridmaster!"
- GOSUB updateConsole
- CLS tty
- 'END
- ENDIF
- GOSUB enemyAI
- ENDIF
- ENDIF
- 'firstturn=0
- ENDIF
- GOTO loopA
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- drawRect:
- RECT (a*sz)-szzz+1,(b*sz)-szzz+1,((a+1)*sz)-szzz-1,((b+1)*sz)-szzz-1
- RETURN
- updateHUD:
- COLOR 0,0,0
- RECT 0,0,sw,35
- COLOR 255,255,0
- CIRCLE 15,15,6
- TEXTFONT "Arial Rounded","Bold",18
- DRAWTEXT STR$(cash),25,4
- COLOR 255,255,255
- TEXTFONT "Arial",16
- DRAWTEXT "Cells: "+STR$(cells),sw/2,5
- RETURN
- updateConsole:
- COLOR 0,0,0
- RECT 0,sh-70,sw,sh
- COLOR 200,255,200
- TEXTFONT "Helvetica","Italic",16
- DRAWTEXT ca$,10,sh-60
- COLOR 255,200,200
- DRAWTEXT cb$,10,sh-30
- RETURN
- attackCell:
- CLS tty
- PRINT ""
- INPUT "Attack ("+STR$(tx-1)+","+STR$(ty-1)+") with how much cash?: ",ac
- IF ac<1 OR ac>cash THEN
- ELSE
- ' IF firstturn=1 THEN
- ' firstturn=0
- ' gr2(tx,ty)=ac-1
- ' ENDIF
- cash=cash-ac
- IF ac>gr2(tx,ty) THEN
- gr(tx,ty)=1
- cells=cells+1
- cash=gr2(tx,ty)+cash
- ' IF firstturn=0 THEN
- IF 2000-ac>0 THEN
- cash=cash+(2000-ac)
- ENDIF
- ' ENDIF
- GOSUB updateHUD
- COLOR 0,200,0
- a=tx
- b=ty
- GOSUB drawRect
- ca$="You took cell ("+STR$(a-1)+","+STR$(b-1)+")."
- COLOR 75,75,75
- FOR i=(tx-1) TO (tx+1)
- FOR j=(ty-1) TO (ty+1)
- IF gr(i,j)=0 AND i>1 AND i<7 AND j>1 AND j<7 THEN
- gr(i,j)=3
- a=i
- b=j
- GOSUB drawRect
- ENDIF
- NEXT
- NEXT
- IF cells=25 THEN
- ca$="You own every cell!"
- cb$="You are the Gridmaster!"
- GOSUB updateConsole
- CLS tty
- PRINT ""
- PAUSE "Tap to restart."
- CLS
- GOTO abcd
- ENDIF
- ENDIF
- IF ac=gr2(tx,ty) THEN
- GOSUB updateHUD
- gr2(tx,ty)=0
- ca$="You tied with cell ("+STR$(tx-1)+","+STR$(ty-1)+")."
- ENDIF
- IF ac<gr2(tx,ty) THEN
- GOSUB updateHUD
- gr2(tx,ty)=gr2(tx,ty)-ac
- ca$="You failed to take cell ("+STR$(tx-1)+","+STR$(ty-1)+")."
- ENDIF
- GOSUB updateConsole
- GOSUB checkBankrupt
- ENDIF
- RETURN
- attackEnemy:
- CLS tty
- PRINT ""
- aec=INT(cash/cells)
- PRINT "Attacking enemy with $"+STR$(aec)+"/cell..."
- eec=INT(ecash/ecells)
- 'SLEEP 1
- IF aec>eec THEN
- gr(tx,ty)=1
- ca$="You took enemy cell ("+STR$(tx-1)+","+STR$(ty-1)+")."
- COLOR 0,200,0
- a=tx
- b=ty
- GOSUB drawRect
- ecells=ecells-1
- cells=cells+1
- COLOR 75,75,75
- FOR i=(tx-1) TO (tx+1)
- FOR j=(ty-1) TO (ty+1)
- IF gr(i,j)=0 AND i>1 AND i<7 AND j>1 AND j<7 THEN
- gr(i,j)=3
- a=i
- b=j
- GOSUB drawRect
- ENDIF
- NEXT
- NEXT
- ENDIF
- IF eec>aec THEN
- cash=cash-aec
- ca$="You failed to attack the enemy."
- ENDIF
- IF eec=aec THEN
- cash=cash-aec
- ecash=ecash-eec
- ca$="You tied with the enemy while atacking."
- ENDIF
- GOSUB updateConsole
- GOSUB updateHUD
- GOSUB checkBankrupt
- RETURN
- checkBankrupt:
- IF cash<1 THEN
- ca$="YOU HAVE GONE BANKRUPT."
- cb$="You are not the Gridmaster."
- GOSUB updateConsole
- CLS tty
- PRINT ""
- PAUSE "Tap to restart."
- CLS
- GOTO abcd
- ENDIF
- RETURN
- enemyAI:
- IF enemyDef=0 THEN
- rndatkx=INT(1+(RND*5))+1
- rndatky=INT(1+(RND*5))+1
- IF rndatkx<2 OR rndatkx>6 OR rndatky<2 OR rndatky>6 THEN
- GOTO enemyAI
- ENDIF
- IF gr(rndatkx,rndatky)=2 THEN
- GOTO enemyAI
- ENDIF
- nxttru=0
- FOR i=(rndatkx-1) TO (rndatkx+1)
- FOR j=(rndatky-1) TO (rndatky+1)
- IF gr(i,j)=2 THEN
- nxttru=1
- ENDIF
- NEXT
- NEXT
- IF nxttru=0 THEN
- GOTO enemyAI
- ENDIF
- IF gr(rndatkx,rndatky)=0 OR gr(rndatkx,rndatky)=3 THEN
- IF maximumprice<ecash THEN
- atcsh=INT(1+(RND*maximumprice))
- ELSE
- atcsh=INT(1+(RND*ecash))
- IF atcsh>ecash THEN
- atcsh=ecash
- ENDIF
- ENDIF
- ecash=ecash-atcsh
- IF atcsh>gr2(rndatkx,rndatky) THEN
- gr(rndatkx,rndatky)=2
- ecash=ecash+gr2(rndatkx,rndatky)
- IF (maximumprice-atcsh)>0 THEN
- ecash=ecash+(maximumprice-atcsh)
- ENDIF
- cb$="Enemy has taken ("+STR$(rndatkx-1)+","+STR$(rndatky-1)+")."
- GOSUB updateConsole
- COLOR 200,0,0
- a=rndatkx
- b=rndatky
- GOSUB drawRect
- ecells=ecells+1
- ELSE
- cb$="Enemy fails their attack."
- GOSUB updateConsole
- ENDIF
- ENDIF
- IF gr(rndatkx,rndatky)=1 THEN
- eec=INT(ecash/ecells)
- aec=INT(cash/cells)
- IF eec>aec THEN
- cb$="Enemy takes your cell at ("+STR$(rndatkx-1)+","+STR$(rndatky-1)+")."
- COLOR 200,0,0
- cells=cells-1
- a=rndatkx
- b=rndatky
- gr(rndatkx,rndatky)=2
- GOSUB drawRect
- GOSUB updateConsole
- ENDIF
- IF eec<aec THEN
- cb$="Enemy failed an attack against you."
- GOSUB updateConsole
- ecash=ecash-eec
- ENDIF
- IF eec=aec THEN
- cash=cash-aec
- ecash=ecash-eec
- cb$="Enemy tied in an attack against you."
- GOSUB updateConsole
- ENDIF
- ENDIF
- IF ecash<1 THEN
- cb$="Enemy went bankrupt!"
- GOSUB updateConsole
- ENDIF
- ENDIF
- RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement