Post by Wayne Rayner on Sept 23, 2015 21:18:00 GMT -5
Hey guys,
So if you are a part of the Basic4GL facebook group then you may of seen the .zip of this game. It is an assignment for a IT subject using Visual Basic for Applications. I thought it would be cool to convert it to Basic4GL and with the help of Adam and Matthew on the facebook group.
Wayne's Wacky Golf
WWG is a text based golf game. It will feature 18 unique and fun holes with different lengths, decreased shot distance's, even increased shot distances and even in some holes adds a super driver for the very long holes.
Visit Wayne's Wacky Golf project page at my website here (while at my website look around and sign up i even have a forum
Downloads
Latest Version: 0.1.0 download the .exe here (size: 2.3mb)
Earlier Versions:
Golf Game Prototype (source code below) or .exe here (size: 2.3mb)
Version log
Version 0.1.0
- 3 different holes
- Scores all your shots for each hole
- calculates whether you were on under par (good), on par (average) or above par (bad).
Version 0.2.0
- 18 different holes
- Detailed stats at the end of the game for. (First 9 holes average, Last 9 holes average, Detailed hole stats such as hole one par 5 you took 4 shots)
Version 0.3.0
- Adds a top 10 local scoreboard
- Makes the game have buttons instead of relying on full text
Version 0.4.0 and up (Not Likely)
- Create your own course (9 or 18 holes)
- Multiplayer (local, against another player like your brother (has to be there physically)
- Multiplayer Online (very very unlikely but will have peer to peer networking and will allow you to search for online games.)
So here is the code for the golf game prototype.
Note: If code doesn't work I edited the code to have the same style as opposed to multiple code styles throughout the code.
So if you are a part of the Basic4GL facebook group then you may of seen the .zip of this game. It is an assignment for a IT subject using Visual Basic for Applications. I thought it would be cool to convert it to Basic4GL and with the help of Adam and Matthew on the facebook group.
Wayne's Wacky Golf
WWG is a text based golf game. It will feature 18 unique and fun holes with different lengths, decreased shot distance's, even increased shot distances and even in some holes adds a super driver for the very long holes.
Visit Wayne's Wacky Golf project page at my website here (while at my website look around and sign up i even have a forum
Downloads
Latest Version: 0.1.0 download the .exe here (size: 2.3mb)
Earlier Versions:
Golf Game Prototype (source code below) or .exe here (size: 2.3mb)
Version log
Version 0.1.0
- 3 different holes
- Scores all your shots for each hole
- calculates whether you were on under par (good), on par (average) or above par (bad).
Version 0.2.0
- 18 different holes
- Detailed stats at the end of the game for. (First 9 holes average, Last 9 holes average, Detailed hole stats such as hole one par 5 you took 4 shots)
Version 0.3.0
- Adds a top 10 local scoreboard
- Makes the game have buttons instead of relying on full text
Version 0.4.0 and up (Not Likely)
- Create your own course (9 or 18 holes)
- Multiplayer (local, against another player like your brother (has to be there physically)
- Multiplayer Online (very very unlikely but will have peer to peer networking and will allow you to search for online games.)
So here is the code for the golf game prototype.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Golf Game Prototype (UNI Assignment)
' Created by Wayne Rayner
' Version 0.1.0
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Global Variables
dim totalPar, totalShots, PlayerName, game
dim PlayerName as String
dim Option as string
' shot distance generator function
function shotDistance(clubrange#)
dim distance# = rnd() % 40
distance# = ((distance# * .01) + .8) * clubrange#
return distance#
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Golf Game Sub
Sub golfGame()
Dim holeDistance As Integer
Dim clubType As String
Dim distance As Integer
Dim shot As Integer
holeDistance = 230
shot = 0
While holeDistance <> 0
Printr "You are " + holeDistance + "m away from the hole"
Printr "which club will you select"
Printr "(D) Driver"
printr "(I) Iron"
Printr "(P) Putter"
input clubType
clubType = ucase$(clubType)
If clubType = "D"Then
shot = shot + 1
distance = shotDistance(100)
ElseIf clubType = "I" Then
shot = shot + 1
distance = shotDistance(30)
ElseIf clubType = "P" Then
shot = shot + 1
If holeDistance < 10 Then
distance = shotDistance(holeDistance)
Else
distance = shotDistance(10)
End If
Else
shot = shot + 1
distance = 0
End If
holeDistance = holeDistance - distance
If holeDistance < 0 Then
holeDistance = Abs(holeDistance)
End If
cls
printr "Your Shot went " + distance + "m"
printr "The distance to the hole is " + holeDistance + "m"
Printr "The hole par is 5 shots"
Printr "You have taken " + shot + " shot(s)"
Wend
cls
Printr "You got the ball in the hole in " + shot + " shots. The hole par was 5"
Printr "Would you like to play again? Y/N"
input option
option = ucase$(option)
If option = "Y" then
GolfGame()
ElseIf option = "N" Then
return
Else
print "invalid option please enter Y or N"
input option$
option = ucase$(option)
If option = "Y" then
GolfGame()
ElseIf option = "N" Then
return
EndIF
EndIf
End Sub
Sub Main()
dim menuType as string
cls
Printr "Hello " + playerName$ + " What would you like to do?"
Printr "(I)Instructions"
Printr "(P)Play Golf Game"
Printr "(Q)Quit"
input menuType
menuType = ucase$(menuType)
If menuType = "I" then
cls
printr "You are playing a game of golf"
Printr "There are 18 holes"
Printr "Each hole has a par"
Printr "You have 3 clubs to choose from"
Printr "The driver which covers the most distance"
Printr "The iron which is around a third of the driver"
Printr "The putter which is around 10% of the driver"
Sleep(5000)
cls
main()
ElseIf menuType = "P" then
cls
golfGame()
ElseIf menuType = "Q" then
cls
Printr "Thank you " + PlayerName " For playing golf"
Printr "Hope you enjoyed it"
game = 0
end
Else
Print "Invalid Menu option please try again"
Sleep (2000)
Main()
EndIF
End Sub
game = 1
printr"Please tell us your name?"
input playerName
while game = 1
Main()
Wend
Note: If code doesn't work I edited the code to have the same style as opposed to multiple code styles throughout the code.