Guest User

Untitled

a guest
Jul 20th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Framework BRL.GlMax2D
  2. Import BRL.StandardIO
  3. Import BRL.Random
  4. Global Board:Int[14,14]
  5. Board = New Int[14,14]
  6. ' draw lines
  7. Graphics 800,600
  8. HideMouse
  9. SetBlend alphablend
  10. Global cursorX,cursorY
  11.  
  12. Global Scores:Int[]
  13. Scores = New Int[2]
  14.  
  15. Global baseBoardX:Int = 72
  16. Global baseBoardY:Int = 72
  17. Global boardOriginX:Int = 72
  18. Global boardOriginY:Int = 72
  19.  
  20. Global Shake:Float
  21. Global Letters:TList = New TList
  22. Type TLetter
  23.     Field X:Int
  24.     Field Y:Int
  25.     Field sY:Float
  26.     Field sX:Int
  27.     Field Char:Int
  28.     Field word:String
  29.     Field scalex:Float
  30.     Field scaley:Float
  31. EndType
  32.  
  33. Function AnyWord:String()
  34.     Select Rand(0,10)
  35.         Case 0
  36.             Return "Nincopomp"
  37.         Case 1
  38.             Return "Homosexual"
  39.         Case 2
  40.             Return "Rectal prolapse"
  41.         Case 3
  42.             Return "Fecal mass"
  43.         Case 4
  44.             Return "Poo"
  45.         Case  5
  46.             Return "British Media"
  47.         Case 6
  48.             Return "George W Bush"
  49.         Case 7
  50.             Return "Barack Obama"
  51.         Case 8
  52.             Return "RAGING HOMOPHOBE"
  53.         Case 9
  54.             Return "RACIST"
  55.         Case 10
  56.             Return "THIEF"
  57.    
  58.     EndSelect
  59. EndFunction
  60. For Local I:Int = 0 To 200
  61.     Local L:TLetter
  62.     L = New TLetter
  63.     Letters.AddLast(L)
  64.     L.sY = 10
  65.     L.Word = AnyWord()
  66. Next
  67. Function DrawBackground()
  68.     SetAlpha 1
  69.     SetRotation 0
  70.     For Local L:TLetter = EachIn Letters
  71.         L.sY :+ 0.2
  72.         L.Y:+L.sY
  73.         L.X:+L.sX
  74.         If Rand(0,10)=2 Then
  75.             L.Char:+1
  76.         EndIf
  77.         If Rand(0,5)=1 Then SetColor Rand(0,1)*255,Rand(0,1)*255,Rand(0,1)*255
  78.         SetScale l.scalex,l.scaley
  79.         DrawText L.Word,L.X,L.Y
  80.         If L.Y > 600 Or ( L.X < 0) Or (L.X > 800) And (Rand(0,100)=3)Then
  81.             L.X =Rand(0,800)
  82.             L.Y =Rand(0,600)
  83.             L.sY=Rand(-3,3)*10
  84.             L.sX=Rand(-3,3)*10
  85.             L.Char = Rand(32,255)
  86.             l.scalex = Rand(1,2)
  87.             l.scaley = Rand(1,2)
  88.             L.Word = AnyWord()
  89.         EndIf
  90.     Next
  91. EndFunction
  92.  
  93. Function FartLetters(X:Int,Y:Int)
  94.     For Local I:Int = 0 To 10
  95.         Local L:TLetter = TLetter(Letters.RemoveLast())
  96.         L.X = X
  97.         L.Y = Y
  98.         L.sX = Rand(-10,10)
  99.         L.sY = Rand(-10,10)
  100.         L.scaleX = Rnd(3,5)
  101.         l.scaleY = Rnd(3,5)
  102.         Select turn
  103.             Case 1
  104.                 L.Word = "NIGGAZ TURN"
  105.             Case 2
  106.                 L.Word = "CRACKAZ TURN"
  107.         EndSelect
  108.         Letters.AddFirst(L)
  109.     Next
  110. EndFunction
  111.  
  112. Repeat
  113.     Shake :* Shake
  114.     If shake < 0.1 Then shake = 0
  115.     If (Rand(0,100)=10) Then Shake=Rnd(0.4,0.5)
  116.  
  117.  
  118.     cursorX = ((MouseX()+24-boardOriginX) / 24)
  119.     cursorY = ((MouseY()+24-boardOriginY) / 24)
  120.     If cursorX  < 0 Then cursorX  = 0
  121.     If cursorX  > 13 Then cursorX  = 13
  122.     If cursory < 0 Then cursory = 0
  123.     If cursory > 13 Then cursory = 13  
  124.     If MouseHit(1)
  125.         PlaceStone()
  126.     EndIf
  127.    
  128.     boardOriginX = baseBoardX + (Shake * Rnd(-10,10))
  129.     boardOriginY = baseBoardY + (Shake * Rnd(-10,10))
  130.    
  131.     SetClsColor  Rand(1,0)*255*Shake , Rand(1,0)*255*Shake,  Rand(1,0)*255*Shake
  132.     If Rand(0,100)>Rand(1,3)*10 Then Cls()
  133.    
  134.     SetScale 2.2 * ( 1 + Abs(Cos(MilliSecs()/10)*Sin(MilliSecs()/50))),4
  135.     SetColor(Rand(100,255),Rand(100,255),Rand(100,255))
  136.     SetRotation 15 * ( (Cos(MilliSecs()/10)*Sin(MilliSecs()/50)))
  137.     DrawText("Race War 2000",400,10)
  138.     DrawBackGround()
  139.    
  140.    
  141.    
  142.     SetScale 1,1
  143.     SetRotation 0
  144.    
  145.     DrawBoard()
  146.     DrawStones()
  147.     If shake>0 Then
  148.         baseboardx = Rand(64,300)
  149.         baseboardy = Rand(64,200)
  150.         Cls
  151.     EndIf
  152.     Flip()
  153.     Delay 20
  154.     If AppTerminate() Or KeyHit(KEY_ESCAPE) Then Exit
  155. Forever
  156.  
  157.  
  158.  
  159. Global turn = 1 ' whites start
  160. Function PlaceStone()
  161.     LastPlaced = CursorX*100 + CursorY
  162.     'If board[cursorX,cursorY]<>0 Then Return
  163.     fartletters( MouseX(), MouseY())
  164.     shake = 0.999
  165.     board[cursorX,cursorY]=Turn
  166.     If turn=2
  167.         turn=1
  168.     Else
  169.         turn=2
  170.     EndIf
  171.  
  172.     Global CheckedForGroup:Int[14,14]
  173.     CheckedForGroup = New Int[14,14]
  174.    
  175.     ' check for groups of stones
  176.     Function AddStoneToGroup:TList(Group:TList,X:Int,Y:Int,fromX:Int=0,fromY:Int=0)
  177.         ' this stone isn't in a group yet,
  178.         ' so I add it to the list
  179.         If(CheckedForGroup[X,Y]) Return
  180.         CheckedForGroup[X,Y]=True
  181.         Local Pos:Int[]
  182.         pos = New Int[2]
  183.         pos[0] = x
  184.         pos[1] = y
  185.         Group.AddLast( Pos )
  186.         ' Adds the one to the right, unless we came from there
  187.         If (X<13)
  188.             If(Board[X+1,Y]=Turn)And ((X+1 > fromX))
  189.                 AddStoneToGroup(Group,X+1,Y,X,Y)
  190.             EndIf
  191.         EndIf
  192.         ' The one to the left
  193.         If (X>0)
  194.             If(Board[X-1,Y]=Turn)And ((X-1 < fromX))
  195.                 AddStoneToGroup(Group,X-1,Y,X,Y)
  196.             EndIf
  197.         EndIf
  198.        
  199.         ' Adds the one to the bottom, unless we came from there
  200.         If (Y<13)
  201.             If(Board[X,Y+1]=Turn)And((Y+1>fromY))
  202.                 addstoneToGroup(group,X,Y+1,x,y)
  203.             EndIf
  204.         EndIf
  205.         ' adds the one to the top, unless we came from there
  206.         If (Y>0)
  207.             If(Board[X,Y-1]=Turn)And((Y-1<fromY))
  208.                 addstoneToGroup(group,X,Y-1,x,y)
  209.             EndIf
  210.         EndIf
  211.        
  212.         Return group
  213.     EndFunction
  214.    
  215.    
  216.     Local x:Int,y:Int
  217.     Local groups:TList
  218.     Groups=New TList
  219.     Local EnemyPieces:Int
  220.     EnemyPieces=0
  221.     For X = 0 To 13
  222.         For Y = 0 To 13
  223.             If Board[X,Y]=Turn Then EnemyPieces:+1
  224.             If CheckedForGroup[X,Y] = False
  225.                 If Board[X,Y]=Turn
  226.                     Local Group:TList
  227.                     Group = New TList
  228.                     AddStoneToGroup(Group,X,Y,X,Y)
  229.                     Groups.AddLast(Group)
  230.                 EndIf
  231.             EndIf
  232.         Next
  233.     Next
  234.     Local I:Int
  235.     I=0
  236.     For Local L:TList = EachIn Groups
  237.         I:+1   
  238.         drawboard()
  239.         drawstones()
  240.         Local CheckedForLiberty:Int[,]
  241.         CheckedForLiberty = New Int[14,14]
  242.        
  243.         Local Liberties:Int
  244.         liberties=0
  245.         Local A:Int[]
  246.         For A = EachIn L                       
  247.             X = A[0]
  248.             Y = A[1]
  249.             ' Count the liberties of each position
  250.             ' To the left
  251.             If X > 0 Then
  252.                 If CheckedForLiberty[X-1,Y]=False Then
  253.                     CheckedForLiberty[X-1,Y]=True
  254.                     If Board[X-1,Y] = 0 Then Liberties:+1
  255.                 EndIf
  256.             EndIf
  257.             ' To the right
  258.             If X < 13 Then
  259.                 If CheckedForLiberty[X+1,Y]=False Then
  260.                     CheckedForLiberty[X+1,Y]=True
  261.                     If Board[X+1,Y]=0 Then Liberties:+1
  262.                 EndIf
  263.             EndIf
  264.             ' Top
  265.             If Y > 0 Then
  266.                 If CheckedForLiberty[X,Y-1]=False Then
  267.                     CheckedForLiberty[X,Y-1]=True
  268.                     If Board[X,Y-1] = 0 Then Liberties:+1
  269.                 EndIf
  270.             EndIf
  271.             ' Bottom
  272.             If Y < 13 Then
  273.                 If CheckedForLiberty[X,Y+1]=False Then
  274.                     CheckedForLiberty[X,Y+1]=True
  275.                     If Board[X,Y+1]=0 Then Liberties:+1
  276.                 EndIf
  277.             EndIf
  278.         Next
  279.  
  280.         If Liberties=0
  281.             For A = EachIn L
  282.                 Board[A[0],A[1]]=0
  283.                 EnemyPieces:-1
  284.             Next
  285.         EndIf
  286.         If EnemyPieces=0 Then GameOver()
  287.     Next
  288.    
  289.     Groups.Clear()
  290.     CheckedForGroup=Null
  291. EndFunction
  292.  
  293. Function GameOver()
  294.     Local Color:String
  295.     If Turn = 1 Then Color = "Niggaz"' Whites obliterated
  296.     If Turn = 2 Then Color= "Crackaz"
  297.    
  298.     For Local I:Int = 0 To 600
  299.         SetClsColor(Rnd(100,255),Rnd(100,255),0)
  300.         Cls
  301.         SetRotation (Rnd(0,13))
  302.         SetScale Rnd(1,2)*2.4,Rnd(1,2)*2.5
  303.         SetColor(Rand(100,244),Rand(100,255),Rand(100,255))
  304.         DrawText Color + " Wins!",64+ 20*Rnd(-1,1), 64 + 20*Rnd(-1,1)
  305.         SetColor(0,0,0)
  306.         DrawText Color + " Wins!",60+ 20*Rnd(-1,1), 60 + 20*Rnd(-1,1)
  307.        
  308.        
  309.         Flip
  310.         If KeyHit(KEY_ESCAPE) Then Exit
  311.    
  312.     Next
  313.    
  314.     SetScale 1,1
  315.     Board = New Int[14,14]
  316. EndFunction
  317.  
  318.  
  319.  
  320. Function DrawBoard()
  321.     SetOrigin boardOriginX,boardOriginY
  322.    
  323.    
  324.     SetAlpha 1
  325.    
  326.     Local x:Int
  327.     Local y:Int
  328.     ' Verticles
  329.     For x = 0 To 13
  330.         SetColor 255 * ( Abs(Cos(MilliSecs()*X/10))),255,255 * ( Abs(Cos(MilliSecs()*X/10)))
  331.         DrawLine X * 24, 0, X*24, 13*24
  332.     Next
  333.     ' Horizontiles
  334.     For y = 0 To 13
  335.         SetColor 255 * ( Abs(Sin(MilliSecs()*y/10))),255,255 * ( Abs(Sin(MilliSecs()*Y/10)))
  336.         DrawLine 0,y*24,13*24,y*24
  337.     Next
  338.    
  339.     SetOrigin 0,0
  340. EndFunction
  341. Global LastPlaced
  342. Function DrawStones()
  343.     Local x:Int
  344.     Local y:Int
  345.     ' cursor
  346.  
  347.    
  348.     DrawText "Position "+x+":"+y,10,10
  349.    
  350.     SetOrigin boardOriginX,boardOriginY
  351.    
  352.     ' stones
  353.  
  354.     SetAlpha 1
  355.     For x = 0 To 13
  356.         For y = 0 To 13
  357.             If LastPlaced = X * 100 + Y
  358.                 SetScale 1+Shake,1+Shake
  359.             Else
  360.                 SetScale 1,1
  361.             EndIf
  362.             If board[x,y]=1 Then
  363.                 SetColor 255,255,255
  364.             Else
  365.                 SetColor 75,75,75+ (Rnd(0,1)*255*Shake)
  366.             EndIf
  367.             If board[x,y] <> 0 Then
  368.                 DrawOval x*24-11,y*24-11,22,22
  369.             EndIf
  370.         Next
  371.     Next
  372.    
  373.     SetAlpha 0.5
  374.     SetColor 255,255,0
  375.     DrawOval cursorX*24 -12,cursory*24 -12,24,24
  376.    
  377.     SetOrigin 0,0
  378. EndFunction
Add Comment
Please, Sign In to add comment