You may have recently read that I created a small program for my dad and I because we play alot of xbox. I have completly re-written the code and I have a couple of questions about it.
Here is the code:
Rem Project: Football ManagerMode
Rem Created: 17/06/2009 20:29:09
Rem ***** Main Source File *****
`VARIABLES
WinPoints = 3
YellowCardBan = 5
RedCardBan = 1
MatchesBanIfRed = 3
MatchesBanYellowCard = 2
MatchesInjured = 2
LiverpoolMoney = 35000000
BarcelonaMoney = 40000000
BackToMenu$ = "Back to Menu"
FinishMatch$ = "Finished a Match?"
`Test Variables.
GamesPlayed = 0
Leader$ = "Liverpool"
Loser$ = "Barcelona"
LeaderWins = 0
LoserWins = 0
LeaderLosses = LoserWins
LoserLosses = LeaderWins
LeaderGoals = 0
LoserGoals = 0
LeaderC = LoserGoals
LoserC = LeaderGoals
LeaderGD = LeaderGoals - LeaderC
LoserGD = LoserGoals - LoserC
LeaderPoints = (LeaderWins * WinPoints)+(LeaderLosses * LosePoints)
LoserPoints = (LoserWins * WinPoints)+(LoserLosses * LosePoints)
LiverpoolGoals = 0
BarcelonaGoals = 0
LiverpoolPoints = 0
BarcelonaPoints = 0
LiverpoolGD = LiverpoolGoals - BarcelonaGoals
BarcelonaGD = BarcelonaGoals - LiverpoolGoals
JPKV = 0
DPKV = 0
TopScorer1$ = "Torres"
TopScorer2$ = "Rooney"
TopScorer3$ = "Eto'o"
TopScorer4$ = "Henry"
TopScorer5$ = "Gerrard"
`PKK
If JPKV > DPKV
PKK$ = "Liverpool "
PKL$ = "Barcalona "
PKVL = DPKV
PKVW = JPKV
endif
if DPKV > JPKV
PKK$ = "Barcalona "
PKVW = DPKV
PKL$ = "Liverpool "
PKVL = JPKV
endif
`Main Menu
Menu1:
`CalcVarys
LeaderC = LoserGoals
LoserC = LeaderGoals
LeaderGD = LeaderGoals - LeaderC
LoserGD = LoserGoals - LoserC
LeaderPoints = (LeaderWins * WinPoints)+(LeaderLosses * LosePoints)
LoserPoints = (LoserWins * WinPoints)+(LoserLosses * LosePoints)
CLS
Text 245,114,"Manage Mode: The Complete Package"
Line 0,150,Screen Width(),150
Text 800,186,FinishMatch$
text 245,186,"Access Table"
text 245,262,"Access Liverpool Stats"
text 245,338,"Access Barcelona Stats"
text 245,414,"Access Transfer List"
text 245,490,"Access Finances"
text 245,566,"Players on Bans"
text 245,642,"Recent Transfers"
text 245,718,"Save and Quit"
Do
Mx=MouseX(): My=MouseY(): Mc=MouseClick()
If Mc=1 Then Gosub CheckRegion
Sync
Loop
End
CheckRegion:
Rem TableButton
If Mx > 800 and My > 186 And Mx < 1121 And My < 242
gosub FinishedMatch
Endif
If Mx > 245 and My > 186 And Mx < 566 And My < 242
gosub Table
Endif
Rem LiverpoolStatsButton
If Mx > 245 and My > 262 And Mx < 566 And My < 318
Gosub LiverpoolStats
Endif
Rem BarcelonaStatsButton
If Mx > 245 and My > 338 And Mx < 566 And My < 394
Gosub BarcelonaStats
Endif
Rem Fourth Button
If Mx > 245 and My > 414 And Mx < 566 And My < 470
Rem Add here, whatever code you want to be executed when you click button 4
Endif
Rem Fifth Button
If Mx > 245 and My > 490 And Mx < 566 And My < 546
Rem Add here, whatever code you want to be executed when you click button 5
Endif
If Mx > 245 and My > 566 And Mx < 566 And My < 622
Rem Add here, whatever code you want to be executed when you click button 5
Endif
If Mx > 245 and My > 642 And Mx < 566 And My < 698
Rem Add here, whatever code you want to be executed when you click button 5
Endif
If Mx > 245 and My > 718 And Mx < 566 And My < 774
Rem Add here, whatever code you want to be executed when you click button 5
end
Endif
Return
`Table
Table:
CLS
`Main Table
text 245,642,BackToMenu$
LINE 117,245,702,245
Text 117,230,"Club"
Text 117,260,Leader$
Text 117,285,Loser$
text 247,230,"Wins"
Text 247,260,str$(LeaderWins)
Text 247,285,str$(LoserWins)
Text 312,230,"Losses"
Text 312,260,str$(LeaderLosses)
Text 312,285,str$(LoserLosses)
Text 377,230,"Goals F"
Text 377,260,str$(LeaderGoals)
Text 377,285,str$(LoserGoals)
Text 442,230,"Goals A"
Text 442,260,str$(LeaderC)
Text 442,285,str$(LoserC)
Text 507,230,"Goal D"
Text 507,260,str$(LeaderGD)
Text 507,285,str$(LoserGD)
Text 572,230,"Points"
Text 572,260,str$(LeaderPoints)
Text 572,285,str$(LoserPoints)
Text 637,230,"Played"
Text 637,260,str$(GamesPlayed)
Text 637,285,str$(GamesPlayed)
`TopScorer
Text 117,400,"Top 5 Goal Scorers"
Text 117,430,TopScorer1$
Text 117,445,TopScorer2$
Text 117,460,TopScorer3$
Text 117,475,TopScorer4$
Text 117,490,TopScorer5$
`LongestWinStreak
Text 377,400,"Longest Win Streak"
`ExtraTimeKing
Text 572,400,"Penalty Shootout Victories"
Text 572,430,PKK$+str$(PKVW)
Text 572,445,PKL$+str$(PKVL)
`Total Red/Yellow Cards
Text 800,400,"Total Red Cards"
Text 800,415,str$(TotalRedCards)
Text 800,460,"Total Yellow Cards"
Text 800,475,str$(TotalYellowCards)
`Final Thing
Do
Mx=MouseX(): My=MouseY(): Mc=MouseClick()
If Mc=1 Then Gosub CheckRegionTable
Sync
Loop
End
CheckRegionTable:
If Mx > 245 and My > 642 And Mx < Text Width(BackToMenu$) And My < Text Height(BackToMenu$)
gosub Menu1
Endif
return
`LIVERPOOL STATS!!!!!
LiverpoolStats:
CLS
Text 245,642,"Back to Main Menu"
LINE 117,245,702,245
Text 117,315,"Liverpool Yellow Cards: "+str$(LiverpoolYellow)
Text 117,330,"Liverpool Red Cards: "+str$(LiverpoolYellow)
Text 117,345,"Liverpool Injuries: "+str$(LiverpoolHurt)
Text 117,75,"Liverpool Finances: "+"£"+str$(LiverpoolMoney)
Text 117,230,"Club"
Text 117,260,"Liverpool"
Text 247,230,"Wins"
Text 247,260,str$(LeaderWins)
Text 312,230,"Losses"
Text 312,260,str$(LeaderLosses)
Text 377,230,"Goals F"
Text 377,260,str$(LeaderGoals)
Text 442,230,"Goals A"
Text 442,260,str$(LeaderC)
Text 507,230,"Goal D"
Text 507,260,str$(LeaderGD)
Text 572,230,"Points"
Text 572,260,str$(LeaderPoints)
Text 637,230,"Played"
Text 637,260,str$(GamesPlayed)
`BackToMenu
Do
Mx=MouseX(): My=MouseY(): Mc=MouseClick()
If Mc=1 Then Gosub CheckRegionTable
Sync
Loop
End
CheckRegionTable:
If Mx > 245 and My > 642 And Mx < 566 And My < 698
gosub Menu1
Endif
return
`BARCELONA STATS!!!!!
BarcelonaStats:
CLS
text 245,642,"Back to Main Menu"
LINE 117,245,702,245
Text 117,315,"Barcelona Yellow Cards: "+str$(BarcelonaYellow)
Text 117,330,"Barcelona Red Cards: "+str$(BarcelonaYellow)
Text 117,345,"Barcelona Injuries: "+str$(BarcelonaHurt)
Text 117,75,"Barcelona Finances: "+"£"+str$(BarcelonaMoney)
Text 117,230,"Club"
Text 117,260,"Barcelona"
text 247,230,"Wins"
Text 247,260,str$(LoserWins)
Text 312,230,"Losses"
Text 312,260,str$(LoserLosses)
Text 377,230,"Goals F"
Text 377,260,str$(LoserGoals)
Text 442,230,"Goals A"
Text 442,260,str$(LoserC)
Text 507,230,"Goal D"
Text 507,260,str$(LoserGD)
Text 572,230,"Points"
Text 572,260,str$(LoserPoints)
Text 637,230,"Played"
Text 637,260,str$(LoserPlayed)
`BackToMenu
Do
Mx=MouseX(): My=MouseY(): Mc=MouseClick()
If Mc=1 Then Gosub CheckRegionTable
Sync
Loop
End
CheckRegionTable:
If Mx > 245 and My > 642 And Mx < 566 And My < 698
gosub Menu1
Endif
return
FinishedMatch:
CLS
Text 117,260,"Who won? "
set cursor 190,260
Input ""; WinsOne$
Text 117,275,"Liverpool Goals: "
set cursor 250,275
Input "";LiverpoolGoalsMatch
Text 117,290,"Barcelona Goals: "
set cursor 250,290
Input "";BarcelonaGoalsMatch
text 245,642,"Back to Main Menu"
GamesPlayed = GamesPlayed + 1
BarcelonaGoals = BarcelonaGoals + BarcelonaGoalsMatch
LiverpoolGoals = LiverpoolGoals + LiverpoolGoalsMatch
If WinsOne$ = "Jack"
LiverpoolWins = LiverpoolWins + 1
BarcelonaLosses = BarcelonaLosses + 1
LiverpoolPoints = LiverpoolPoints + 3
BarcelonaPoints = BarcelonaPoints + 0
If LiverpoolPoints > BarcelonaPoints
gosub LiverpoolTableStats
endif
endif
If WinsOne$ = "Dad"
BarcelonaWins = BarcelonaWins + 1
LiverpoolLosses = LiverpoolLosses + 1
BarcelonaPoints = BarcelonaPoints + 3
LiverpoolPoints = LiverpoolPoints + 0
If BarcelonaPoints > LiverpoolPoints
Gosub BarcelonaTableStats
endif
endif
Do
Mx=MouseX(): My=MouseY(): Mc=MouseClick()
If Mc=1 Then Gosub CheckRegionTable
Sync
Loop
End
CheckRegionTable:
If Mx > 245 and My > 642 And Mx < 566 And My < 698
goto Menu1
Endif
return
LiverpoolTableStats:
LeaderGoals = LiverpoolGoals
LeaderPoints = LiverpoolPoints
LeaderC = BarcelonaGoals
LeaderGD = LiverpoolGD
LeaderWins = LiverpoolWins
LeaderLosses = LiverpoolLosses
LoserGoals = BarcelonaGoals
LoserPoints = BarcelonaPoints
LoserC = LiverpoolGoals
LoserGD = BarcelonaGD
LoserWins = BarcelonaWins
LoserLosses = BarcelonaLosses
return
BarcelonaTableStats:
LeaderGoals = BarcelonaGoals
LeaderPoints = BarcelonaPoints
LeaderC = LiverpoolGoals
LeaderGD = BarcelonaGD
LeaderWins = BarcelonaWins
LeaderLosses = BarcelonaLosses
LoserGoals = LiverpoolGoals
LoserPoints = LiverpoolPoints
LoserC = BarcelonaGoals
LoserGD = LiverpoolGD
LoserWins = LiverpoolWins
LoserLosses = LiverpoolLosses
return
`Red Cards
`Yellow Cards
`Number of goals scored
`Number of goals conceded
`Goal Difference
`Money
`Team
`Top Scorer
`Transfer List
`Add/Remove Player
Ok,
Question 1:
Is there a way of simplifieing my code in any way. Maybe by using Functions?
Question 2:
A part of my code isn't working.
If WinsOne$ = "Dad"
BarcelonaWins = BarcelonaWins + 1
LiverpoolLosses = LiverpoolLosses + 1
BarcelonaPoints = BarcelonaPoints + 3
LiverpoolPoints = LiverpoolPoints + 0
If BarcelonaPoints > LiverpoolPoints
Gosub BarcelonaTableStats
endif
endif
REM Followed By:
BarcelonaTableStats:
LeaderGoals = BarcelonaGoals
LeaderPoints = BarcelonaPoints
LeaderC = LiverpoolGoals
LeaderGD = BarcelonaGD
LeaderWins = BarcelonaWins
LeaderLosses = BarcelonaLosses
LoserGoals = LiverpoolGoals
LoserPoints = LiverpoolPoints
LoserC = BarcelonaGoals
LoserGD = LiverpoolGD
LoserWins = LiverpoolWins
LoserLosses = LiverpoolLosses
return
This part for my dad doesn't work however the part for me does work?? Any suggestions?
Finally
Question 3:
Can anyone explain to me a good use of the CASE command to replace my many If this If that else commands.
Thanks alot in advance guys.
Jack
TheCleverGuyz