MDGTutorials

Untitled

Dec 11th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.89 KB | None | 0 0
  1. 'TROM is a non-profit fanmade game, developed as a University Project. All rights over the name TROM reserved ©MDG and no Copyright infringement intended over the TRON name.
  2. 'Two lightcycles in a vast space.
  3. 'The one that hits the end of the playfield or the other lightcycle's trail loses.
  4. 'The Player who survives the round is given 1 point.
  5. 'First to 5 points wins the game
  6. 'Player 1 uses WASD and Player 2 uses the Arrow keys (↑←↓→)
  7. 'Don't forget to have fun and change the difficulty if you find it too easy or too hard  /To be added
  8.  
  9. If (GraphicsWindow.lastkey="F1") Then
  10.  Easy()
  11.  Reset()
  12. Endif
  13.  
  14. If (GraphicsWindow.lastkey="F2") Then
  15.  Normal()
  16.  Reset()
  17. Endif
  18.  
  19. If (GraphicsWindow.lastkey="F3") Then
  20.  Hard()
  21.  Reset()
  22. Endif
  23.  
  24. GraphicsWindow.KeyDown=OnKeyDown 'Controls
  25. GraphicsWindow.backgroundcolor="Black"
  26. gw=GraphicsWindow.Width 'ShortenerWidth
  27. gh=GraphicsWindow.Height 'ShortenerHeight
  28.  
  29. Red = 0 'Red score
  30. Blue = 0 'Blue score
  31.  
  32. Reset() 'Resetting Trom positions
  33. Start: 'Game Start
  34.  
  35. x1 = x1 + deltax1  'Movement First TromX
  36. y1 = y1 + deltay1 'Movement First TromY
  37. x2 = x2 + deltax2  'Movement Second  TromX
  38. y2 = y2 + deltay2 ''Movement Second  TromY
  39.  
  40. 'Check if  First Trom touches own trail or Second Trom's trail
  41.  If (trail[x1][y1] = 1 Or trail[x1][y1] = 2) then
  42.   GraphicsWindow.ShowMessage("1 point To Blue","Red hit Blue's trail")
  43.   Blue=Blue+1
  44.   Reset()
  45.  EndIf
  46.  
  47. 'Check if Second Trom touches  own trail or First Trom's trail
  48.  If (trail[x2][y2] = 2 Or trail[x2][y2] =1) then
  49.    GraphicsWindow.ShowMessage("1 point To Red","Blue hit Red's trail")
  50.    Red= Red+1
  51.    Reset()
  52.  EndIf
  53.  
  54. 'Checks if  the First Trom or Second Trom touch the end of the screen
  55.  
  56.   If (x1 = gw-8 Or y1=gh-8 Or y1 < 0 Or x1 < 0) then
  57.     GraphicsWindow.ShowMessage("1 point to Blue","Red hit a wall")
  58.     Blue=Blue+1
  59.     Reset()
  60.   Endif
  61.  
  62.   If (x2 = gw-8 Or y2=gh-8 Or y2 < 0 Or x2 < 0) Then
  63.     GraphicsWindow.ShowMessage("1 point To Red","Blue hit a wall")
  64.     Red = Red+1
  65.     Reset()
  66.   EndIf
  67.  
  68. Shapes.Move(Trom1,x1,y1) 'Moving the First Trom's shape
  69. Shapes.Move(Trom2,x2,y2) 'Moving the Second Trom's shape
  70.  
  71. a1=Shapes.GetLeft(Trom1) 'Orange Trail X
  72. b1=Shapes.GetTop(Trom1) 'Orange Trail Y
  73.  
  74. a2=Shapes.GetLeft(Trom2) 'Cyan Trail X
  75. b2=Shapes.GetTop(Trom2) 'Cyan Trail Y
  76.  
  77. GraphicsWindow.brushcolor="Orange"
  78. GraphicsWindow.FillRectangle(x1,y1,8,8) 'Creating First Trom's trail
  79.  
  80. GraphicsWindow.brushcolor="Cyan"
  81. GraphicsWindow.FillRectangle(x2,y2,8,8) 'Creating Second Trom's trail
  82.  
  83. trail[x1][y1] = 1 'First Trom trail array
  84. trail[x2][y2] = 2 'Second Trom trail array
  85.  
  86. Program.Delay(5) 'Adjusting Game speed
  87.  
  88. Goto Start
  89.  
  90. Sub OnKeyDown 'Controls
  91.  
  92.     If (GraphicsWindow.LastKey="D") Then
  93.       deltax1 = 1
  94.       deltay1 = 0
  95.     EndIf
  96.  
  97.     If (GraphicsWindow.lastkey="Right")Then
  98.       deltax2 = 1
  99.       deltay2 = 0
  100.     EndIf
  101.  
  102.     If GraphicsWindow.LastKey="A" Then
  103.       deltax1 = -1
  104.       deltay1 = 0
  105.     EndIf
  106.  
  107.     If (GraphicsWindow.LastKey="Left") Then
  108.       deltax2 = -1
  109.       deltay2 = 0
  110.     EndIf
  111.  
  112.     If GraphicsWindow.lastkey="W" Then
  113.       deltax1 = 0
  114.       deltay1 = -1
  115.     EndIf
  116.    
  117.     If (GraphicsWindow.lastkey="Up")Then
  118.       deltax2 = 0
  119.       deltay2 = -1
  120.     EndIf
  121.    
  122.     If GraphicsWindow.lastkey="S" Then
  123.       deltax1 = 0
  124.       deltay1 = 1
  125.     EndIf
  126.    
  127.     If(GraphicsWindow.lastkey="Down")Then
  128.       deltax2 = 0
  129.       deltay2 = 1
  130.     EndIf
  131.    
  132. If (GraphicsWindow.lastkey="F1") Then
  133.   Easy()
  134. EndIf
  135.  
  136.  
  137. If (GraphicsWindow.lastkey="F2") Then
  138. Normal()
  139. EndIf
  140.  
  141. If (GraphicsWindow.lastkey="F3") Then
  142.   Hard()
  143. EndIf
  144.  
  145.  
  146. EndSub
  147.  
  148.  Sub Reset 'Resetting Trom positions
  149.  
  150. GraphicsWindow.Clear()
  151. GraphicsWindow.Title = ("Trom  "+ Red+"  :  "+Blue) 'Displays score in Title
  152.  
  153. If (Red=5) Then
  154.   Sound.PlayChime()
  155.   GraphicsWindow.ShowMessage("Red Wins the Game","Better luck next time, Blue")
  156.   Program.End()
  157. EndIf
  158.  
  159. If (Blue=5) Then
  160.   Sound.PlayChime()
  161.   GraphicsWindow.ShowMessage("Blue Wins the Game","Better luck next time, Red")
  162.   Program.End()
  163. EndIf
  164.  
  165. 'First Shape
  166. GraphicsWindow.pencolor="Red"
  167. GraphicsWindow.brushcolor= "Red"
  168. Trom1= Shapes.AddRectangle(8,8)
  169.  
  170. 'Second Shape
  171.  GraphicsWindow.pencolor="Blue"
  172.  GraphicsWindow.BrushColor= "Blue"
  173. Trom2= Shapes.AddRectangle(8,8)
  174.  
  175. x1= 30 'First Trom's X
  176. y1= 30 'First Trom's Y
  177. deltax1 = 1 'First Trom's direction X
  178. deltay1 = 0 'First Trom's direction Y
  179.  
  180. x2 = gw-30 'Second Trom's X
  181. y2 = gh-30 'Second Trom's Y
  182. deltax2 = -1 'Second Trom's direction X
  183. deltay2 = 0 'Second Trom's direction y
  184.  
  185. trail = "" 'Removing old Trom trails
  186.  
  187. EndSub
  188.  
  189. Sub Normal
  190.  GraphicsWindow.Show()
  191.  GraphicsWindow.Width=560
  192.  GraphicsWindow.Height=560
  193. EndSub
  194.  
  195. Sub Easy
  196.  GraphicsWindow.Show()
  197.  GraphicsWindow.Width=640
  198.  GraphicsWindow.Height=640
  199. EndSub
  200.  
  201. Sub Hard
  202.  GraphicsWindow.Show()
  203.  GraphicsWindow.Width=400
  204.  GraphicsWindow.Height=400
  205. EndSub
Advertisement
Add Comment
Please, Sign In to add comment