Advertisement
Mysoft

Mysoft FlappyFB 1.0

Jan 19th, 2015
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define fbc -s gui -gen gcc -O 3
  2.  
  3. #include "crt.bi"
  4. #include "fbgfx.bi"
  5.  
  6. const PI = atn(1)/45,PI128 = (atn(1)*4)/128
  7. const ftBig = 0,ftSmall = 256,ftCenter = 512
  8.  
  9. enum ColorConstants
  10.   cTrans   =  0
  11.   cReady  : cReady2 : cOver   : cOver2   : cWall    : cWall2  : cWall3  : cWall4
  12.   cWall5  : cWall6  : cWall7  : cWall8   : cFrame1  : cFrame2 : cFrame3 : cText
  13.   cText2  : cBorder : cBlack  : cGray    : cWhite   : cRed
  14.   cMedal0 : cMedal1 : cMedal2 : cMedal3
  15.   cBirdA  : cBirdA1 : cBirdA2 : cBirdA3  : cBirdA4  : cBirdA5
  16.   cBirdB  : cBirdB1 : cBirdB2 : cBirdB3  : cBirdB4  : cBirdB5 : cBirdB6
  17.   cPipeA  : cPipeZ = cPipeA+47 ' ------------------------------------------------
  18.   cSky    : cStars  : cClouds : cShadow1 : cShadow2 : cBuild1 : cBuild2 : cBuild3
  19.   cLight1 : cLight2 : cGrass1 : cGrass2  
  20.   CLast   : cOpaque  = 255
  21. end enum
  22. enum ActionConstants
  23.   _NEXT   = -1  'advance to next Char (special meaning)  
  24.   _ROUND  = -1  'Draw a filled Circle X,Y,RADIUS,COLOR  
  25.   _ROUNDX = -2  'Draw a filled Circle X,Y,RADIUS,COLOR  
  26.   _LINE   = -3  'Draws a horz filed line X,Y,XX,YY,COLOR
  27.   _BOX    = -4  'Draw a filled box X,Y,XX,YY (exclusive)
  28.   _ARC    = -5  'Draws an outlined partial circle X,Y,RADIUS,COLOR,START,END,RATIO?
  29.   _AREA   = -6  'offsets to a clipping area X,Y,WID,HEI  
  30.   _NOAREA = -7  'remove previous set clipping            
  31.   _OFFSET = -8  'offsets to a point X,Y (or ID,Skips)    
  32.   _BORDER = -9  'Borderize area with COLOR              
  33.   _SHADOW = -10 'Cast Shadow on text COLOR,BACKGROUND    
  34.   _LINE2  = -11 'Draws a horz filed line X,Y,XX,YY,COLOR
  35.   _PAINT  = -12 'Paint area at X,Y,COLOR,BORDER          
  36.   _FINISH = -7  'Done Drawing... same as _NOAREA_ last!  
  37. end enum
  38. enum Graphics  
  39.   #define _gClouds_    pGfx,(v(  0),v( 28))-(v( 64)-1,v( 46)-1)
  40.   #define _gGetReady_  pGfx,(v(  0),v( 64))-(v( 92)-1,v( 88)-1)
  41.   #define _gGameOver_  pGfx,(v(  0),v( 88))-(v( 96)-1,v(109)-1)
  42.   #define _gShadows_   pGfx,(v( 64),v( 28))-(v( 96)-1,v( 46)-1)
  43.   #define _gBuildings_ pGfx,(v( 96),v( 28))-(v(128)-1,v( 46)-1)
  44.   #define _gBushes_    pGfx,(v(  0),v( 46))-(v( 64)-1,v( 64)-1)
  45.   #define _gWall_      pGfx,(v(116),v( 46))-(v(128)-1,v( 58)-1)
  46.   #define _gPipeDown_  pGfx,(v( 90),v( 46))-(v(116)-1,v( 58)-1)
  47.   #define _gPipeUp_    pGfx,(v( 64),v( 46))-(v( 90)-1,v( 58)-1)
  48.   #define _gPipeLine_  pGfx,(v( 80),v( 58))-(v(104)-1,v( 59)-1)
  49.   #define _gPipeBody_  pGfx,(v(104),v( 58))-(v(128)-1,v( 70)-1)
  50.   #define _gFrameLT_   pGfx,(v(104),v( 70))-(v(112)-1,v( 78)-1)
  51.   #define _gFrameU_    pGfx,(v(112),v( 70))-(v(120)-1,v( 78)-1)
  52.   #define _gFrameRT_   pGfx,(v(120),v( 70))-(v(128)-1,v( 78)-1)
  53.   #define _gFrameL_    pGfx,(v(104),v( 78))-(v(112)-1,v( 86)-1)
  54.   #define _gFrameR_    pGfx,(v(120),v( 78))-(v(128)-1,v( 86)-1)
  55.   #define _gFrameLD_   pGfx,(v(104),v( 86))-(v(112)-1,v( 94)-1)
  56.   #define _gFrameD_    pGfx,(v(112),v( 86))-(v(120)-1,v( 94)-1)
  57.   #define _gFrameRD_   pGfx,(v(120),v( 86))-(v(128)-1,v( 94)-1)
  58.   #define _gMedal_     pGfx,(v( 70),v( 18))-(v( 93)-1,v( 24)-1)
  59.   #define _gScore_     pGfx,(v( 94),v( 18))-(v(116)-1,v( 24)-1)
  60.   #define _gNew_       pGfx,(v(  0),v(109))-(v( 16)-1,v(116)-1)
  61.   #define _gBest_      pGfx,(v(  0),v(116))-(v( 17)-1,v(122)-1)
  62.   #define _gNoMedal_   pGfx,(v( 96),v( 94))-(v(118)-1,v(116)-1)
  63.   #define _gTapLeft_   pGfx,(v( 21),v(109))-(v( 42)-1,v(118)-1)
  64.   #define _gTapRight_  pGfx,(v( 17),v(109))-(v( 38)-1,v(118)-1)
  65.   #define _gKeys_      pGfx,(v( 42),v(109))-(v( 61)-1,v(128)-1)
  66.   #define _gSign_      pGfx,(v(  0),v(122))-(v(  9)-1,v(126)-1)
  67.   #define _gArrowUp_   pGfx,(v( 17),v(118))-(v( 25)-1,v(125)-1)
  68.   gDummy
  69. end enum
  70.  
  71. #define w(_NN_) (((_NN_)+iOffsetX)*iScale)
  72. #define h(_NN_) (((_NN_)+iOffsetY)*iScale)
  73. #define v(_NN_) (((_NN_))*iScale)
  74. #define DebugRender() if iDebug then put (v(4),v(2)),pGfx,pset: sleep 100,1
  75. #define DebugRenderTemp() if iDebug then put pGfx,(w(0),h(0)),pTemp,pset:put (v(4),v(2)),pGfx,pset: sleep 100,1
  76.  
  77. dim shared as integer iScale=0,iDay=0,iDebug=0,iTime,iFocus=1
  78. dim shared as fb.image ptr pGfx,pDither,pBirdA,pBirdB,pCollision
  79. dim shared as integer ScrW,ScrH,iHZ,iBest
  80. dim shared as integer AA=1,iFull=0,iDither=1,iSync=2,iShowCrash=0
  81. dim shared as integer iOffsetX,iOffsetY,iWid,iHei
  82. dim shared as integer iBirdX,iBirdY
  83.  
  84. function SetPalette(iDay as integer=-1,iMinuteOfDay as integer=0,iBird as integer=0) as integer
  85.   function = 0
  86.   ' Palette Constant
  87.   palette cTrans  ,255,  0,  0 : palette cBorder , 88, 56, 72  
  88.   palette cBlack  ,  8,  8,  8 : palette cWhite  ,248,248,248
  89.   palette cReady  , 80,208, 80 : palette cReady2 ,  0,152, 72
  90.   palette cOver   ,248,152, 88 : palette cOver2  ,224,104, 32
  91.   palette cWall   ,224,248,136 : palette cWall2  ,152,224, 96
  92.   palette cWall3  ,128,192, 56 : palette cWall4  ,120,184, 48
  93.   palette cWall5  ,136,216, 80 : palette cWall6  , 88,128, 40
  94.   palette cWall7  ,208,168, 80 : palette cWall8  ,216,216,144
  95.   palette cFrame1 ,240,232,160 : palette cFrame2 ,216,208,152
  96.   palette cFrame3 ,192,192,136 : palette cRed    ,240, 40,  8
  97.   palette cText   ,248,128, 96 : palette cText2  ,240,232,160
  98.   palette cGray   ,200,200,200
  99.  
  100.   select case (iBird and 255)
  101.   case 0 'Blue
  102.     palette cBirdA  , 64,152,192 : palette cBirdA1 , 80,184,232
  103.     palette cBirdA2 , 88,200,240 : palette cBirdA3 ,216, 96, 24
  104.     palette cBirdA4 ,200,216,192 : palette cBirdA5 ,240,240,240
  105.   case 1 'Orange
  106.     palette cBirdA  ,208,120, 48 : palette cBirdA1 ,240,168, 40
  107.     palette cBirdA2 ,240,200,128 : palette cBirdA3 ,240, 56, 24
  108.     palette cBirdA4 ,206,222,198 : palette cBirdA5 ,240,240,240  
  109.   case 2 'Red
  110.     palette cBirdA  ,206, 49, 16 : palette cBirdA1 ,247, 57, 24
  111.     palette cBirdA2 ,247,115, 33 : palette cBirdA3 ,247,173, 71
  112.     palette cBirdA4 ,206,222,198 : palette cBirdA5 ,240,240,240  
  113.   end select  
  114.   select case (iBird shr 8)
  115.   case 0 'No Medal
  116.     palette cBirdB  ,200,200,200 : palette cBirdB1 ,200,200,200
  117.     palette cBirdB2 ,240,240,240 : palette cBirdB3 ,200,200,200
  118.     palette cBirdB4 ,200,200,200 : palette cBirdB5 ,240,240,240
  119.     palette cBirdB6 , 88, 56, 72
  120.     palette cMedal0 ,208,200,144 : palette cMedal1 ,208,200,144
  121.     palette cMedal2 ,208,200,144 : palette cMedal3 ,208,200,144
  122.   case 1 'Bronze Medal
  123.     palette cBirdB  ,232,160, 72 : palette cBirdB1 ,240,176, 72
  124.     palette cBirdB2 ,248,216,112 : palette cBirdB3 ,240,176, 72
  125.     palette cBirdB4 ,232,160, 72 : palette cBirdB5 ,240,176, 72    
  126.     palette cBirdB6 ,216,144, 72
  127.     palette cMedal0 ,240,176, 72 : palette cMedal1 ,176,128, 56
  128.     palette cMedal2 ,232,160, 72 : palette cMedal3 ,248,216,112
  129.   case 2 'Silver Medal
  130.     palette cBirdB  ,200,192,192 : palette cBirdB1 ,232,224,224
  131.     palette cBirdB2 ,248,248,248 : palette cBirdB3 ,232,224,224
  132.     palette cBirdB4 ,200,192,192 : palette cBirdB5 ,232,224,224
  133.     palette cBirdB6 ,152,152,152
  134.     palette cMedal0 ,232,224,224 : palette cMedal1 ,128,128,128
  135.     palette cMedal2 ,200,192,192 : palette cMedal3 ,248,248,248
  136.   case 3 'Gold Medal
  137.     palette cBirdB  ,248,216,112 : palette cBirdB1 ,232,240,112
  138.     palette cBirdB2 ,248,248,248 : palette cBirdB3 ,232,240,112
  139.     palette cBirdB4 ,248,216,112 : palette cBirdB5 ,232,240,112
  140.     palette cBirdB6 ,224,192, 96
  141.     palette cMedal0 ,232,240,112 : palette cMedal1 ,184,160, 80
  142.     palette cMedal2 ,248,216,112 : palette cMedal3 ,248,248,248
  143.   case 4 'Platinum Medal
  144.     palette cBirdB  ,232,232,232 : palette cBirdB1 ,248,248,248
  145.     palette cBirdB2 ,248,248,248 : palette cBirdB3 ,248,248,248
  146.     palette cBirdB4 ,232,232,232 : palette cBirdB5 ,248,248,248
  147.     palette cBirdB6 ,208,200,200
  148.     palette cMedal0 ,248,248,248 : palette cMedal1 ,128,128,128
  149.     palette cMedal2 ,232,232,232 : palette cMedal3 ,248,248,248
  150.   end select
  151.  
  152.   for CNT as integer = 0 to 47
  153.     palette cPipeA+CNT,88+((224-88)/47)*CNT,128+((248-128)/47)*CNT,48+((144-48)/47)*CNT
  154.   next CNT
  155.   palette 255,32,64,128
  156.  
  157.   if iDay=-1 then
  158.     dim as integer IR,IG,IB,IM=abs((iMinuteOfDay mod 1440)-720)
  159.     iTime= IM
  160.     static as integer iDo
  161.     if iM<10 then
  162.       iDo = 1
  163.     elseif iM<20 then
  164.       if iDo then iDo=0: function = 1        
  165.     end if
  166.    
  167.     #macro SetPal(_ATT_,_DR,_DG,_DB,_NR,_NG,_NB)
  168.       IR = _DR+(((_NR-_DR)*IM)\720)
  169.       IG = _DG+(((_NG-_DG)*IM)\720)
  170.       IB = _DB+(((_NB-_DB)*IM)\720)
  171.       palette _ATT_,IR,IG,IB
  172.     #endmacro    
  173.     SetPal( cSky     , 90,220,230 ,   6, 96,108 )
  174.     var RR=0,GG=0,BB=0,R2=0,G2=0,B2=0
  175.     palette get cSky,RR,GG,BB
  176.     SetPal( cStars   , RR,GG,BB , 168,224,208 )    
  177.     if IM < 256 then
  178.       palette cStars,RR,GG,BB
  179.     else
  180.       palette get cStars,R2,G2,B2
  181.       SetPal( cStars   , RR,GG,BB , R2,G2,B2 )
  182.     end if
  183.     SetPal( cClouds  ,224,240,208 ,   6,132,144 )
  184.     SetPal( cShadow1 ,216,232,200 ,   6,108,120 )
  185.     SetPal( cShadow2 ,200,224,184 ,   6,108,110 )
  186.     SetPal( cBuild1  ,200,224,184 ,   6, 96,108 )
  187.     SetPal( cBuild2  ,168,216,184 ,   6, 96,108 )
  188.     SetPal( cBuild3  ,144,208,200 ,   6, 96,108 )
  189.     if IM > 330 then
  190.       'SetPal( cLight1  ,168,216,184 , 248,184,  8 )
  191.       palette cLight1 ,248,184,  8
  192.     else
  193.       SetPal( cLight1  ,168,216,184 ,   4, 64, 72 )      
  194.     end if
  195.     if IM > 270 then
  196.       'SetPal( cLight2  ,168,216,184 , 248,184, 68 )
  197.       palette cLight2 ,248,184,  8
  198.     else
  199.       SetPal( cLight2  ,168,216,184 ,   4, 64, 72 )      
  200.     end if
  201.     SetPal( cGrass1  , 96,192,120 ,   6,120,  6 )
  202.     SetPal( cGrass2  , 88,216,112 ,   6,132,  6 )    
  203.   else    
  204.     if iDay then
  205.       ' Palette Day
  206.       palette cSky    , 72,176,184 : palette cStars  , 72,176,184 : palette cClouds ,224,240,208
  207.       palette cShadow1,216,232,200 : palette cShadow2,208,232,192 : palette cBuild1 ,200,224,184
  208.       palette cBuild2 ,168,216,184 : palette cBuild3 ,144,208,200 : palette cLight1 ,168,216,184
  209.       palette cLight2 ,168,216,184 : palette cGrass1 , 96,192,120 : palette cGrass2 , 88,216,112
  210.     else  
  211.       ' Palette Night
  212.       palette cSky    ,  8,128,144 : palette cStars  ,168,224,208 : palette cClouds ,  8,176,192
  213.       palette cShadow1,  8,144,160 : palette cShadow2,  8,144,152 : palette cBuild1 ,  8,128,144
  214.       palette cBuild2 ,  8,128,144 : palette cBuild3 ,  8,128,144 : palette cLight1 ,248,184,  8
  215.       palette cLight2 ,248,184, 68 : palette cGrass1 ,  8,160,  8 : palette cGrass2 ,  8,176,  8
  216.     end if
  217.   end if
  218.  
  219.   if iDither then    
  220.     dim as integer R,G,B,R2,G2,B2,iV=iHei\40
  221.     if iV < 8 then iV=8 else if iV > 32 then iV = 32
  222.     for CNT as integer = cTrans+1 to cLast-1    
  223.       palette get CNT,R,G,B
  224.       R2=R+iV:G2=G+iV:B2=B+iV
  225.       R-=iV:G-=iV:B-=iV
  226.       if R2>255 then R2=255
  227.       if G2>255 then G2=255
  228.       if B2>255 then B2=255      
  229.       if R<0 then R=0
  230.       if G<0 then G=0
  231.       if B<0 then B=0
  232.       palette CNT,R,G,B
  233.       palette CNT or 128,R2,G2,B2
  234.     next CNT
  235.   end if  
  236.  
  237. end function
  238. sub DrawArc(pBuff as fb.image ptr,x0 as integer,y0 as integer,radius as integer,iColor as integer,fStartAng as single,fEndAng as single,iSz as integer=0)  
  239.     const sTemp = csng(16384/(atn(1)*8))
  240.     const iTabSize = 512 '~(Radius/1.4) usage
  241.     static as short iAtnTab(iTabSize),iInitTable  
  242.     if iInitTable=0 then
  243.       iInitTable = 1
  244.       for CNT as integer = 0 to iTabSize
  245.         iAtnTab(CNT) = atn(CNT/.iTabSize)*sTemp
  246.       next CNT
  247.     end if
  248.     dim as integer x=radius,y=0,radiusError=1-x
  249.     dim as integer iStartAng = (fStartAng*sTemp) and 16383
  250.     dim as integer iEndAng   = (fEndAng*sTemp) and 16383  
  251.     var iW = pBuff->Width, iH = pBuff->Height,iPitch = pBuff->Pitch  
  252.     var pBuffStart = cast(ubyte ptr,pBuff+1),iBuffSz=(iPitch*iH)  
  253.     var pMidPix = pBuffStart+(y0*iPitch)+(x0)
  254.     if iStartAng > iEndAng then iEndAng += 16384    
  255.     #macro SetOctant(_N,_ANGS,_ANGE,_ALGO)
  256.     if (iStartAng >= (_ANGS) and iEndAng <= (_ANGE)) orelse (iEndAng>= (_ANGS) and iStartAng <= (_ANGE)) then p##_N = _ALGO
  257.     if (iStartAng >= (_ANGS+16384) and iEndAng <= (_ANGE+16384)) orelse (iEndAng>= (_ANGS+16384) and iStartAng <= (_ANGE+16384)) then p##_N = _ALGO  
  258.     #endmacro
  259.     dim as ubyte ptr p0,p1,p2,p3,p4,p5,p6,p7
  260.     SetOctant(0,14336,16383,pMidPix+(y*iPitch)+x) 'x0 + x , y0 + y
  261.     SetOctant(1,12288,14335,pMidPix+(x*iPitch)+y) 'x0 + y , y0 + x
  262.     SetOctant(2,10240,12887,pMidPix+(x*iPitch)-y) 'x0 - y , y0 + x
  263.     SetOctant(3, 8192,10239,pMidPix+(y*iPitch)-x) 'x0 - x , y0 + y
  264.     SetOctant(4, 6144, 8191,pMidPix-(y*iPitch)-x) 'x0 - x , y0 - y
  265.     SetOctant(5, 4096, 6143,pMidPix-(x*iPitch)-y) 'x0 - y , y0 - x
  266.     SetOctant(6, 2048, 4095,pMidPix-(x*iPitch)+y) 'x0 + y , y0 - x
  267.     SetOctant(7,    0, 2047,pMidPix-(y*iPitch)+x) 'x0 + x , y0 - y
  268.     #macro DoDrawArc()
  269.       while x >= y    
  270.         var i7 = iAtnTab((y*iTabSize)\x)    
  271.         var i6=4095-i7,i5=i7+4096,i4=8192-i7,i3=i7+8192
  272.         var i2=12288-i7,i1=i7+12288,i0=16383-i7
  273.         if cuint(x0+x) < iW then : DrawPIxel(0) : DrawPIxel(7) : end if    
  274.         if cuint(x0+y) < iW then : DrawPIxel(1) : DrawPIxel(6) : end if    
  275.         if cuint(x0-x) < iW then : DrawPIxel(3) : DrawPIxel(4) : end if
  276.         if cuint(x0-y) < iW then : DrawPIxel(2) : DrawPIxel(5) : end if
  277.         y += 1: p0 += iPitch: p1 += 1: p2 -= 1: p3 += iPitch:
  278.         p4 -= iPitch: p5 -= 1: p6 += 1: p7 -= iPitch
  279.         if (radiusError<0) then    
  280.           radiusError += 2 * y + 1      
  281.         else
  282.           x -= 1: p0 -= 1: p1 -= iPitch: p2 -= iPitch: p3 += 1
  283.           p4 += 1: p5 += iPitch: p6 += iPitch: p7 -= 1
  284.           radiusError += 2 * (y - x + 1)      
  285.         end if    
  286.       wend  
  287.     #endmacro
  288.   if iSz=0 then
  289.     #macro DrawPixel(N)
  290.       if cuint(p##n-pBuffStart)<iBuffSz then
  291.         if i##N >= iStartAng and i##N <= iEndAng then *p##N = iColor
  292.         if i##N >= (iStartAng-16384) and i##N <= (iEndAng-16384) then *p##N = iColor
  293.       end if
  294.     #endmacro
  295.     DoDrawArc()
  296.   else
  297.     var iColor2 = iColor or (iColor shl 8)
  298.     #macro DrawPixel(N)
  299.       if cuint(p##n-pBuffStart)<iBuffSz then
  300.         if i##N >= iStartAng and i##N <= iEndAng then *cptr(ushort ptr,p##N) = iColor2
  301.         if i##N >= (iStartAng-16384) and i##N <= (iEndAng-16384) then *cptr(ushort ptr,p##N) = iColor2
  302.       end if
  303.     #endmacro
  304.     DoDrawArc()
  305.   end if
  306. end sub
  307. sub CreateGraphics()
  308.   var iOffsetX=0,iOffsetY=0
  309.   if pGfx then ImageDestroy(pGfx):pGfx=0
  310.   pGfx = ImageCreate(v(128),v(128))
  311.   const cBk=cBlack,cWt=cWhite,cTr=cTrans  
  312.   dim as integer iScaleB=(iScale+1)\2,iScaleC=iScaleB-1,iScaleD=(iScale\2)-1
  313.   dim as short iN1(...) = { _ ' >>> Level Numbers <<<
  314.     1,1,12,18,cBlack,0,0,11,17,cBlack,1,1,10,16,cWhite,5,5,6,12,cBlack,                  _NEXT, _  ' **** 0 ****
  315.     2,1, 8,18,cBlack,1,1, 7,17,cBlack,0,0, 7, 6,cBlack,1,1,6, 5,cWhite,2, 2, 6,16,cWhite,_NEXT, _  ' **** 1 ****
  316.     1,1,12,18,cBlack,0,0,11,17,cBlack,1,1,10,16,cWhite,0,5,6, 6,cBlack,5,11,10,12,cBlack,_NEXT, _  ' **** 2 ****
  317.     1,1,12,18,cBlack,0,0,11,17,cBlack,1,1,10,16,cWhite,0,5,6, 6,cBlack,0,11, 6,12,cBlack,_NEXT, _  ' **** 3 ****
  318.     6,1,12,18,cBk,0,0,11,14,cBk,1,1,10,16,cWt,1,13,6,17,cBk,1,15,5,17,cTr,5,1,6,9,cBk,   _NEXT, _  ' **** 4 ****
  319.     1,1,12,18,cBlack,0,0,11,17,cBlack,1,1,10,16,cWhite,5,5,10,6,cBlack,0,11, 6,12,cBlack,_NEXT, _  ' **** 5 ****
  320.     1,1,12,18,cBlack,0,0,11,17,cBlack,1,1,10,16,cWhite,5,5,10,6,cBlack,5,11, 6,12,cBlack,_NEXT, _  ' **** 6 ****
  321.     6,1,12,18,cBk,0,0,11,10,cBk,1,1,10,16,cWt,1, 9,6,17,cBk,1,11,5,17,cTr,5,5,6,9,cBk,   _NEXT, _  ' **** 7 ****
  322.     1,1,12,18,cBlack,0,0,11,17,cBlack,1,1,10,16,cWhite,5,5,6, 6,cBlack,5,11, 6,12,cBlack,_NEXT, _  ' **** 8 ****
  323.     1,1,12,18,cBlack,0,0,11,17,cBlack,1,1,10,16,cWhite,5,5,6, 6,cBlack,0,11, 6,12,cBlack    }      ' **** 9 ****
  324.   dim as short iN2(...) = { _ ' >>> Progress Status Numbers <<<
  325.     0,0,7,10,cBlack,1,1,6, 9,cWhite,3,3,4,7,cBlack,                _NEXT, _  ' **** 0 ****
  326.     0,0,5, 4,cBlack,1,4,5,10,cBlack,1,1,4,3,cWhite,2,3,4,9,cWhite, _NEXT, _  ' **** 1 ****
  327.     0,0,7,10,cBlack,1,1,6, 9,cWhite,1,3,4,4,cBlack,3,6,6,7,cBlack, _NEXT, _  ' **** 2 ****
  328.     0,0,7,10,cBlack,1,1,6, 9,cWhite,1,3,4,4,cBlack,1,6,4,7,cBlack, _NEXT, _  ' **** 3 ****
  329.     0,0,7, 7,cBk,3,7,7,10,cBk,1,1,6,6,cWt,4,6,6,9,cWt,3,1,4,4,cBk, _NEXT, _  ' **** 4 ****
  330.     0,0,7,10,cBlack,1,1,6, 9,cWhite,3,3,6,4,cBlack,1,6,4,7,cBlack, _NEXT, _  ' **** 5 ****
  331.     0,0,7,10,cBlack,1,1,6, 9,cWhite,3,3,6,4,cBlack,3,6,4,7,cBlack, _NEXT, _  ' **** 6 ****
  332.     0,0,7, 4,cBlack,3,3,7,10,cBlack,1,1,6,3,cWhite,4,3,6,9,cWhite, _NEXT, _  ' **** 7 ****
  333.     0,0,7,10,cBlack,1,1,6, 9,cWhite,3,3,4,4,cBlack,3,6,4,7,cBlack, _NEXT, _  ' **** 8 ****
  334.     0,0,7,10,cBlack,1,1,6, 9,cWhite,3,3,4,4,cBlack,1,6,4,7,cBlack    }       ' **** 9 ****
  335.   dim as short iGX(...) = { _ ' >>> Other Objects <<<
  336.     _AREA,0,28,64,18,_ROUND,10,13,11,cClouds,_ROUND,26,13,10,cClouds,           _ ' ***** Cloud *******
  337.       _ROUND,40,13,13,cClouds,_ROUND,58,15, 8,cClouds, _
  338.     _NOAREA,_OFFSET,64,28,_BOX,0,16,32,18,cShadow1,_ROUND,4,5,4,cShadow1,       _ ' ***** Shadows *****
  339.       _BOX,4,1,9,16,cShadow1,_BOX,0,5,4,16,cShadow1,_BOX,1,10,3,17,cShadow2,      _  
  340.       _BOX,3,5,8,17,cShadow2,_ROUND,5,6,3,cShadow2,_BOX,10,10,14,16,cShadow1,     _  
  341.       _BOX,11,11,13,18,cShadow2,_ROUND,15,15,2,cShadow1,_BOX,15,0,17,16,cShadow1, _  
  342.       _BOX,17,1,19,16,cShadow1,_ROUNDX,19,4,3,cShadow1,-1,0,_BOX,19,4,22,16,cShadow1,_  
  343.       _ROUND,18,5,2,cShadow2,_BOX,16,4,20,7,cShadow2,_BOX,18,8,22,11,cShadow2,    _
  344.       _BOX,16,12,20,16,cShadow2,_BOX,23,6,29,12,cShadow1,_BOX,26,3,29,6,cShadow1, _
  345.       _BOX,23,12,32,16,cShadow1,_BOX,24,8,27,12,cShadow2,_BOX,27,4,29,7,cShadow2, _
  346.       _BOX,26,13,31,17,cShadow2, _
  347.     _OFFSET,96,28,_BOX,0,9,27,18,cBuild1,_BOX,3,4,10,9,cBuild1,                 _ ' **** Buildings ****
  348.       _BOX, 0, 7, 3, 9,cBuild1,_BOX,11, 9,27, 6,cBuild1,_BOX,11, 4,23, 6,cBuild1, _
  349.       _BOX,11, 2,20, 4,cBuild1,_BOX,15, 0,20, 2,cBuild1,_BOX, 7, 8, 8,11,cBuild2, _
  350.       _BOX, 5,15, 8,16,cBuild2,_BOX, 8,10, 9,15,cBuild2,_BOX,10,10,11,15,cBuild2, _
  351.       _BOX,13,15,14,16,cBuild2,_BOX,15,15,16,16,cBuild2,_BOX,17,15,18,16,cBuild2, _
  352.       _BOX,20, 5,21,18,cBuild2,_BOX,22,15,23,17,cBuild2,_BOX,24,16,25,17,cBuild2, _
  353.       _BOX, 3, 4,10, 5,cBuild3,_BOX, 3, 5, 4, 7,cBuild3,_BOX, 9, 5,10,11,cBuild3, _
  354.       _BOX, 0, 7, 9, 8,cBuild3,_BOX, 0, 8, 1,18,cBuild3,_BOX, 6,11,11,12,cBuild3, _
  355.       _BOX, 6,12, 7,18,cBuild3,_BOX,11, 3,12,18,cBuild3,_BOX,11, 2,16, 3,cBuild3, _
  356.       _BOX,15, 1,16, 2,cBuild3,_BOX,15, 0,20, 1,cBuild3,_BOX,19, 1,20,18,cBuild3, _
  357.       _BOX,20, 4,23, 5,cBuild3,_BOX,22, 5,23, 6,cBuild3,_BOX,20, 6,27, 7,cBuild3, _
  358.       _BOX,26, 7,27,18,cBuild3,_BOX, 1, 9, 2,14,cLight1,_BOX, 3, 9, 4,14,cLight1, _
  359.       _BOX, 5, 9, 6,14,cLight1,_BOX, 1,11, 6,12,cBuild1,_BOX, 5, 6, 6, 7,cLight2, _
  360.       _BOX, 8, 5, 9, 7,cLight2,_BOX, 8, 8, 9,10,cLight2,_BOX, 8,11, 9,13,cLight2, _
  361.       _BOX,17,12,18,13,cLight2,_BOX,24,15,25,16,cLight2,_BOX,13, 4,14,15,cLight1, _
  362.       _BOX,15, 4,16,15,cLight1,_BOX,17, 4,18,15,cLight1,_BOX,13, 6,18, 7,cBuild1, _
  363.       _BOX,13, 9,18,11,cBuild1,_BOX,13,13,18,14,cBuild1,_BOX,22, 9,23,14,cLight1, _
  364.       _BOX,24, 9,25,14,cLight1,_BOX,22,11,25,12,cBuild1, _
  365.     _AREA,0,46,64,18,_ROUND,19,7,7,cGrass1,_ROUND,19,7,6,cGrass2,               _ ' ***** Bushes ******
  366.       _ROUND,12, 7,7,cGrass1,_ROUND,12, 7,6,cGrass2,_ROUND,38, 7,7,cGrass1,_ROUND,38, 7,6,cGrass2, _
  367.       _ROUND,60, 7,7,cGrass1,_ROUND,60, 7,6,cGrass2,_ROUND,53, 7,7,cGrass1,_ROUND,53, 7,6,cGrass2, _
  368.       _ROUND, 0, 8,7,cGrass1,_ROUND, 0, 8,6,cGrass2,_ROUND,27, 9,7,cGrass1,_ROUND,27, 9,6,cGrass2, _
  369.       _ROUND,47, 9,7,cGrass1,_ROUND,47, 9,6,cGrass2,_ROUND,63,10,7,cGrass1,_ROUND,63,10,6,cGrass2, _
  370.       _ROUND, 0,10,7,cGrass1,_ROUND, 0,10,6,cGrass2,_ROUND, 8, 9,7,cGrass1,_ROUND, 8, 9,6,cGrass2, _
  371.       _ROUND,20,12,7,cGrass1,_ROUND,20,12,6,cGrass2,_ROUND,38,12,7,cGrass1,_ROUND,38,12,6,cGrass2, _
  372.       _ROUND,58,12,7,cGrass1,_ROUND,58,12,6,cGrass2,_BOX,0,9,64,18,cGrass2, _
  373.     _AREA,0,64,96,24,_ROUND,4,4,2,cOpaque,_ROUNDX,4,16,2,cOpaque,0,-1,        _ ' **** [G]et Ready! ****
  374.       _BOX,6,5,11,15,cTrans,_BOX,4,2,11,5,cOpaque,_BOX,4,15,11,18,cOpaque,      _
  375.       _BOX,2,4,6,16,cOpaque,_BOX,7,8,11,15,cOpaque,                             _
  376.     _ROUND,16,8,4,cOpaque,_ROUNDX,17,8,4,cOpaque,-1,0,_BOX,12,8,17,16,cOpaque,_ ' **** G[e]t Ready! ****
  377.       _ROUNDX,14,16,2,cOpaque,0,-1,_BOX,14,16,17,18,cOpaque,                    _
  378.       _BOX,16,8,17,12,cTrans,_BOX,17,8,21,14,cOpaque,                           _
  379.     _BOX,24,2,28,16,cOpaque,_BOX,22,7,30,10,cOpaque,                          _ ' **** Ge[t] Ready! ****
  380.       _BOX,26,15,30,18,cOpaque,_ROUNDX,26,16,2,cOpaque,0,-1,                    _
  381.     _BOX,36,2,40,18,cOpaque,_BOX,41,4,45,18,cOpaque,_BOX,40,2,43,16,cOpaque,  _ ' **** Get [R]eady! ****
  382.       _ROUNDX,43,4,2,cOpaque,-1,0,_BOX,40,5,41,10,cTr,_ROUNDX,47,14,3,cTr,-1,0, _
  383.     _ROUND,50,8,4,cOpaque,_ROUNDX,51,8,4,cOpaque,-1,0,                        _ ' **** Get R[e]ady! ****
  384.       _BOX,46,8,51,16,cOpaque,_ROUNDX,48,16,2,cOpaque,0,-1,                     _    
  385.       _BOX,48,16,51,18,cOpaque,_BOX,50,8,51,12,cTrans,_BOX,51,8,55,14,cOpaque,  _    
  386.     _ROUND,60,10,4,cOpaque,_BOX,60,6,65,18,cOpaque,_BOX,58,14,65,18,cOpaque,  _ ' **** Get Re[a]dy! ****
  387.       _ROUNDX,58,16,2,cOpaque,0,-1,_BOX,56,9,59,16,cOpaque,_BOX,60,10,61,15,cTr,_
  388.     _ROUND,68,9,2,cOpaque,_ROUNDX,68,16,2,cOpaque,0,-1,                       _ ' **** Get Rea[d]y! ****
  389.       _BOX,68,7,75,18,cOpaque,_BOX,66,9,70,16,cOpaque,_BOX,71,2,75,7,           _
  390.       cOpaque,_BOX,71,2,75,7,cOpaque, _BOX,70,10,71,15,cTrans,                  _
  391.     _ROUNDX,78,13,2,cOpaque,0,-1,_ROUNDX,83,19,2,cOpaque,-1,-1,               _ ' **** Get Read[y]! ****
  392.       _BOX,76,5,85,13,cOpaque,_BOX,78,12,85,15,cOpaque,                         _
  393.       _BOX,81,15,85,19,cOpaque,_BOX,79,18,83,21,cOpaque,_BOX,80,5,81,12,cTrans, _
  394.     _BOX,86,2,90,12,cOpaque,_BOX,86,15,90,18,cOpaque,_BORDER,cReady,          _ ' **** Get Ready[!] ****
  395.     _AREA,0,88,96,24,_ROUND,4,4,2,cOpaque,_ROUNDX,4,16,2,cOpaque,0,-1,        _ ' #### [G]ame Over ####
  396.       _BOX,6,5,11,15,cTrans,_BOX,4,2,11,5,cOpaque,_BOX,4,15,11,18,cOpaque,      _
  397.       _BOX,2,4,6,16,cOpaque,_BOX,7,8,11,15,cOpaque,                             _
  398.     _ROUND,16,10,4,cOpaque,_BOX,16,6,21,18,cOpaque,_BOX,14,14,21,18,cOpaque,  _ ' #### G[a]me Over ####
  399.       _ROUNDX,14,16,2,cOpaque,0,-1,_BOX,12,9,15,16,cOpaque,_BOX,16,10,17,15,cTr,_
  400.     _ROUNDX,33,10,4,cOpaque,-1,0,_BOX,22,6,34,18,cOpaque,                     _ ' #### Ga[m]e Over ####
  401.       _BOX,34,9,37,18,cOpaque,_BOX,26,10,27,18,cTrans,_BOX,32,10,33,18,cTrans,  _
  402.     _ROUND,42,8,4,cOpaque,_ROUNDX,43,8,4,cOpaque,-1,0,                        _ ' #### Gam[e] Over ####
  403.       _BOX,38,8,43,16,cOpaque,_ROUNDX,40,16,2,cOpaque,0,-1,                     _    
  404.       _BOX,40,16,43,18,cOpaque,_BOX,42,8,43,12,cTrans,_BOX,43,8,47,14,cOpaque,  _
  405.     _ROUND,58,4,2,cOpaque,_ROUNDX,63,16,2,cOpaque,-1,-1,                      _ ' #### Game [O]ver ####
  406.       _ROUNDX,58,16,2,cOpaque,0,-1,_ROUNDX,63,4,2,cOpaque,-1,0,                 _
  407.       _BOX,58,2,63,18,cOpaque,_BOX,56,4,65,16,cOpaque,_BOX,60,5,61,15,cTrans,   _
  408.     _BOX,66,6,75,18,cOpaque,_ROUND,88,31,22,cTrans,_BOX,70,6,71,15,cTrans,    _ ' #### Game O[v]er ####
  409.     _ROUND,80,8,4,cOpaque,_ROUNDX,81,8,4,cOpaque,-1,0,                        _ ' #### Game Ov[e]r ####
  410.       _BOX,76,8,81,16,cOpaque,_ROUNDX,78,16,2,cOpaque,0,-1,                     _    
  411.       _BOX,78,16,81,18,cOpaque,_BOX,80,8,81,12,cTrans,_BOX,81,8,85,14,cOpaque,  _    
  412.     _ROUND,90,10,4,cOpaque,_BOX,90,9,95,18,cTrans,                            _ ' #### Game Ove[r] ####
  413.       _BOX,89,6,94,10,cOpaque,_BOX,86,10,90,18,cOpaque,_BORDER,cOver,           _
  414.     _OFFSET,64,46,_BOX,0,0,26,12,cBorder,_BOX,1,1,25,11,cWall6,               _ ' **** Pipe Down ****
  415.     _OFFSET,90,46,_BOX,0,0,26,12,cBorder,_BOX,1,1,25,11,cWall6,               _ ' ****  Pipe Up  ****
  416.     _OFFSET,80,58,_BOX,0,0,24,1,cBorder,_BOX,1,0,23,1,cWall6,                 _ ' **** Pipe Line ****
  417.     _OFFSET,104,58,_BOX,0,0,24,12,cBorder,_BOX,1,0,23,12,cWall6,              _ ' **** Pipe Body ****
  418.     _OFFSET,116,46,_BOX,0,0,12,1,cBorder,_BOX,0,1,12,2,cWall,                 _ ' **** Wall Main ****
  419.       _BOX,0,2,12,9,cWall2,_BOX,0,9,12,10,cWall6,                               _
  420.       _BOX,0,10,12,11,cWall7,_BOX,0,11,12,12,cWall8,                            _
  421.     _AREA,104,70,24,24,_ROUND,7,7,7,cBorder,_ROUNDX,17,7,7,cBorder,-1,0,      _ ' **** Dialog Frame ****
  422.       _ROUNDX,7,17,7,cBorder,0,-1,_ROUNDX,17,17,7,cBorder,-1,-1,                _
  423.       _ROUND,8,8,7,cFrame1,_ROUNDX,16,8,7,cFrame1,-1,0,_ROUNDX,8,16,7,cFrame3,0,-1, _
  424.       _ROUNDX,16,16,7,cFrame3,-1,-1,_ROUNDX,9,9,8,cFrame2,1,0,_ROUNDX,15,9,8,cFrame2,-2,0, _
  425.       _ROUNDX,9,15,8,cFrame2,0,-2,_ROUNDX,15,15,8,cFrame2,-2,-1,_BOX,7,0,17,24,cBorder, _
  426.       _BOX,0,7,24,17,cBorder,_BOX,7,1,17,2,cFrame1,_BOX,7,22,17,2,cFrame1, _    
  427.       _BOX,7,2,17,22,cFrame2,_BOX,1,7,23,17,cFrame2,_BOX,7,22,17,23,cFrame3, _
  428.       _ROUNDX,9,9,8,cFrame2,0,1,_ROUNDX,12,9,8,cFrame2,0,1,_ROUNDX,15,9,8,cFrame2,-1,1, _
  429.       _ROUNDX,9,15,8,cFrame2,0,-2,_ROUNDX,12,15,8,cFrame2,0,-2,_ROUNDX,15,15,8,cFrame2,-1,-2, _
  430.     _AREA,70,18,24,6,_BOX,0,0,1,5,cOpaque,_LINE,0,0,2,3,cOpaque,                         _ '[M]EDAL
  431.       _LINE,2,3,4,0,cOpaque,_BOX,4,0,5,5,cOpaque,                                          _
  432.     _BOX,6,0,7,5,cOpaque,_BOX,7,0,9,1,cOpaque,_BOX,7,2,9,3,cOpaque,_BOX,7,4,9,5,cOpaque, _ 'M[E]DAL
  433.     _ROUNDX,12,2,2,cOpaque,-1,0,_ROUNDX,12,3,2,cOpaque,-1,-1,_ROUNDX,12,2,1,cTrans,-1,0, _ 'ME[D]AL
  434.       _ROUNDX,12,3,1,cTrans,-1,-1,_BOX,13,2,14,3,cOpaque,_BOX,9,0,12,5,cTrans,             _
  435.       _BOX,10,0,11,5,cOpaque,_BOX,10,0,12,1,cOpaque,_BOX,10,4,12,5,cOpaque,                _    
  436.     _LINE,16,0,15,2,cOpaque,_LINE,17,0,18,2,cOpaque,_BOX,15,2,16,5,cOpaque,              _ 'MED[A]L
  437.       _BOX,16,0,18,1,cOpaque,_BOX,18,2,19,5,cOpaque,_BOX,15,3,19,4,cOpaque,              _
  438.     _BOX,20,0,21,5,cOpaque,_BOX,20,4,23,5,cOpaque,_SHADOW,cText,cFrame2,                 _ 'MEDA[L]
  439.     _AREA,94,18,22,6,_BOX,1,0,4,1,cOpaque,_LINE,0,1,1,0,cOpaque,                 _ '[S]CORE
  440.       _LINE,0,1,3,4,cOpaque,_BOX,0,4,3,5,cOpaque,_LINE,3,4,2,5,cOpaque,            _    
  441.     _ROUND,7,2,2,cOpaque,_ROUNDX,7,3,2,cOpaque,0,-1,_ROUND,7,2,1,cTrans,         _ 'S[C]ORE
  442.       _ROUNDX,7,3,1,cTrans,0,-1,_BOX,7,0,10,5,cTrans,_BOX,7,0,8,1,cOpaque,         _
  443.       _BOX,7,4,8,5,cOpaque,_ROUNDX,7,2,-1,cTrans,0,1,_ROUNDX,7,3,-1,cTrans,0,-2,   _
  444.     _ROUND,11,2,2,cOpaque,_ROUNDX,11,3,2,cOpaque,0,-1,                           _ 'SC[O]RE
  445.       _ROUND,11,2,1,cTrans,_ROUNDX,11,3,1,cTrans,0,-1,                             _
  446.       _ROUNDX,11,2,-1,cTrans,0,1,_ROUNDX,11,3,-1,cTrans,0,-2,                      _
  447.     _ROUND,16,2,2,cOpaque,_ROUND,16,2,1,cTrans,_BOX,14,5,18,6,cTrans,            _ 'SCO[R]E
  448.       _BOX,14,0,16,5,cTrans,_BOX,14,0,15,5,cOpaque,_BOX,14,0,17,1,cOpaque,       _
  449.       _BOX,14,3,17,4,cOpaque,_LINE,16,3,17,5,cOpaque,                            _
  450.     _BOX,19,0,20,5,cOpaque,_BOX,20,0,22,1,cOpaque,                               _ 'SCOR[E]
  451.       _BOX,20,2,22,3,cOpaque,_BOX,20,4,22,5,cOpaque,_SHADOW,cText,cFrame2,       _
  452.     _OFFSET,0,109,_BOX,0,0,16,7,cRed,_BOX,1,1,2,6,cWhite,_BOX,4,1,5,6,cWhite,    _ 'NEW
  453.       _LINE,1,1,4,5,cWhite,_BOX,6,1,9,6,cWhite,_BOX,7,2,9,3,cRed, _
  454.       _BOX,7,4,9,5,cRed,_BOX,10,1,11,6,cWhite,_BOX,14,1,15,6,cWhite, _
  455.       _LINE,12,2,10,6,cWhite,_LINE,12,2,14,6,cWhite, _
  456.     _AREA,0,116,17,6,_ROUNDX,2,1,2,cOpaque,-1,0,_ROUNDX,2,1,1,cTrans,-1,0,  _ '[B]EST
  457.       _ROUNDX,2,3,2,cOpaque,-1,0,_ROUNDX,2,3,1,cTrans,-1,0,                 _    
  458.       _BOX,0,0,3,6,cTrans,_BOX,0,0,1,5,cOpaque, _BOX,0,0,3,1,cOpaque,       _
  459.       _BOX,0,4,3,5,cOpaque,_BOX,0,2,3,3,cOpaque,                            _
  460.     _BOX,5,0,8,5,cOpaque,_BOX,6,1,8,2,cTrans,_BOX,6,3,8,4,cTrans,           _ 'B[E]ST
  461.     _BOX,10,0,13,1,cOpaque,_LINE,9,1,10,0,cOpaque,_LINE,9,1,12,4,cOpaque,   _ 'BE[S]T
  462.       _BOX,9,4,12,5,cOpaque,_LINE,12,4,11,5,cOpaque,                        _
  463.     _BOX,14,0,17,1,cOpaque,_BOX,15,1,16,5,cOpaque,_SHADOW,cText,cFrame2,    _ 'BES[T]
  464.     _OFFSET,96,94,_BOX,0,0,22,22,cFrame2,_ROUND,11,11,10,cFrame1,           _ 'Medal
  465.       _ROUND,11,10,10,cMedal1,_ROUND,11,10,9,cMedal0, _
  466.       _ARC,11,10,9,cMedal3,16,111,_ARC,11,10,9,cMedal2,144,239,  _
  467.     _AREA,17,109,25,9,_BOX,1,1,24,8,cRed,_BOX,0,4,25,5,cRed,             _ ' Tap's Frame
  468.       _BOX,4,0,21,9,cWhite,_BOX,5,1,20,8,cRed,_ROUNDX,0,0,3,cTrans,0,-1, _
  469.       _ROUNDX,0,9,3,cTrans,0,-1,_LINE,-1,5,4,0,cWhite,_LINE,-1,4,4,9,cWhite,   _
  470.       _ROUNDX,25,0,3,cTrans,-1,-1,_ROUNDX,25,9,3,cTrans,-1,-1,           _
  471.       _LINE,25,5,20,0,cWhite,_LINE,25,4,20,9,cWhite,                     _
  472.     _BOX,6,2,9,3,cWhite, _BOX,7,3,8,7,cWhite,                            _ '[T]AP
  473.     _LINE,11,2,10,4,cWhite,_LINE,12,2,13,4,cWhite,_BOX,10,4,11,7,cWhite, _ 'T[A]P
  474.       _BOX,11,2,13,3,cWhite,_BOX,13,4,14,7,cWhite,_BOX,10,5,14,6,cWhite, _
  475.     _ROUND,17,4,2,cWhite,_ROUND,17,4,1,cRed,_BOX,15,7,19,8,cRed,         _ 'TA[P]
  476.       _BOX,15,2,17,7,cRed,_BOX,15,2,16,7,cWhite,_BOX,16,6,18,7,cRed,     _
  477.       _BOX,15,2,18,3,cWhite,_BOX,15,5,18,6,cWhite,                       _
  478.     _NOAREA,_OFFSET,42,109,_BOX,6,0,13,19,cBlack,_BOX,0,6,19,13,cBlack,  _ 'Keys 19x919
  479.       _BOX,6,0,12,7,cGray,_BOX,0,6,7,12,cGray,_BOX,7,1,12,18,cBorder,    _
  480.       _BOX,1,7,18,12,cBorder,_BOX,9,2,10,5,cGray,_BOX,14,9,17,10,cGray,  _
  481.       _BOX,9,14,10,17,cGray, _BOX,2,9,5,10,cGray,                        _
  482.     _OFFSET,0,122,_LINE,1,3,0,2,cBorder,_BOX,4,0,5,2,cBorder,_LINE,7,3,8,2,cBorder, _ 'Indicator Sign
  483.     _AREA,17,118,8,7,_BOX,0,4,8,5,cBorder,_BOX,1,0,7,4,cWhite, _ 'Arrow UP
  484.       _ROUNDX,1,0,3,cTrans,-1,-1,_ROUNDX,7,0,3,cTrans,1,-1,    _
  485.       _LINE2,4,0,0,4,cBorder,_LINE2,4,0,8,4,cBorder,           _
  486.       _BOX,1,4,7,7,cBorder,_BOX,2,4,6,6,cWhite,                _
  487.     _
  488.     _FINISH }    
  489.    
  490.   rem ========================================================================================================
  491.    
  492.   scope ' ************ Numbers BIG ***************
  493.     iOffsetX = 0: iOffsetY = 0
  494.     for CNT as integer = 0 to ubound(iN1)-1 step 5
  495.       if iN1(CNT)=-1 then iOffsetX += 12: CNT += 1  
  496.       line pGfx,(w(iN1(CNT)),h(iN1(CNT+1)))-(w(iN1(CNT+2))-1,h(iN1(CNT+3))-1),iN1(CNT+4),bf  
  497.       DebugRender()
  498.     next CNT  
  499.   end scope  
  500.   scope ' *********** Numbers Small **************
  501.     iOffsetX = 0: iOffsetY = 18
  502.     for CNT as integer = 0 to ubound(iN2)-1 step 5
  503.       if iN2(CNT)=-1 then iOffsetX += 7: CNT += 1  
  504.       line pGfx,(w(iN2(CNT)),h(iN2(CNT+1)))-(w(iN2(CNT+2))-1,h(iN2(CNT+3))-1),iN2(CNT+4),bf  
  505.       DebugRender()
  506.     next CNT
  507.   end scope
  508.   scope ' ******* Generic other graphics *********
  509.     var iOffsetX = 0,iOffsetY = 0,CNT=0
  510.     var iAreaX=0,iAreaY=0,iAreaW=0,iAreaH=0
  511.     dim as fb.image ptr pArea=0,pTemp=pGfx
  512.     #define P(_N_) iGX(CNT+(_N_))
  513.     do
  514.       select case P(0)
  515.       case _ROUND  'Draw a filled Circle X,Y,RADIUS,COLOR    
  516.         if P(3)>=0 or iScale>1 then
  517.           circle pTemp,(w(P(1)),h(P(2))),abs(v(P(3))),P(4),,,,f
  518.         end if
  519.         CNT += 5
  520.       case _ROUNDX 'Draw a filled Circle X,Y,RADIUS,COLOR  
  521.         if P(3)>=0 or iScale>1 then
  522.           circle pTemp,(w(P(1))+P(5),h(P(2))+P(6)),abs(v(P(3))),P(4),,,,f
  523.         end if
  524.         CNT += 7
  525.       case _LINE   'Draws a horz filed line X,Y,XX,YY,COLOR
  526.         for X as integer = 0 to v(1)-1
  527.           line pTemp,(w(P(1))+X,h(P(2)))-(w(P(3))+X,h(P(4))-1),P(5)
  528.         next X
  529.         CNT += 6
  530.       case _LINE2  'Draws a horz filed line X,Y,XX,YY,COLOR
  531.         for Y as integer = 0 to v(1)-1
  532.           line pTemp,(w(P(1)),h(P(2))+Y)-(w(P(3)),h(P(4))+Y),P(5)
  533.         next Y
  534.         CNT += 6
  535.       case _BOX    'Draw a filled box X,Y,XX,YY (exclusive)
  536.         line pTemp,(w(P(1)),h(P(2)))-(w(P(3))-1,h(P(4))-1),P(5),bf
  537.         CNT += 6
  538.       case _ARC    'Draws an outlined partial circle X,Y,RADIUS,COLOR,START,END
  539.         P(5) and= 255: P(6) and= 255
  540.         var fAngS = csng(P(5)*PI128),fAngE = csng((P(6)+.5)*PI128)        
  541.         if iScale=1 then
  542.           #ifdef DrawArc
  543.             DrawArc(pTemp,w(P(1)),h(P(2)),abs(v(P(3))),P(4),fAngS,fAngE,0)
  544.           #else
  545.             circle pTemp,w(P(1)),h(P(2)),abs(v(P(3))),P(4),fAngS,fAngE,1
  546.           #endif
  547.         else        
  548.           for iSz as single = -iScaleB to -1 step 1
  549.             #ifdef DrawArc              
  550.               DrawArc(pTemp,w(P(1))-1,h(P(2)),abs(v(P(3)))+iSz,P(4),fAngS,fAngE,1)              
  551.             #else
  552.               circle pTemp,(w(P(1)),h(P(2))),abs(v(P(3)))+iSz,P(4),fAngS,fAngE,1
  553.               circle pTemp,(w(P(1))-1,h(P(2))),abs(v(P(3)))+iSz,P(4),fAngS,fAngE,1
  554.               circle pTemp,(w(P(1)),h(P(2))-1),abs(v(P(3)))+iSz,P(4),fAngS,fAngE,1
  555.             #endif          
  556.           next ISz          
  557.         end if
  558.         CNT += 7
  559.       case _AREA   'offsets to a clipping area X,Y,WID,HEI  
  560.         if pArea then
  561.           put pGfx,(iAreaX,iAreaY),pArea,pset
  562.           ImageDestroy(pArea):pArea=0
  563.         end if        
  564.         iAreaX = v(P(1)): iAreaY = v(P(2))
  565.         iAreaW = v(P(3)): iAreaH = v(P(4))
  566.         pArea = ImageCreate( iAreaW , iAreaH )
  567.         put pArea,(-iAreaX,-iAreaY),pGfx,pset
  568.         iOffsetX=0:iOffsetY=0:pTemp=pArea
  569.         CNT += 5: continue do
  570.       case _NOAREA 'remove previous set clipping            
  571.         if pArea then
  572.           put pGfx,(iAreaX,iAreaY),pArea,pset
  573.           ImageDestroy(pArea):pArea=0
  574.         end if
  575.         iOffsetX=0:iOffsetY=0:pTemp=pGfx:CNT += 1
  576.         if CNT > ubound(iGX) then exit do else continue do
  577.       case _OFFSET 'offsets to a point X,Y                  
  578.         iOffsetX=P(1):iOffsetY=P(2)
  579.         CNT += 3: continue do
  580.       case _BORDER 'Borderize aera with COLOR              
  581.         dim as fb.image ptr pBorder = ImageCreate(iAreaW,iAreaH,cBorder)        
  582.         put pBorder,(0,0),pTemp,and
  583.         for Z as integer = 0 to 1
  584.           if Z = 1 then line pBorder,(0,0)-(iAreaW,iAreaH),cWhite,bf:put pBorder,(0,0),pTemp,and
  585.           for iY as integer = -2+Z to 3-Z
  586.             for iX as integer = -2+Z to 2-Z
  587.               put pGfx,(iAreaX+v(iX),iAreaY+v(iY)),pBorder,trans
  588.               DebugRender()
  589.             next iX
  590.           next iY
  591.         next Z
  592.         line pBorder,(0,0)-(iAreaW,iAreaH),P(1)+1,bf:put pBorder,(0,0),pTemp,and
  593.         put pGfx,(iAreaX,iAreaY+v(1)),pBorder,trans
  594.         DebugRender()
  595.         line pBorder,(0,0)-(iAreaW,iAreaH),P(1),bf:put pBorder,(0,0),pTemp,and
  596.         put pGfx,(iAreaX,iAreaY),pBorder,trans
  597.         DebugRender()
  598.         ImageDestroy(pArea):pArea=0        
  599.         iOffsetX=0:iOffsetY=0:pTemp=pGfx:CNT += 2
  600.       case _SHADOW 'Cast Shadow on text COLOR,BACKGROUND    
  601.         dim as fb.image ptr pBorder = ImageCreate(iAreaW,iAreaH,P(1)+1)        
  602.         line pGfx,(iAreaX,iAreaY)-(iAreaX+iAreaW-1,iAreaY+iAreaH-1),P(2),bf
  603.         DebugRender()
  604.         put pBorder,(0,0),pTemp,and
  605.         put pGfx,(iAreaX,iAreaY+v(1)),pBorder,trans
  606.         DebugRender()
  607.         line pBorder,(0,0)-(iAreaW,iAreaH),P(1),bf:put pBorder,(0,0),pTemp,and
  608.         put pGfx,(iAreaX,iAreaY),pBorder,trans
  609.         DebugRender()
  610.         ImageDestroy(pArea):pArea=0        
  611.         iOffsetX=0:iOffsetY=0:pTemp=pGfx:CNT += 3
  612.       case else
  613.         #ifdef Messagebox
  614.         Messagebox(null,"Bad Parameters","Bad Paramaters",MB_SYSTEMMODAL or MB_ICONSTOP)
  615.         #endif
  616.         stop
  617.       end select      
  618.       if iDebug andalso pArea then put pGfx,(iAreaX,iAreaY),pArea,pset      
  619.       DebugRender()
  620.     loop
  621.   end scope
  622.   scope ' *********** Diagonal Lines *************
  623.     iOffsetX = 116: iOffsetY = 46
  624.     for CNT as integer = 0 to v(1)-1
  625.       line pGfx,(w(6)+CNT,h(2))-(w(0)+CNT,h(9)-1),cWall3
  626.       line pGfx,(w(12)+CNT,h(2))-(w(6)+CNT,h(9)-1),cWall5
  627.     next CNT
  628.     for CNT as integer = 0 to v(5)-1
  629.       line pGfx,(w(7)+CNT,h(2))-(w(1)+CNT,h(9)-1),cWall4
  630.     next CNT    
  631.   end scope
  632.   scope ' *************** Pipes ******************
  633.     iOffsetY=46
  634.     var fMul = (PI*90)/v(22),fMulB = (PI*90)/v(16)
  635.     for CNT as integer = 0 to v(22)-1
  636.       iOffsetX=64
  637.       line pGfx,(w(1)+CNT,h(2))-(w(1)+CNT,h(10)-1),cPipeZ-abs(cos(fMul*((v(24)-1)-CNT)))*47
  638.       line pGfx,(w(1)+CNT,h(1))-(w(1)+CNT,h(2)-1),cPipeA+abs(cos(fMul*((v(24)-1)-CNT)+PI*80))*34
  639.       iOffsetX=90
  640.       line pGfx,(w(1)+CNT,h(2))-(w(1)+CNT,h(10)-1),cPipeZ-abs(cos(fMul*((v(24)-1)-CNT)))*47
  641.       line pGfx,(w(1)+CNT,h(10))-(w(1)+CNT,h(11)-1),cPipeA+abs(cos(fMul*((v(24)-1)-CNT)+PI*80))*34
  642.     next CNT
  643.     iOffsetX=104:iOffsetY=58
  644.     for CNT as integer = 0 to v(22)-1
  645.       line pGfx,(w(1)+CNT,h(0))-(w(1)+CNT,h(12)-1),cPipeZ-abs(cos(fMulB*((v(24)-1)-CNT)))*47
  646.     next CNT      
  647.   end scope
  648. end sub
  649. sub DrawNumber(iNumber as integer,iX as integer,iY as integer,iFormat as integer=0)
  650.   var sText = iNumber & "",iSz=0,iBg=(iFormat and 255)
  651.   dim as integer iSA=any,iSB=any,iPY=any,iSY=any
  652.   if (iFormat and ftSmall) then
  653.     iSA=v(7):iSB=v(5):iPY=v(18):iSY=v(10)    
  654.   else
  655.     iSA=v(12):iSB=v(8):iPY=v(0):iSY=v(18)
  656.   end if
  657.   if (iFormat and ftCenter) then    
  658.     for CNT as integer = 0 to len(sText)-1
  659.       select case sText[CNT]
  660.       case asc("0"),asc("2") to asc("9"): iSz += iSA
  661.       case else: iSz += iSB
  662.       end select
  663.     next CNT
  664.     iX -= iSz\2
  665.   end if
  666.   for CNT as integer = 0 to len(sText)-1
  667.     select case sText[CNT]
  668.     case asc("0"),asc("2") to asc("9")
  669.       var iPX = (sText[CNT]-asc("0"))*iSA
  670.       if iBg then line(iX,iY)-(v(1)+iX+iSA-1,iY+iSY-1),iBg,bf
  671.       put(iX,iY),pGfx,(iPX,iPY)-(iPX+iSA-1,iPY+iSY-1),trans
  672.       iX += iSA+v(1): if iX > ScrW then exit sub
  673.     case asc("1")      
  674.       if iBg then line(iX,iY)-(v(1)+iX+iSA-1,iY+iSY-1),iBg,bf
  675.       put(iX,iY),pGfx,(iSA,iPY)-(iSA+iSB-1,iPY+iSY-1),trans
  676.       iX += iSB+v(1): if iX > ScrW then exit sub
  677.     case else
  678.       if iBg then line(iX,iY)-(v(1)+iX+iSA-1,iY+iSY-1),iBg,bf
  679.       iX += iSB+v(1)
  680.     end select
  681.   next CNT
  682. end sub
  683. sub DrawBird(iPX as integer,iPY as integer,iAngle as integer,iWing as integer,iColor as integer,pTarget as fb.image ptr=0)
  684.   static as integer iBird(...) = { _
  685.     _ROUND,11,3,1,4,_ROUND,9,8,5,3,_ROUND,8,35,25,2,_ROUND,15,5,3,7,           _ 'Bird Main
  686.       _ARC,10,5,8,1,145,204,_ARC,11,10,8,1,50,123,_ARC,12,7,5,1,246,63,        _
  687.       _ARC,11,10,7,4,61,104,_ARC,18,9,1,1,173,24,_ROUND,14,10,1,5,             _
  688.       _ROUND,15,10,1,5,_ROUND,16,10,1,5,_ROUND,17,10,1,5,_ARC,18,10,1,5,14,82, _
  689.       _ARC,14,5,3,1,75,207,_ARC,17,30,22,1,66,72,_ARC,14,30,22,1,53,64,        _
  690.       _ARC,15,5,7,1,171,204,_ARC,17,-12,22,1,182,191,_ARC,16,3,7,1,194,214,    _
  691.       _ARC,14,-12,22,1,194,203,_ARC,14,11,3,1,74,119,_ARC,14,9,3,1,144,189,    _
  692.       _ARC,16,10,2,1,177,9,_ARC,13,10,1,5,39,216,_ARC,15,5,3,6,122,161,        _
  693.       _ARC,14,5,3,1,75,207,_ARC,12,6,3,1,250,22,_ARC,11,11,2,1,183,238,        _
  694.       _PAINT,15,14,0,1,_PAINT,4,12,0,1,_ROUND,-1,8,3,0,                        _
  695.     _OFFSET,0,41,_ROUNDX,6,7,2,7,_ARC,6,6,3,4,151,238,_ARC,6,7,3,1,177,255,    _ 'Bird Wing 0
  696.       _ARC,6,8,3,1,11,76,_ARC,6,7,3,1,116,191,_ARC,5,7,2,1,61,145,_FINISH,     _
  697.     _OFFSET,1,72,_ROUND,5,8,1,7,_ROUNDX,7,8,1,7,_ROUND,6,9,1,7,                _ 'Bird Wing 1
  698.       _ARC,6,7,3,4,146,176,_ARC,6,7,3,4,210,240,_ARC,7,7,3,1,184,237,          _
  699.       _ARC,7,10,3,1,20,73,_ARC,5,10,3,1,56,109,_ARC,5,7,3,1,145,198,           _
  700.       _ARC,6,7,3,1,180,203,_ARC,6,10,3,1,52,75,_FINISH,                        _
  701.     _OFFSET,2,65,_ROUNDX,5,10,2,7,_ROUNDX,6,9,1,7,_ROUNDX,7,10,1,7,            _ 'Bird Wing 2
  702.       _ARC,6,12,4,4,29,48,_ARC,2,8,2,4,213,252,_ARC,7,13,2,4,59,98,            _
  703.       _ARC,7,11,3,1,30,69,_ARC,6,10,3,1,91,160,_ARC,6,19,11,1,56,72,           _
  704.       _ARC,4,6,6,1,190,237,_FINISH }
  705.   rem ---------------------------------------------------------------------------
  706.   static as integer iInit,iPivX,iPivY,iScaleB,iScaleC,iScaleD
  707.   static as integer iOldAngA=-2^29,iOldAngB=-2^29,iOldWingA=-1,iOldWingB=-1
  708.   static as integer ptr piLastAng,piLastWing
  709.   static as fb.image ptr pBird
  710.   const fpBits=16,fpMul=1 shl fpBits,PImul=csng((atn(1)*4)/(256\2))
  711.   #define fBird(_N) *cptr(single ptr,@iBird(_N))
  712.   '#define UseFloats
  713.   'Initialize and convert array x,y to ang,dist
  714.   if iInit=0 then
  715.     iInit = 1: iScaleB = (iScale+1)\2:iScaleC=iScaleB-1:iScaleD=(iScale\2)-1
  716.     iPivX = 7*iScale+iScaleB: iPivY = (8+2)*iScale+iScaleB    
  717.     for CNT as integer = 0 to ubound(iBird)      
  718.       if iBird(CNT) = _OFFSET then CNT += 2: continue for
  719.       if iBird(CNT) = _FINISH then continue for
  720.       var iX = cint(iBird(CNT+1)*iScale)+iScaleB
  721.       var iY = cint((iBird(CNT+2)+2)*iScale)+iScaleB
  722.       #ifdef UseFloats
  723.         fBird(CNT+1) = atan2(iY-iPivY,iX-iPivX)
  724.         fBird(CNT+2) = sqr(((iY-ipivY)*(iY-iPivY))+((iX-iPivX)*(iX-iPivX)))
  725.       #else
  726.         iBird(CNT+1) = cint(atan2(iY-iPivY,iX-iPivX)/PImul)
  727.         iBird(CNT+2) = cint(sqr(((iY-ipivY)*(iY-iPivY))+((iX-iPivX)*(iX-iPivX)))*fpMul)
  728.       #endif
  729.       select case iBird(CNT)
  730.       case _ROUND : iBird(CNT+3) = (iBird(CNT+3)*iScale)+iScaleD+1:CNT += 4
  731.       case _ROUNDX: iBird(CNT+3) = (iBird(CNT+3)*iScale):CNT += 4
  732.       case _ARC   : iBird(CNT+3) *= iScale:CNT += 6
  733.       case _PAINT : CNT += 4      
  734.       case else
  735.         #ifdef Messagebox
  736.         Messagebox(null,"Bad Parameters2 " & iBird(CNT),"Bad Paramaters2",MB_SYSTEMMODAL or MB_ICONSTOP)
  737.         end
  738.         #endif
  739.       end select
  740.     next CNT
  741.   end if  
  742.   if iColor = cBirdA then
  743.     PiLastAng=@iOldAngB:PiLastWing=@iOldWingA:pBird=pBirdA
  744.   else
  745.     PiLastAng=@iOldAngB:PiLastWing=@iOldWingB:pBird=pBirdB
  746.   end if
  747.   'Draw Bird in temporary buffer
  748.   if iAngle <> *piLastAng or iWing <> *piLastWing then
  749.     *piLastAng = iAngle: *piLastWIng = iWing
  750.     line pBird,(0,0)-(pBird->Width-1,pBird->Height-1),cTrans,bf
  751.     dim as integer iPal(...) = { cTrans,cBorder,iColor, _
  752.     iColor+1,iColor+2,iColor+3,iColor+4,iColor+5 }
  753.     if iColor=cBirdB then iPal(1) = iColor+6
  754.     for CNT as integer = 0 to ubound(iBird)
  755.       #ifdef UseFloats
  756.         var fTempAng = csng(fBird(CNT+1)+iAngle*PImul)
  757.         var iX = (iPivX+(cos(fTempAng)*fBird(CNT+2)))
  758.         var iY = (iPivY+(sin(fTempAng)*fBird(CNT+2)))
  759.       #else
  760.         var fTempAng = csng((iBird(CNT+1)+iAngle)*PImul)      
  761.         'var iX = iBird(CNT+1)*iScale+iScaleB, iY = iBird(CNT+2)*iScale+iScaleB
  762.         var iX = (iPivX+(cos(fTempAng)*iBird(CNT+2)) shr fpBits)
  763.         var iY = (iPivY+(sin(fTempAng)*iBird(CNT+2)) shr fpBits)
  764.       #endif
  765.       select case iBird(CNT)
  766.       case _ARC
  767.         iBird(CNT+5) and= 255: iBird(CNT+6) and= 255
  768.         var fAngS = csng(((iBird(CNT+5)-iAngle) and 255)*PImul)
  769.         var fAngE = csng((((iBird(CNT+6)-iAngle) and 255)+.5)*PImul)        
  770.         if iScale=1 then
  771.           #ifdef DrawArc
  772.             DrawArc(pBird,iX,iY,iBird(CNT+3),iPal(iBird(CNT+4)),fAngS,fAngE,0)
  773.           #else
  774.             circle pBird,(iX,iY),iBird(CNT+3),iPal(iBird(CNT+4)),fAngS,fAngE,1
  775.           #endif
  776.         else        
  777.           for iSz as single = -iScaleC to iScaleD step 1
  778.             #ifdef DrawArc              
  779.               DrawArc(pBird,iX,iY,iBird(CNT+3)+iSz,iPal(iBird(CNT+4)),fAngS,fAngE,1)              
  780.             #else
  781.               circle pBird,(iX,iY),iBird(CNT+3)+iSz,iPal(iBird(CNT+4)),fAngS,fAngE,1
  782.               circle pBird,(iX-1,iY),iBird(CNT+3)+iSz,iPal(iBird(CNT+4)),fAngS,fAngE,1
  783.               circle pBird,(iX,iY-1),iBird(CNT+3)+iSz,iPal(iBird(CNT+4)),fAngS,fAngE,1
  784.             #endif          
  785.           next ISz          
  786.         end if
  787.         CNT += 6
  788.       case _ROUND        
  789.         circle pBird,(iX,iY),iBird(CNT+3),iPal(iBird(CNT+4)),,,,f              
  790.         CNT += 4
  791.       case _ROUNDX        
  792.         circle pBird,(iX,iY),iBird(CNT+3)-1,iPal(iBird(CNT+4)),,,,f              
  793.         CNT += 4
  794.       case _PAINT
  795.         paint pBird,(iX,iY),iPal(iBird(CNT+3)),iPal(iBird(CNT+4))        
  796.         CNT += 4
  797.       case _OFFSET        
  798.         if iBird(CNT+1) <> iWing then CNT += iBird(CNT+2)
  799.         CNT += 2
  800.       case _FINISH
  801.         exit for
  802.       case else
  803.         #ifdef Messagebox
  804.         Messagebox(null,"Bad Parameters3","Bad Paramaters3",MB_SYSTEMMODAL or MB_ICONSTOP)
  805.         #endif
  806.       end select
  807.       'screenunlock      
  808.       'put (0,0),pBird,pset: sleep 500,1
  809.       'if multikey(1) then stop
  810.       'screenlock
  811.     next CNT    
  812.   end if  
  813.   'Put to target
  814.   if pBird = pBirdA then iBirdX = iPX-iPivX: iBirdY = iPY-iPivY
  815.   put pTarget,(iPX-iPivX,iPY-iPivY),pBird,trans
  816. end sub
  817. sub DrawMedal(iPX as integer,iPY as integer,iMedal as integer)
  818.   static as integer iInit=0,iLastMedal=-1
  819.   static as fb.image ptr pMedal,pTemp
  820.   if iInit=0 then
  821.     iInit = 1
  822.     pMedal = ImageCreate(v(22),v(22))
  823.     pTemp = ImageCreate(v(22),v(22))
  824.   end if  
  825.   if iLastMedal <> iMedal then
  826.     iLastMedal = iMedal
  827.     put pMedal,(v(0),v(0)),_gNoMedal_,pset
  828.     if iMedal then      
  829.       for iY as integer = -1 to 1 step 1
  830.         line pTemp,(v(0),v(0))-(v(22),v(22)),cTrans,bf
  831.         DrawBird(v(6)+iScale\2,v(10+iY)+iScale\2,0,1,cBirdB,pTemp)
  832.         var pPix = cast(ubyte ptr,pTemp+1),iColor=cMedal2+(abs(iY+1)\2)
  833.         for CNT as integer= 0 to (pTemp->Pitch*pTemp->Height)-1
  834.           if pPix[CNT] <> cTrans then pPix[CNT] = iColor
  835.         next CNT
  836.         put pMedal,(v(0),v(0)),pTemp,trans
  837.       next iY
  838.       DrawBird(v(6)+iScale\2,v(10)+iScale\2,0,1,cBirdB,pMedal)
  839.     end if
  840.   end if
  841.  
  842.   put (iPX,iPY),pMedal,pset
  843. end sub
  844. sub SaveConfig()
  845.   var f = freefile()
  846.   if open(exepath+"/FlappyFB.cfg" for binary access write as #f)=0 then
  847.     var iTempA = iBest xor &h12345678, iTempB = ((-(2^30))+iBest) xor &h87654321
  848.     put #f,,iTempA: put #f,,iTempB: put #f,,iFull: put #f,,iDither
  849.     put #f,,iSync: put #f,,iShowCrash: put #f,,iScale\AA
  850.     close #f
  851.   end if
  852. end sub
  853. sub LoadConfig()
  854.   var f = freefile()
  855.   if open(exepath+"/FlappyFB.cfg" for binary access read as #f)=0 then
  856.     var iTempA=0,iTempB=0
  857.     get #f,,iTempA: get #f,,iTempB
  858.     iTempA xor= &h12345678: iTempB = (iTempB xor &h87654321)+(2^30)
  859.     if iTempA <> iTempB then close #f: exit sub
  860.     iBest = iTempA: get #f,,iFull: get #f,,iDither
  861.     get #f,,iSync: get #f,,iShowCrash: get #f,,iScale
  862.     if iScale < 0 or iScale > 16 then iScale = 0    
  863.     close #f
  864.   end if
  865. end sub
  866.  
  867. randomize()
  868. LoadConfig()
  869.  
  870. #ifdef __FB_DOS__
  871.   ScrW=640:ScrH=480:iHz=60
  872. #else
  873.   screeninfo ScrW,ScrH,,,,iHZ
  874.   ScrH -= 24: if iHZ < 50 then iHZ = 60  
  875. #endif
  876. iHZ *= 2
  877.  
  878. ' *** Create Graphic Screen ***
  879. if iScale=0 then iScale = (ScrH*AA\240) else iScale *= AA
  880. iWid = v(160): iHei = v(240)
  881. ScrW *= AA: ScrH *= AA  
  882. iOffsetX=iif(iFull,((ScrW-iWid)\2)\iScale,0)
  883. iOffsetY=iif(iFull,((ScrH-iHei)\2)\iScale,0)
  884. if iFull then
  885.   screenres ScrW,ScrH,8,,fb.gfx_HIGH_PRIORITY or _
  886.   fb.gfx_NO_FRAME or fb.GFX_ALWAYS_ON_TOP or fb.GFX_NO_SWITCH
  887. else
  888.   screenres iWid,iHei,8,,fb.gfx_HIGH_PRIORITY or fb.GFX_NO_SWITCH
  889. end if
  890. WindowTitle "FlappyFB v1.0 by Mysoft"
  891. if iFull then
  892.   setmouse ,,0
  893.   line(0,0)-(ScrW,ScrH),cBlack,bf
  894.   line(w(0)-1,h(0)-1)-(w(0)+iWid,h(0)+iHei),cWhite,b
  895.   view screen (w(0),h(0))-(w(0)+iWid-1,h(0)+iHei-1)
  896. end if
  897. ' *** Create Initial Graphics ***
  898. pBirdA = ImageCreate(24*iScale,24*iScale)
  899. pBirdB = ImageCreate(24*iScale,24*iScale)
  900. pCollision = ImageCreate(24*iScale,24*iScale)
  901. SetPalette(0) 'Night
  902. CreateGraphics()
  903.  
  904. ' *** Prepare screen and dither effect buffer ***
  905. line(w(0),h(204))-(w(160)-1,h(240)-1),cWall8,bf
  906. if iDither then
  907.   pDither = ImageCreate(v(160),v(240),0)
  908.   if AA=1 then
  909.     for Y as integer = 0 to v(240)-1 step 2
  910.       line pDither,(0,Y)-(v(160)-1,Y),128,,&h5555
  911.       line pDither,(0,Y+1)-(v(160)-1,Y+1),128,,&hAAAA
  912.     next Y
  913.   else
  914.     for Y as integer = 0 to v(240)-1 step 4
  915.       line pDither,(0,Y)-(v(160)-1,Y),128,,&hCCCC
  916.       line pDither,(0,Y+1)-(v(160)-1,Y+1),128,,&hCCCC
  917.       line pDither,(0,Y+2)-(v(160)-1,Y+2),128,,&h3333
  918.       line pDither,(0,Y+3)-(v(160)-1,Y+3),128,,&h3333
  919.     next Y
  920.   end if
  921. end if
  922.  
  923. ' *** Initial game variables ***
  924. var dStart = timer,iFps=0,dFps=dStart,dTimer=dStart
  925. var dDay=dStart-rnd*256,dPause=dStart
  926. var iRandom=0,dPipe=dStart,dBird=dStart,iPipePosi=-v(73*3),iPipe=-1
  927. var iIsReady=0,iIsOver=0,iScore=0,iIsBest=0,iIsCrash=0,iLastFps=iHz/2
  928. var iPosiS=0,iPosiB=0,iPosiG=0,iPosiW=0,iBirdColor=int(rnd*3)
  929. dim fBirdY as single,fBirdAng as single,iBirdUp as integer
  930. dim as integer iScoreY(3),iPipeY(3) = {72,110,45,90}
  931. dim as integer iStarX(19),iStarY(19),iStarSz(19)
  932.  
  933.  
  934. ' ***********************************************************************************
  935. ' ******************************* Main Game Loop ************************************
  936. ' ***********************************************************************************
  937.  
  938. do  
  939.   if iSync=1 then dTimer += 1/iLastFps else dTimer = timer
  940.   var dTmr = (timer-dStart) 'dTmr += (1/240)    
  941.   ' *** Pipes movement calculation ***
  942.   if abs(dTmr-dPipe) > 1 then
  943.     dPipe = dTmr
  944.   else
  945.     while (dTmr-dPipe) > (1/v(60))
  946.       dPipe += (1/v(60))
  947.       if iIsReady xor iIsOver then
  948.         iPipePosi = iPipePosi+1          
  949.         if iPipePosi >= v(73) then '73
  950.           iPipePosi -= v(73)
  951.           iPipe = (iPipe+1) and 3
  952.           iPipeY((iPipe+3) and 3) = 40+rnd*60
  953.           iScoreY((iPipe+3) and 3)=0
  954.         end if        
  955.       end if
  956.     wend
  957.   end if
  958.   ' *** Bird Movement calculation
  959.   if iIsReady<>0 andalso (iIsOver=0 or iIsCrash<>0) then
  960.     while (dTmr-dBird) > (1/120)
  961.       dBird += (1/120)
  962.       if iBirdUp then
  963.         fBirdAng = ((-25+(fBirdAng*3))\4)-1
  964.         if fBirdAng <= -25 then fBirdAng=-25:iBirdUp=0
  965.       else
  966.         fBirdAng += .85      
  967.         if fBirdAng > 64 then fBirdAng = 64
  968.       end if
  969.       fBirdY += sin(PI128*fBirdAng)*v(2)
  970.       if fBirdY < h(-24) then fBirdY = h(-24)
  971.       if fBirdY > h(182) then
  972.         fBirdY = h(182)          
  973.         if iIsOver=0 or iIsCrash>60 then            
  974.           dPause=dTmr:iBirdUp=0:iIsCrash=60:iIsOver=1
  975.           if iScore > iBest then iBest = iScore:iIsBest=1
  976.           SaveConfig()
  977.         end if
  978.       end if
  979.       if iIsCrash then
  980.         iIsCrash -= 1:if iIsCrash=0 then iIsReady=1
  981.       end if
  982.     wend
  983.   end if
  984.  
  985.   screenlock  
  986.     ' *** Update Palette and Day/Night effects ***
  987.     var iMedal = iif(iScore>40,4,iScore\10)
  988.     if SetPalette(,(timer-dDay)*24,iBirdColor or (iMedal shl 8)) or iStarY(0)=0 then
  989.       for CNT as integer = 0 to 19
  990.         iStarX(CNT) = w(rnd*160):iStarY(CNT) = h(40+rnd*40):iStarSz(CNT) = v(rnd)
  991.       next CNT
  992.     end if    
  993.     ' *** Draw Sky ***
  994.     line(w(0),h(0))-(w(160)-1,h(160)-1),cSky,bf    
  995.     for CNT as integer = w(0) to w(160)-1 step v(64)
  996.       put (CNT,h(147)),_gClouds_,trans
  997.     next CNT
  998.     ' *** Draw Stars (night) ***
  999.     for CNT as integer = 0 to 19
  1000.       circle(iStarX(CNT),iStarY(CNT)),iStarSz(CNT),cStars,,,,f
  1001.     next CNT
  1002.     ' *** Draw far Building shadows ***
  1003.     line(w(0),h(162))-(w(160)-1,h(184)-1),cClouds,bf
  1004.     if iIsOver=0 then iPosiS = (dTmr*v(5)) mod v(32)
  1005.     for CNT as integer = w(0)-iPosiS to w(160)-1 step v(32)
  1006.       put (CNT,h(162)),_gShadows_,trans
  1007.     next CNT
  1008.     ' *** Draw buildings ***
  1009.     if iIsOver=0 then iPosiB = (dTmr*v(10)) mod v(34)
  1010.     for CNT as integer = w(0)-iPosiB to w(160)-1 step v(34)
  1011.       put (CNT,h(162)),_gBuildings_,trans
  1012.     next CNT
  1013.     ' *** Draw Bushes ***
  1014.     if iIsOver=0 then iPosiG = (dTmr*v(20)) mod v(64)
  1015.     for CNT as integer = w(0)-iPosiG to w(160)-1 step v(64)
  1016.       put (CNT,h(176)),_gBushes_,trans
  1017.     next CNT
  1018.     ' *** Draw Pipes ***
  1019.     for X as integer = 0 to 3            
  1020.       if (iPipe+X) >= 0 then
  1021.         var iY = iPipeY((iPipe+X) and 3)
  1022.         for Y as integer = h(0) to h(iY)-1 step v(12)
  1023.           put (w(X*73)-iPipePosi,Y),_gPipeBody_,pset
  1024.         next Y      
  1025.         put (w(X*73)-iPipePosi,h(iY)),_gPipeLine_,pset
  1026.         put (w(X*73-1)-iPipePosi,h(iY+1)),_gPipeUp_,pset
  1027.         put (w(X*73-1)-iPipePosi,h(iY+13+48)),_gPipeDown_,pset
  1028.         put (w(X*73)-iPipePosi,h(iY+25+48)),_gPipeLine_,pset
  1029.         for Y as integer = h(iY+50+24) to h(193)-1 step v(12)
  1030.           put (w(X*73)-iPipePosi,Y),_gPipeBody_,pset
  1031.         next Y
  1032.       end if
  1033.     next X
  1034.     ' *** Draw Get Ready Stage ***
  1035.     if iIsReady=0 then
  1036.       put(w(32),h(60)),_gGetReady_,trans
  1037.       put(w(52),h(130)),_gTapLeft_,trans
  1038.       line(w(68),h(131))-(w(69)-1,h(138)-1),cRed,bf
  1039.       put(w(88),h(130)),_gTapRight_,trans
  1040.       line(w(92),h(131))-(w(93)-1,h(138)-1),cRed,bf
  1041.       put(w(71),h(135)),_gKeys_,trans
  1042.       if ((dTmr*6) mod 3)<2 then put(w(76),h(128)),_gSign_,trans
  1043.       put(w(76)+(v(1)\2),h(116)),_gArrowUp_,trans      
  1044.       var iPosi = (dTmr*400) mod 360,iPosi2 = (dTmr*12) mod 4          
  1045.       DrawBird(w(48),v(117)+sin(iPosi*PI)*v(4),0,abs(-2+iPosi2),cBirdA) '(abs(iPosi-80)-40)
  1046.       DrawBird(w(76),v(102),0,1,cBirdB)
  1047.     elseif iIsOver=0 or IIsCrash<>0 then
  1048.       DrawNumber(iScore,w(80),h(22),ftBig+ftCenter)      
  1049.     end if
  1050.     ' *** Draw in Stage bird and check collision
  1051.     if iIsReady then
  1052.       var iPosi2 = (dTmr*12) mod 4,iAng = iif(fBirdAng<-18,-18,cint(fBirdAng))
  1053.       var iWing = iif(iIsOver,1,abs(-2+iPosi2))
  1054.       DrawBird(w(48),fBirdY,iAng,iWing,cBirdA) '(abs(iPosi-80)-40)
  1055.       if iIsOver=0 then 'Collision
  1056.         for X as integer = 0 to 3            
  1057.           if (iPipe+X) >= 0 then
  1058.             var iY = iPipeY((iPipe+X) and 3)
  1059.             var iX = (w(X*73)-iPipePosi)-iBirdX,iXX=iX+v(24)-1
  1060.             if iXX < v(-1) then 'totally passed a pipe
  1061.               if iScoreY((iPipe+X) and 3)=0 then
  1062.                 iScore += 1: iScoreY((iPipe+X) and 3) = 1
  1063.               end if
  1064.               continue for
  1065.             end if
  1066.             if iX < v(25) then 'possible collision
  1067.               if iBirdY < h(0) then iIsOver=1:iIsCrash=1000:dPause=dTmr: exit for
  1068.               memcpy(pCollision+1,pBirdA+1,pBirdA->Pitch*pBirdA->Height)
  1069.               line pCollision,(iX,h(0)-iBirdY)-(iXX,(h(iY)-1)-iBirdY),cTrans,bf
  1070.               line pCollision,(iX-v(1),h(iY)-iBirdY)-(iXX+(v(1)-1),(h(iY+13)-1)-iBirdY),cTrans,bf
  1071.               line pCollision,(iX-v(1),h(iY+61)-iBirdY)-(iXX+(v(1)-1),(h(iY+74)-1)-iBirdY),cTrans,bf
  1072.               line pCollision,(iX,h(iY+74)-iBirdY)-(iXX,(h(193)-1)-iBirdY),cTrans,bf
  1073.               'put (iBirdX,iBirdY),pCollision,pset
  1074.               if memcmp(pCollision+1,pBirdA+1,pBirdA->Pitch*pBirdA->Height) then
  1075.                 if iShowCrash then
  1076.                   put pCollision,(iBirdX,iBirdY),pBirdA,xor
  1077.                   put (iBirdX,iBirdY),pCollision,xor
  1078.                 end if
  1079.                 iIsOver=1:iIsCrash=1000:dPause=dTmr                
  1080.               end if              
  1081.               exit for
  1082.             end if
  1083.           end if
  1084.         next X                
  1085.       end if    
  1086.     end if
  1087.     ' *** Draw bottom wall ***
  1088.     if iIsOver=0 then iPosiW = (dTmr*v(60)) mod v(12)
  1089.     for CNT as integer = w(0)-iPosiW to w(160)-1 step v(12)
  1090.       put (CNT,h(193)),_gWall_,pset
  1091.     next CNT    
  1092.     ' *** Draw GameOver Stage with medal and score ***
  1093.     if iIsOver andalso iIsCrash=0 then
  1094.       put(w(32),h(48)),_gGameOver_,trans
  1095.       put (w(24),h(80)),_gFrameLT_,trans:put (w(128),h(80)),_gFrameRT_,trans
  1096.       put (w(24),h(128)),_gFrameLD_,trans:put (w(128),h(128)),_gFrameRD_,trans
  1097.       for X as integer = w(32) to w(120) step v(8)
  1098.         put (X,h(80)),_gFrameU_,pset: put (X,h(128)),_gFrameD_,pset
  1099.       next X
  1100.       for Y as integer = h(88) to h(120) step v(8)
  1101.         put (w(24),Y),_gFrameL_,pset
  1102.         put (w(128),Y),_gFrameR_,pset
  1103.       next Y
  1104.       line(w(32),h(88))-(w(128)-1,h(128)-1),cFrame2,bf
  1105.       put(w(37),h(88)),_gMedal_,pset
  1106.       put(w(104),h(88)),_gScore_,pset
  1107.       put(w(109),h(108)),_gBest_,pset
  1108.       DrawMedal(w(38),h(102),iMedal)      
  1109.       if iIsBest then put(w(92),h(107)),_gNew_,pset
  1110.       DrawNumber(iScore,w(116),h(96),ftSmall+ftCenter)
  1111.       DrawNumber(iBest,w(116),h(116),ftSmall+ftCenter)
  1112.     end if
  1113.     ' *** Draw and calc Fps ***
  1114.     if (timer-dFps) >= 1 then    
  1115.       line(w(0),h(204))-(w(160)-1,h(240)-1),cWall8,bf
  1116.       DrawNumber(iFps,w(1),h(229),cWall8 or ftSmall)
  1117.       iLastFps=iFps:iFps=-1:dFps=timer
  1118.     end if      
  1119.     iFps += 1    
  1120.     ' *** Apply dither Effect ***
  1121.     if iDither then
  1122.       put(w(0),h(0)),pDither,or
  1123.     end if
  1124.     ' *** Sync frame (pre-delay) ***
  1125.     if iFocus andalso iSync=1 or iSync=2 then screensync
  1126.    
  1127.   screenunlock
  1128.  
  1129.   ' *** Sync frame (pos-delay) ***
  1130.   select case iSync
  1131.   case 0
  1132.     static as double dSync
  1133.     if abs(timer-dSync) > .5 then
  1134.       dSync=timer
  1135.     else
  1136.       while (timer-dSync) < (1/iHz)        
  1137.         sleep 1,1
  1138.       wend
  1139.       dSync += 1/iHz
  1140.     end if
  1141.   case 2,3
  1142.     sleep 1,1
  1143.   end select
  1144.   if iFocus=0 then sleep 30,1
  1145.  
  1146.   if iShowCrash andalso iIsCrash=1000 then
  1147.     var dTemp = timer:sleep 100,1
  1148.     while len(inkey):wend:sleep 1000
  1149.     dStart += (timer-dTemp)
  1150.   end if
  1151.  
  1152.   ' *** Input Events ***
  1153.   do
  1154.     dim iPress as integer=0,InEvent as fb.event
  1155.     if screenevent( @InEvent )=0 then exit do
  1156.     select case InEvent.type    
  1157.     case fb.EVENT_KEY_PRESS
  1158.       dim as integer iKey = InEvent.ascii
  1159.       if iKey=0 then iKey = -InEvent.scancode    
  1160.       select case iKey
  1161.       case 27 'Escape
  1162.         if iIsReady andalso iIsOver=0 then        
  1163.           iIsOver=1:iIsCrash=1000:dPause=dTmr
  1164.         else
  1165.           exit do,do
  1166.         end if
  1167.       case -fb.SC_F1: iDither xor= 1
  1168.       case -fb.SC_F2
  1169.         iSync = (iSync+1) mod 5
  1170.         dPause = dtimer-dStart: dtimer = timer
  1171.         dStart = dtimer-dPause      
  1172.         iLastFps=iHz\2:iFps=0:dFps=timer      
  1173.         draw string (w(64),h(230)),"Vsync: " & iSync,cRed      
  1174.       case -asc("k"),-asc("a"),-fb.SC_F9 'Button
  1175.         exit do,do
  1176.       case -fb.SC_UP: iPress = 1        
  1177.       end select  
  1178.     case fb.EVENT_MOUSE_BUTTON_PRESS: iPress = 1            
  1179.     case fb.EVENT_WINDOW_CLOSE: exit do,do            
  1180.     case fb.EVENT_WINDOW_GOT_FOCUS: iFocus = 1
  1181.     case fb.EVENT_WINDOW_LOST_FOCUS: iFocus = 0
  1182.     end select
  1183.    
  1184.     if iPress then
  1185.       if iIsOver=0 and iIsReady=0 then
  1186.         iIsReady = 1: iIsOver = 0
  1187.         iScore = 0 : iIsBest = 0
  1188.         fBirdY = v(117):fBirdAng=0
  1189.         dBird = dTmr:iBirdUp=1
  1190.         for CNT as integer = 0 to 3
  1191.           iPipeY(CNT) = 30+rnd*70: iScoreY(CNT)=0
  1192.         next CNT
  1193.       elseif iIsOver=0 and iIsCrash=0 then
  1194.         iBirdUp = 1
  1195.       end if
  1196.       if iIsOver andalso iIsReady andalso iIsCrash=0 then
  1197.         iIsOver = 0: iIsReady = 0: iScore = 0
  1198.         dStart = dtimer-dPause: iBirdColor=int(rnd*3)
  1199.         iPipePosi=-v(73*3):iPipe=-1
  1200.       end if
  1201.     end if
  1202.    
  1203.   loop
  1204.  
  1205. loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement