Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GraphicsWindow.Show()
- GraphicsWindow.Width=560
- GraphicsWindow.height=560
- GraphicsWindow.KeyDown=OnKeyDown 'Controls
- GraphicsWindow.backgroundcolor="Black"
- gw=GraphicsWindow.Width 'ShortenerWidth
- gh=GraphicsWindow.Height 'ShortenerHeight
- Red = 0 'Red score
- Blue = 0 'Blue score
- Reset()
- Start:
- x1 = x1 + deltax1 'Movement First TronX
- y1 = y1 + deltay1 'Movement First TronY
- x2 = x2 + deltax2 'Movement Second TronX
- y2 = y2 + deltay2 ''Movement Second TronY
- 'Check if First Tron touches own trail or Second Tron's trail
- If (trail[x1][y1] = 1 Or trail[x1][y1] = 2) then
- GraphicsWindow.ShowMessage("1 point","Blue Wins a")
- Blue=Blue+1
- Reset()
- Loop()
- EndIf
- 'Check if Second Tron touches own trail or First Tron's trail
- If (trail[x2][y2] = 2 Or trail[x2][y2] =1) then
- GraphicsWindow.ShowMessage("1 point","Red Wins a")
- Red= Red+1
- Reset()
- Loop()
- EndIf
- 'Checks if the First Tron or Second Tron touch the end of the screen
- If (a1 = gw-8 Or b1=gh-8 Or b1 < 0 Or a1 < 0) then
- GraphicsWindow.ShowMessage("1 point","Blue Wins b")
- Blue=Blue+1
- Reset()
- Loop()
- Endif
- If (a2 = gw-8 Or b2=gh-8 Or b2 < 0 Or a2 < 0) Then
- GraphicsWindow.ShowMessage("1 point","Red Wins b")
- Red = Red+1
- Reset()
- Loop()
- EndIf
- Shapes.Move(tron1,x1,y1) 'Moving the First Tron's shape
- Shapes.Move(tron2,x2,y2) 'Moving the Second Tron's shape
- a1=Shapes.GetLeft(tron1) 'Orange Trail X
- b1=Shapes.GetTop(tron1) 'Orange Trail Y
- a2=Shapes.GetLeft(tron2) 'Cyan Trail X
- b2=Shapes.GetTop(tron2) 'Cyan Trail Y
- trail[x1][y1] = 1 'First Tron trail array
- trail[x2][y2] = 2 'Second Tron trail array
- GraphicsWindow.brushcolor="Orange"
- GraphicsWindow.FillRectangle(x1,y1,8,8) 'Creating First Tron's trail
- GraphicsWindow.brushcolor="Cyan"
- GraphicsWindow.FillRectangle(x2,y2,8,8) 'Creating Second Tron's trail
- Program.Delay(5) 'Adjusting Game speed
- Goto Start
- Sub OnKeyDown
- If (GraphicsWindow.LastKey="D") Then
- deltax1 = 1
- deltay1 = 0
- EndIf
- If (GraphicsWindow.lastkey="Right")Then
- deltax2 = 1
- deltay2 = 0
- EndIf
- If GraphicsWindow.LastKey="A" Then
- deltax1 = -1
- deltay1 = 0
- EndIf
- If (GraphicsWindow.LastKey="Left") Then
- deltax2 = -1
- deltay2 = 0
- EndIf
- If GraphicsWindow.lastkey="W" Then
- deltax1 = 0
- deltay1 = -1
- EndIf
- If (GraphicsWindow.lastkey="Up")Then
- deltax2 = 0
- deltay2 = -1
- EndIf
- If GraphicsWindow.lastkey="S" Then
- deltax1 = 0
- deltay1 = 1
- EndIf
- If(GraphicsWindow.lastkey="Down")Then
- deltax2 = 0
- deltay2 = 1
- EndIf
- EndSub
- 'http://qs.lc/nha9w
- Sub Reset
- GraphicsWindow.Clear()
- GraphicsWindow.Title = ("Trom "+ Red+" : "+Blue) 'Displays score in Title
- 'First Shape
- GraphicsWindow.pencolor="Red"
- GraphicsWindow.brushcolor= "Red"
- tron1= Shapes.AddRectangle(8,8)
- 'Second Shape
- GraphicsWindow.pencolor="Blue"
- GraphicsWindow.BrushColor= "Blue"
- tron2= Shapes.AddRectangle(8,8)
- x1= 30 'First Tron's X
- y1= 30 'First Tron's Y
- deltax1 = 1 'First Tron's direction X
- deltay1 = 0 'First Tron's direction Y
- x2 = 530 'Second Tron's X
- y2 = 530 'Second Tron's Y
- deltax2 = -1 'Second Tron's direction X
- deltay2 = 0 'Second Tron's direction y
- EndSub
- Sub Loop
- For i = 0 To gw
- For j = 0 To gh
- trail[j][i] = 0
- EndFor
- EndFor
- EndSub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement