Sub TankData
Dir = Program.Directory+"\Pictures\"
For i = 1 To 4
TankImage[i] = ImageList.LoadImage(Dir+"Tank "+i+".gif")
EndFor
TankImage[5] = ImageList.LoadImage(Dir+"Boss.gif")
TankSpeed[1] = 3 'speed he goes per about ?? milliseconds
TankHP[1] = 50 'hit points
TankArmor[1] = 1 'damage reduction
TankMoney[1] = 50 'money for killing
TankProb[1] = 35 'probability of it appearing in percent
Sub LevelData
For i = 1 To 50
Level_AmountTanks[i] = Math.Power(i*2,2)
EndFor
EndSub
Sub ToolBar
GraphicsWindow.Width = Width+100
GraphicsWindow.BrushColor = "LightGray"
GraphicsWindow.PenColor = "LightGray"
Bar = Shapes.AddRectangle(100,Height)
Shapes.Move(Bar,Width,0)
GraphicsWindow.BrushColor = "Gray"
GraphicsWindow.PenColor = "Gray"
txtMoney = Shapes.AddText("Your money:"+Text.GetCharacter(10)+" $ "+Money)
Hearts = ""
For i = 1 To Lives
Hearts = Hearts+"♥ "
EndFor
txtLives = Shapes.AddText("Your lives:"+Text.GetCharacter(10)+Hearts)
Shapes.Move(txtMoney,Width+20,10)
Shapes.Move(txtLives,Width+20,50)
For i = 1 To TowerNum
BackSquare[i] = Shapes.AddRectangle(30,30)
Icon[i] = Shapes.AddImage(TowerImage[i])
CostDisplay[i] = Shapes.AddText("$ "+TowerCost[i])
Shapes.Move(BackSquare[i],Width+50-15,i*80)
Shapes.Move(Icon[i],Width+50-13,i*80+3)
Shapes.Move(CostDisplay[i],Width+50-25,i*80+40)
Shapes.SetOpacity(BackSquare[i],20)
EndFor
btnStart = Controls.AddButton("Start!",Width+50-30,i*80+30)
btnPause = Controls.AddButton("Pause",Width+50-30,i*80+60)
EndSub
Sub StartTanksComing
Lives = Lives+1
Hearts = ""
For i = 1 To Lives
Hearts = Hearts+"♥ "
EndFor
Shapes.SetText(txtLives,"Your lives:"+Text.GetCharacter(10)+Hearts)
LevelNum = LevelNum+1
For g = 1 To Level_AmountTanks[LevelNum]
NumOfTank = Math.GetRandomNumber(100)
If NumOfTank <= TankProb[1] Then
nowTank = 1
ElseIf NumOfTank <= TankProb[2]+TankProb[1] Then
nowTank = 2
ElseIf NumOfTank <= TankProb[3]+TankProb[2]+TankProb[1] Then
nowTank = 3
ElseIf NumOfTank <= TankProb[4]+TankProb[3]+TankProb[2]+TankProb[1] Then
nowTank = 4
EndIf
tTank[g] = Shapes.AddImage(TankImage[nowTank])
tX[g] = -g*80
tY[g] = Height/2-20+Math.GetRandomNumber(20)
tType[g] = nowTank
tHP[g] = TankHP[nowTank]
tArmor[g] = TankArmor[nowTank]
tMoney[g] = TankMoney[nowTank]
tSpeed[g] = TankSpeed[nowTank]
Amount_Tanks = Amount_Tanks+1
EndFor
EndSub
Sub MouseMove
MX = GraphicsWindow.MouseX
MY = GraphicsWindow.MouseY
If waitingToBePlaced Then
Shapes.Move(twTower[index],MX-13,MY-13)
Else
For q = 1 To TowerNum
If MX > Width+50-15 And MX < Width+50+15 And MY > q*80 And MY < q*80+30 Then
If Money >= TowerCost[q] Then
Shapes.SetOpacity(BackSquare[q],90)
Else
Shapes.SetOpacity(BackSquare[q],20)
EndIf
Else
Shapes.SetOpacity(BackSquare[q],20)
EndIf
EndFor
EndIf
EndSub
Sub MouseUp
If waitingToBePlaced And MY < Height/2-32 Or MY > Height/2+32 Then
twX[index] = MX-13
twY[index] = MY-13
notFiring[index] = "True"
waitingToBePlaced = "False"
Else
For q = 1 To TowerNum
If MX > Width+50-15 And MX < Width+50+15 And MY > q*80 And MY < q*80+30 Then
If Money >= TowerCost[q] Then
index = index+1
waitingToBePlaced = "True"
twTower[index] = Shapes.AddImage(TowerImage[q])
twType[index] = q
twDamage[index] = TowerDamage[q]
twRange[index] = TowerRange[q]
twSpeed[index] = TowerSpeed[q]
Shapes.Move(twTower[index],MX-12,MY-12)
Money = Money-TowerCost[q]
Shapes.SetText(txtMoney,"Your money:"+Text.GetCharacter(10)+" $ "+Money)
EndIf
EndIf
EndFor
EndIf
EndSub
Sub ButtonClick
Button = Controls.LastClickedButton
If Button = btnStart Then
Timer.Tick = OnTick
StartTanksComing()
ElseIf Button = btnPause Then
Pause()
ElseIf Button = btnCancel Then
Controls.Remove(btnCancel)
Controls.Remove(btnNewSaveSlot)
For i = 1 To Array.GetItemCount(SavedGames)
Controls.Remove(btnSaveGame[i])
EndFor
Shapes.Remove(PauseScreen)
Pause()
ElseIf Button = btnUnpause Then
Timer.Tick = OnTick
Shapes.Remove(PauseScreen)
Controls.Remove(btnUnpause)
Controls.Remove(btnSaveGame)
Controls.Remove(btnLoadGame)
Controls.Remove(btnQuit)
ElseIf Button = btnSaveGame Then
SaveGame()
ElseIf Array.ContainsValue(btnSaveGame,Button) Then
OverwriteFile()
ElseIf Button = btnNewSaveSlot Then
AskForFileName()
ElseIf Button = btnLoadGame Then
LoadGame()
ElseIf Array.ContainsValue(btnLoadGame,Button) Then
LoadFile()
ElseIf Button = btnQuit Then
Quit()
EndIf
EndSub
Sub SaveGame
Controls.Remove(btnUnpause)
Controls.Remove(btnSaveGame)
Controls.Remove(btnLoadGame)
Controls.Remove(btnQuit)
' The following line could be harmful and has been automatically commented.
' SavedGames = File.GetFiles(Program.Directory+"\Saved games\")
btnCancel = Controls.AddButton("Cancel",10,10)
Controls.SetSize(btnCancel,Width+80,(Height-20)/(Array.GetItemCount(SavedGames)+2))
For i = 1 To Array.GetItemCount(SavedGames)
btnSaveGame[i] = Controls.AddButton(Text.GetSubTextToEnd(Text.GetSubText(SavedGames[i],1,Text.GetLength(SavedGames[i])-4),Text.GetLength(Program.Directory+"\Saved games\")+1),10,i*(Height-20)/(Array.GetItemCount(SavedGames)+2)+10)
Controls.SetSize(btnSaveGame[i],Width+80,(Height-20)/(Array.GetItemCount(SavedGames)+2))
EndFor
btnNewSaveSlot = Controls.AddButton("New save slot",10,(i)*(Height-20)/(Array.GetItemCount(SavedGames)+2)+10)
Controls.SetSize(btnNewSaveSlot,Width+80,(Height-20)/(Array.GetItemCount(SavedGames)+2))
EndSub
Sub OverwriteFile
EndSub
Sub AskForFileName
EndSub
Sub LoadGame
Controls.Remove(btnUnpause)
Controls.Remove(btnSaveGame)
Controls.Remove(btnLoadGame)
Controls.Remove(btnQuit)
' The following line could be harmful and has been automatically commented.
' SavedGames = File.GetFiles(Program.Directory+"\Saved games\")
btnCancel = Controls.AddButton("Cancel",10,10)
Controls.SetSize(btnCancel,Width+80,(Height-20)/(Array.GetItemCount(SavedGames)+1))
For i = 1 To Array.GetItemCount(SavedGames)
btnLoadGame[i] = Controls.AddButton(Text.GetSubTextToEnd(Text.GetSubText(SavedGames[i],1,Text.GetLength(SavedGames[i])-4),Text.GetLength(Program.Directory+"\Saved games\")+1),10,i*(Height-20)/(Array.GetItemCount(SavedGames)+1)+10)
Controls.SetSize(btnLoadGame[i],Width+80,(Height-20)/(Array.GetItemCount(SavedGames)+1))
EndFor
EndSub
Sub LoadFile
EndSub
Sub Nothing
EndSub
Sub Quit
Program.End()
EndSub
Sub DetermineTarget
Target = ""
Greatest = ""
For r = 1 To Amount_Tanks
If tX[r] > Greatest And Math.SquareRoot(Math.Power(tX[r]-twX[h],2)+Math.Power(tY[r]-twY[h],2)) < twRange[h] Then
Greatest = tX[r]
Target = r
EndIf
EndFor
If Math.SquareRoot(Math.Power(tX[Target]-twX[h],2)+Math.Power(tY[Target]-twY[h],2)) > twRange[h] Then
notFiring[h] = "True"
EndIf
EndSub
Sub DetermineAngle
dx = twX[h] - tX[Target]
dy = twY[h] - tY[Target]
If (dx = 0) Then
angle = Math.Pi/2
If (dy < 0) Then
angle = -angle
EndIf
Else
angle = Math.ArcTan(dy/dx)
EndIf
If (dx < 0) Then
angle = angle+Math.Pi
EndIf
angle = angle+Math.Pi
EndSub