Advertisement
MDGTutorials

Untitled

Dec 10th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.40 KB | None | 0 0
  1. GraphicsWindow.Show()
  2. GraphicsWindow.Width=560
  3. GraphicsWindow.height=560
  4. GraphicsWindow.KeyDown=OnKeyDown 'Controls
  5. GraphicsWindow.backgroundcolor="Black"
  6. gw=GraphicsWindow.Width 'ShortenerWidth
  7. gh=GraphicsWindow.Height 'ShortenerHeight
  8.  
  9. Red = 0 'Red score
  10. Blue = 0 'Blue score
  11. Reset()
  12.  
  13.  
  14. Start:
  15.  
  16.  
  17. x1 = x1 + deltax1  'Movement First TronX
  18. y1 = y1 + deltay1 'Movement First TronY
  19. x2 = x2 + deltax2  'Movement Second  TronX
  20. y2 = y2 + deltay2 ''Movement Second  TronY
  21.  
  22.  
  23.  
  24.  'Check if  First Tron touches own trail or Second Tron's trail
  25.  If (trail[x1][y1] = 1 Or trail[x1][y1] = 2) then
  26.  GraphicsWindow.ShowMessage("1 point","Blue Wins a")
  27.  Blue=Blue+1
  28.  Reset()
  29.  Loop()
  30. EndIf
  31.  
  32. 'Check if Second Tron touches  own trail or First Tron's trail
  33.  If (trail[x2][y2] = 2 Or trail[x2][y2] =1) then
  34.  GraphicsWindow.ShowMessage("1 point","Red Wins a")
  35.  Red= Red+1
  36.  Reset()
  37.  Loop()
  38. EndIf
  39.  
  40.  'Checks if  the First Tron or Second Tron touch the end of the screen
  41.  
  42. If (a1 = gw-8 Or b1=gh-8 Or b1 < 0 Or a1 < 0) then
  43.  GraphicsWindow.ShowMessage("1 point","Blue Wins b")
  44.  Blue=Blue+1
  45.  Reset()
  46.  Loop()
  47. Endif
  48.  
  49.  If (a2 = gw-8 Or b2=gh-8 Or b2 < 0 Or a2 < 0) Then
  50.   GraphicsWindow.ShowMessage("1 point","Red Wins b")
  51.   Red = Red+1
  52.   Reset()
  53.   Loop()
  54. EndIf
  55.  
  56.  
  57. Shapes.Move(tron1,x1,y1) 'Moving the First Tron's shape
  58. Shapes.Move(tron2,x2,y2) 'Moving the Second Tron's shape
  59.  
  60. a1=Shapes.GetLeft(tron1) 'Orange Trail X
  61. b1=Shapes.GetTop(tron1) 'Orange Trail Y
  62.  
  63. a2=Shapes.GetLeft(tron2) 'Cyan Trail X
  64. b2=Shapes.GetTop(tron2) 'Cyan Trail Y
  65.  
  66. trail[x1][y1] = 1 'First Tron trail array
  67.  trail[x2][y2] = 2 'Second Tron trail array
  68.  
  69. GraphicsWindow.brushcolor="Orange"
  70. GraphicsWindow.FillRectangle(x1,y1,8,8) 'Creating First Tron's trail
  71.  
  72. GraphicsWindow.brushcolor="Cyan"
  73. GraphicsWindow.FillRectangle(x2,y2,8,8) 'Creating Second Tron's trail
  74.  
  75.  
  76. Program.Delay(5) 'Adjusting Game speed
  77. Goto Start
  78.  
  79. Sub OnKeyDown
  80.  
  81.     If (GraphicsWindow.LastKey="D") Then
  82.     deltax1 = 1
  83.     deltay1 = 0
  84.   EndIf
  85.  
  86.    If (GraphicsWindow.lastkey="Right")Then
  87.     deltax2 = 1
  88.     deltay2 = 0
  89.    EndIf
  90.  
  91.    If GraphicsWindow.LastKey="A" Then
  92.     deltax1 = -1
  93.     deltay1 = 0
  94.   EndIf
  95.  
  96.    If (GraphicsWindow.LastKey="Left") Then
  97.     deltax2 = -1
  98.     deltay2 = 0
  99.    EndIf
  100.  
  101.  If GraphicsWindow.lastkey="W" Then
  102.       deltax1 = 0
  103.       deltay1 = -1
  104.     EndIf
  105.    
  106.     If (GraphicsWindow.lastkey="Up")Then
  107.       deltax2 = 0
  108.       deltay2 = -1
  109.  EndIf
  110.    
  111. If GraphicsWindow.lastkey="S" Then
  112.       deltax1 = 0
  113.       deltay1 = 1
  114.     EndIf
  115.    
  116.     If(GraphicsWindow.lastkey="Down")Then
  117.       deltax2 = 0
  118.       deltay2 = 1
  119.    EndIf
  120.    
  121. EndSub
  122.  
  123. 'http://qs.lc/nha9w
  124.  
  125.  
  126. Sub Reset
  127.  GraphicsWindow.Clear()
  128.  GraphicsWindow.Title = ("Trom  "+ Red+" : "+Blue) 'Displays score in Title
  129.  
  130.  
  131. 'First Shape
  132. GraphicsWindow.pencolor="Red"
  133. GraphicsWindow.brushcolor= "Red"
  134. tron1= Shapes.AddRectangle(8,8)
  135.  
  136. 'Second Shape
  137.  GraphicsWindow.pencolor="Blue"
  138.  GraphicsWindow.BrushColor= "Blue"
  139. tron2= Shapes.AddRectangle(8,8)
  140.  
  141.  
  142. x1= 30 'First Tron's X
  143. y1= 30 'First Tron's Y
  144. deltax1 = 1 'First Tron's direction X
  145. deltay1 = 0 'First Tron's direction Y
  146.  
  147. x2 = 530 'Second Tron's X
  148. y2 = 530 'Second Tron's Y
  149. deltax2 = -1 'Second Tron's direction X
  150. deltay2 = 0 'Second Tron's direction y
  151.  
  152.  
  153.  
  154. EndSub  
  155.  
  156.  
  157. Sub Loop
  158.    For i = 0 To gw
  159.   For j = 0 To gh
  160.     trail[j][i] = 0
  161.   EndFor
  162. EndFor
  163.  
  164. EndSub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement