Está en la página 1de 50

Ateneo de Davao University Jacinto St.

, Davao City Engineering and Architecture Division

CpE 310 ObjectOriented Programming

The Pirate Quest

Programmed and Submitted By: Jhunorjim Zandueta Jolu Ezra O. Zamudio BSComputer Engineering 3 Submitted to: Engr. Edicio Faller, MIT

The Program: The task was to create a program that is educational and entertaining, thus it is an edutainment game. The program was created using the software, Visual Basic .Net. The program is mainly a flash game. Like the games that we commonly play on free gaming sites on the internet. For example: Dragon Fable. Content of the Game: The program is an adventure type game. Where the player has a certain storyline to follow, and accomplish certain achievements. The programs theme is about pirates, so the game would focus on travel and treasure hunting. The player also gets to choose his/her avatar and pirate ship. The players score is determined once the game is completed. In order to advance through the game, the player needs to answer a series of questions to attain the treasure. The questions vary from science, math, history, about other video games and general knowledge. The player would venture on locations on a treasure map. This is done by rolling a dice and moves a number of spaces on the treasure map. The rolling dice concept was taken from the Snake and Ladders board game. These locations are islands and that the name of each location and each treasure were taken from other video games. The names were taken from games and anime shows, Devil May Cry, Golden Sun and Code Geass. Synopsis the Game: The video game is entitled, The Pirate Quest: The Search for Captain Jacks Treasure. As what says on the games title, this is about treasure hunting. The player takes the role of an ordinary person who happens to stumble upon a treasure map and has the locations of Captain Jacks treasures. With the map in hand, the protagonist sets out on a journey to locate all the treasures. However it wont be easy to get a treasure. The player needs to answer a question before the treasure can be attained.

Software and Hardware Requirements: - .NET 4 Framework - Windows Installer 3.1 (Included) - Adobe Flash Player/Plug-In - 1Gb of RAM - 1GHz processor or better - 50Mb Free Hard Disk Space - Speakers

Source Code: Form1.vb: Public Class frmTitleWindow Dim sec As Integer Private Sub frmTitleWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load proc_deletefiles() My.Computer.FileSystem.CreateDirectory("C:\Program Files\The Pirate Quest\Gamedata\Flash") My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\red.swf", My.Resources.flash_splash, False) flash.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\red.swf" End Sub Private Sub btnplay_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplay.MouseLeave btnexit.Image = My.Resources.but_exit btnplay.Image = My.Resources.but_play btnoptions.Image = My.Resources.but_options End Sub Private Sub btnoptions_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnoptions.MouseLeave btnexit.Image = My.Resources.but_exit btnplay.Image = My.Resources.but_play btnoptions.Image = My.Resources.but_options End Sub Private Sub btnexit_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.MouseLeave btnexit.Image = My.Resources.but_exit btnplay.Image = My.Resources.but_play btnoptions.Image = My.Resources.but_options

End Sub Private Sub btnplay_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplay.MouseHover btnplay.Image = My.Resources.but_play_sel End Sub Private Sub btnoptions_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnoptions.MouseHover btnoptions.Image = My.Resources.but_options_sel End Sub Private Sub btnexit_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.MouseHover btnexit.Image = My.Resources.but_exit_sel End Sub Private Sub btnplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplay.MouseClick btnplay.Visible = False btnexit.Visible = False btnoptions.Visible = False tmrfade.Start() End Sub Private Sub tmrfade_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrfade.Tick sec = sec + 1 If sec = 2 Then frmSelectQuest.Show() My.Computer.FileSystem.DeleteFile("C:\Program Files\The Pirate Quest\Gamedata\Flash\main.swf") Me.Close() End If End Sub

Private Sub tmrbtn_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrbtn.Tick sec = sec + 1 If sec = 6 Then btnplay.Visible = True btnoptions.Visible = True btnexit.Visible = True sec = 0 tmrbtn.Stop() End If End Sub Private Sub tmrscreen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrscreen.Tick sec = sec + 1 If sec = 1 Then My.Computer.Audio.Stop() If sec = 11 Then sec = 0 My.Computer.FileSystem.CreateDirectory("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo") My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\main.swf", My.Resources.flash_titlewindow, False) flash.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\main.swf" My.Computer.Audio.Play(My.Resources.main, AudioPlayMode.BackgroundLoop) tmrbtn.Start() tmrscreen.Stop() End If End Sub Private Sub btnoptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnoptions.Click 'insert option line here.. End Sub Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click End End Sub Sub proc_deletefiles()

If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo\PirateInfo.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo\PirateInfo.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\status.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\status.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") End Sub End Class frmSelectQuest.vb: Public Class frmTitleWindow Dim sec As Integer Private Sub frmTitleWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load proc_deletefiles() My.Computer.FileSystem.CreateDirectory("C:\Program Files\The Pirate Quest\Gamedata\Flash") My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\red.swf", My.Resources.flash_splash, False)

flash.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\red.swf" End Sub Private Sub btnplay_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplay.MouseLeave btnexit.Image = My.Resources.but_exit btnplay.Image = My.Resources.but_play btnoptions.Image = My.Resources.but_options End Sub Private Sub btnoptions_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnoptions.MouseLeave btnexit.Image = My.Resources.but_exit btnplay.Image = My.Resources.but_play btnoptions.Image = My.Resources.but_options End Sub Private Sub btnexit_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.MouseLeave btnexit.Image = My.Resources.but_exit btnplay.Image = My.Resources.but_play btnoptions.Image = My.Resources.but_options End Sub Private Sub btnplay_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplay.MouseHover btnplay.Image = My.Resources.but_play_sel End Sub Private Sub btnoptions_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnoptions.MouseHover btnoptions.Image = My.Resources.but_options_sel End Sub Private Sub btnexit_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.MouseHover

btnexit.Image = My.Resources.but_exit_sel End Sub Private Sub btnplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplay.MouseClick btnplay.Visible = False btnexit.Visible = False btnoptions.Visible = False tmrfade.Start() End Sub Private Sub tmrfade_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrfade.Tick sec = sec + 1 If sec = 2 Then frmSelectQuest.Show() My.Computer.FileSystem.DeleteFile("C:\Program Files\The Pirate Quest\Gamedata\Flash\main.swf") Me.Close() End If End Sub Private Sub tmrbtn_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrbtn.Tick sec = sec + 1 If sec = 6 Then btnplay.Visible = True btnoptions.Visible = True btnexit.Visible = True sec = 0 tmrbtn.Stop() End If End Sub Private Sub tmrscreen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrscreen.Tick sec = sec + 1 If sec = 1 Then My.Computer.Audio.Stop() If sec = 11 Then

sec = 0 My.Computer.FileSystem.CreateDirectory("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo") My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\main.swf", My.Resources.flash_titlewindow, False) flash.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\main.swf" My.Computer.Audio.Play(My.Resources.main, AudioPlayMode.BackgroundLoop) tmrbtn.Start() tmrscreen.Stop() End If End Sub Private Sub btnoptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnoptions.Click 'insert option line here.. End Sub Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click End End Sub Sub proc_deletefiles() If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo\PirateInfo.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo\PirateInfo.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt")

If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\status.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\status.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") End Sub End Class frmGameProper: Public Class frmGameProper '*'Variables that handle FinishQuestion.txt'*' '*'FinishQuestion.txt is a list of integers that represent the questions already asked"*" '**************************** Dim write_finish As IO.StreamWriter Dim read_finish As IO.StreamReader Dim create_finish As IO.StreamWriter '**************************** '*'Variable that handle QuestionNumber.txt'*' '*'QuestionNumber.txt holds an integer that represent the question number to be asked."*" '*'The question number is generated using the randomize/random function'*' '**************************** Dim create_Qnumber As IO.StreamWriter '**************************** '*'Holds the integer result of the randomize/random function'*' '*'The result represents the question number to be asked'*' '**************************** Dim question_number As String '**************************** '*'A switch that is used to identify if the QUESTION NUMBER randomize/random function is to be executed again '*' '*"It performs the randomize/random function when its value is 1 '*' '*'Its value (0 or 1 ) is assigned after seeing to it that the number generated is not on FinishQuestion.txt list'*'

'**************************** Dim question_verify As Integer = 1 '**************************** '*'Variable that handles NumberofMistakes.txt'*' '*'NumberofMistakes.txt holds an integer that represents the number of mistakes made by the user'*' '*'This file is read by another form to determine if the program is to be closed.'*' '**************************** Dim create_mistake As IO.StreamWriter '**************************** '========== '-00-important files above-00-'========' '*'A variable that holds the result of the randomize/random funnction for the dice roll result'*' '*'Used to identify the final image to be displayed in pctrbxdice'*' '*'Used to identify how many times the flash file should play'*' '**************************** Dim roll As Integer '**************************** '*'A variable used in a timer to identify the number of seconds passed'*' '**************************** Dim sec As Integer '**************************** '*'Variable used to identify the current position of the ship in the map'*' '*'Minimum position is 0 (start) and maximum is 38 (end)'*' '**************************** Dim position As Integer = 0 '**************************** '*'Variable used in the manipulation of the image in pctrbxdice'*' '**************************** Dim dicevar1, dicevar2 As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim read_profile As IO.StreamReader '*'Variable that handles PirateInfo.txt '*'PirateInfo.txt contains information about the avatar, name and ship to be displayed

Dim Pname As String '*'Holds the information about the inputed user name '*'Value contained taken from PirateInfo.txt' Dim ship As Integer '*'Holds the information about the chosen ship '*'Value contained taken from PirateInfo.txt' Dim avatar As Integer '*'Holds the information about the chosen avatar '*'Value contained taken from PirateInfo.txt' '!!Creation FinishQuestion.txt file If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") create_finish = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") create_finish.Close() '!!Creation NumberofMistakes.txt file If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") create_mistake = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") create_mistake.WriteLine(0) create_mistake.Close() '!!Reading PirateInfo.txt read_profile = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo\PirateInfo.txt") Pname = read_profile.ReadLine() '] avatar = read_profile.ReadLine ']--> Variable assignment (Pname,avatar,ship) ship = read_profile.ReadLine '] read_profile.Close() '!!Ship Identification and Resource Export If ship = 1 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_black, False) If ship = 2 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_blue, False) If ship = 3 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_green, False) If ship = 4 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_orange, False) If ship = 5 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_pink, False) If ship = 6 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_red, False)

If ship = 7 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_violet, False) If ship = 8 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_white, False) flash.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf" '!! Exported file is read and assigned to flash component flash.Stop() '!!Resource Export for flash instructions My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\instructions.swf", My.Resources.flash_instructions, False) flashIns.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\instructions.swf" '!! Exported file is read and assigned to flash component (The flash file is an instruction/hint about the game) '!!Image for PctrbxAvatar is made If avatar = 1 Then pctrbxAvatar.BackgroundImage = My.Resources.av1 If avatar = 2 Then pctrbxAvatar.BackgroundImage = My.Resources.av2 If avatar = 3 Then pctrbxAvatar.BackgroundImage = My.Resources.av3 If avatar = 4 Then pctrbxAvatar.BackgroundImage = My.Resources.av4 If avatar = 5 Then pctrbxAvatar.BackgroundImage = My.Resources.av5 If avatar = 6 Then pctrbxAvatar.BackgroundImage = My.Resources.av6 If avatar = 7 Then pctrbxAvatar.BackgroundImage = My.Resources.av7 If avatar = 8 Then pctrbxAvatar.BackgroundImage = My.Resources.av8 If avatar = 9 Then pctrbxAvatar.BackgroundImage = My.Resources.av9 '!!User name is displayed grpTreasures.Text = Pname & "'s Treasure Chest" '!!Audio played from past form is stopped and new audio is played My.Computer.Audio.Stop() proc_audio() End Sub Private Sub btnrolldice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrolldice.Click '!!Reading of SetPosition.txt and Setting of Ship's Position If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") = True Then Dim read_Setposition As IO.StreamReader = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") position = read_Setposition.ReadLine() read_Setposition.Close() IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt")

End If '*******' 'Note: SetPostion.txt is a file created from another form. It sets the new position a the ship due to a wrong user answer '*******' btnrolldice.Visible = False btnquit.Visible = False '!!TIMER tmrdicepic is started. tmrdicepic controls the dynamics of the picture changing in the pctrbxdice tmrdicepic.Start() '!!Randomize function is executed Randomize() roll = CInt(Int(6 * Rnd()) + 1) ']---> Variable assignment End Sub Private Sub tmrdicepic_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrdicepic.Tick '!!variable dicevar1 is incremented by 1; each dicevar1 value displays a different dice image found in my.reosurces dicevar1 = dicevar1 + 1 If dicevar1 = 1 Then pctrbxdice.Image = My.Resources.d1 If dicevar1 = 2 Then pctrbxdice.Image.Dispose() If dicevar1 = 3 Then pctrbxdice.Image = My.Resources.d2 If dicevar1 = 4 Then pctrbxdice.Image.Dispose() If dicevar1 = 5 Then pctrbxdice.Image = My.Resources.d3 If dicevar1 = 6 Then pctrbxdice.Image.Dispose() If dicevar1 = 7 Then pctrbxdice.Image = My.Resources.d4 If dicevar1 = 8 Then pctrbxdice.Image.Dispose() If dicevar1 = 9 Then pctrbxdice.Image = My.Resources.d5 If dicevar1 = 10 Then pctrbxdice.Image.Dispose() If dicevar1 = 11 Then pctrbxdice.Image = My.Resources.d6 If dicevar1 = 12 Then pctrbxdice.Image.Dispose() If dicevar1 = 13 Then dicevar2 is incremented by 1 dicevar2 = dicevar2 + 1 dicevar1 = 1 End If '*At dicevar1 = 13, dicevar is returned to 1 and

If dicevar2 = 5 Then

'*At dicevar2 = 5, the final dice image is displayed

If roll = 1 Then pctrbxdice.Image = My.Resources.d1 If roll = 2 Then pctrbxdice.Image = My.Resources.d2 If roll = 3 Then pctrbxdice.Image = My.Resources.d3 If roll = 4 Then pctrbxdice.Image = My.Resources.d4 If roll = 5 Then pctrbxdice.Image = My.Resources.d5 If roll = 6 Then pctrbxdice.Image = My.Resources.d6 tmrdicepic.Stop() '*The timer is stoped proc_PASTposition() '*The position of the ship, before it moves to its new position, is taken. This is called PAST Position tmrsteps.Start() '*tmrsteps is started and the flash is played dicevar1 = 0 dicevar2 = 0 End If End Sub Private Sub btnquit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnquit.Click Dim writeStatus As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\status.txt") writeStatus.WriteLine("Quit") writeStatus.Close() frmmsg.ShowDialog() End Sub Private Sub tmrsteps_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrsteps.Tick '!!flash file is played If sec = 0 Then flash.Play() '!!sec is incremented sec = sec + 1 '!!Procedure Position is called proc_Position() ']Variables are ']refreshed

'!!When the number of seconds (ship movement) is equal to the result of the dice roll If sec = roll + 1 Then position = position - 1 proc_CURRENTposition() '* The Current Position of the ship is taken tmrsteps.Stop() flash.Stop() proc_AskQuestion() '* The Timer is stopeed '* A Question is asked

flashIns.Visible = True grpPosition.Visible = False End If End Sub

'*****************'Procedures are found below this line'********************' Sub proc_PASTposition() '!! This procedure writes down the PAST Position of the ship. (BEFORE the ship moved from its original position) Dim create_PASTposition As IO.StreamWriter create_PASTposition = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") create_PASTposition.WriteLine(position) create_PASTposition.Close() End Sub Sub proc_Position() '!! This procedure modifies and displays the varible position. '!! Position represents the position of the ship on the map. proc_Position is invoked at every tick of the step timer flashIns.Visible = False grpPosition.Visible = True position = position + 1 If position < 10 Then lblPosition.Text = "0" & position Else lblPosition.Text = position If position = 39 Then sec = roll + 1 End If

End Sub Sub proc_CURRENTposition() '!! This procedure writes down the CURRENT Position of the ship. (AFTER the ship moved from its original position) Dim create_CURRENTposition As IO.StreamWriter create_CURRENTposition = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") create_CURRENTposition.WriteLine(position) create_CURRENTposition.Close() End Sub Sub proc_AskQuestion() '!! This procedure: '1.) Randomizes a range of numbers and assign it to question_number '2.) Checks if the generated random number is already in the FinishQuestion.txt list (If it number is on the list, it randomize and generates again '3) Updates the FinishQuestion.txt list by adding the generated number not on the list '4) Writes down the question number generated. This number represents the Question file name to be asked '5) Opens the form that will display the question Do While question_verify = 1 '1 Randomize() question_number = CInt(Int(218 * Rnd()) + 1) ''dagdagan pa ng questions question_verify = 0 '2 read_finish = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") Do Until read_finish.EndOfStream = True If question_number = read_finish.ReadLine() Then question_verify = 1 Loop read_finish.Close() Loop '3 write_finish = IO.File.AppendText("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") write_finish.WriteLine(question_number) write_finish.Close()

'4 If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") create_Qnumber = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") create_Qnumber.WriteLine(question_number) create_Qnumber.Close() sec = 0 question_verify = 1 '5 dlgQuestion.Show() End Sub Sub proc_audio() '!! This procedure generates a number and assign it to a variable. The value assigned to the said variable represents audio files from my.resources to be played in loop in the background Dim audio_variable As Integer Randomize() audio_variable = CInt(Int(3 * Rnd()) + 1) If audio_variable = 1 Then My.Computer.Audio.Play(My.Resources.wav1, AudioPlayMode.BackgroundLoop) If audio_variable = 2 Then My.Computer.Audio.Play(My.Resources.wav2, AudioPlayMode.BackgroundLoop) If audio_variable = 3 Then My.Computer.Audio.Play(My.Resources.wav3, AudioPlayMode.BackgroundLoop) End Sub Sub proc_deletefiles() 'all created txt files are deleted when window is closed If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt")

If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\FinishQuestion.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo\PirateInfo.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\PlayerInfo\PirateInfo.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\status.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\status.txt") If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") End Sub '------' Private Sub frmGameProper_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed proc_deletefiles() frmmsg.Close() dlgQuestion.Close() My.Computer.Audio.Stop() End Sub End Class dlgQuestion: Imports System.Windows.Forms

Public Class dlgQuestion '*'Variable that handles QuestionNumber.txt'*' '*QuestionNumber.txt holds an integer that identifies the question number to be asked'*' Dim readQuestionNumber As IO.StreamReader '*'Variables that handle NumberofMistakes.txt'*' '*'NumberofMistakes.txt holds an integer value identifies wether the user has reached the allowable wrong answers'*' Dim readmistake As IO.StreamReader Dim createmistake As IO.StreamWriter '*'Variables that handles CURRENTPosition.txt and PASTPosition.txt'*' '*'These text files holds integers that indicates the position of the ship before and after dice roll'*' Dim readPASTposition As IO.StreamReader Dim readCURRENTposition As IO.StreamReader '*'Variables that handle numberTreasure.txt'*' '*numberTreasure.txt holds an integer value that indicates the number of treasure collected'*' Dim writeNumberTreasure As IO.StreamWriter Dim readNumberTreasure As IO.StreamReader '*'Variable that handles status.txt'*' '*'status.txt holds a string that indicates wether the answer given is "Correct" or "Wrong" or wether "Times Up" or if the user want to "Quit" or "Game Over" Dim writeStatus As IO.StreamWriter Dim question_number As Integer Dim mistake As Integer Dim PASTposition As Integer Dim CURRENTposition As Integer Dim numberTreasure As Integer Dim FoundTreasure As Boolean = False 'this boolean variable is switch to True if the ship landed in a position with treasure Dim answer As String Dim sec As Integer Dim counter As Integer Private Sub dlgQuestion_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

readQuestionNumber = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\QuestionNumber.txt") question_number = readQuestionNumber.ReadLine() readQuestionNumber.Close() If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") = False Then writeNumberTreasure = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") writeNumberTreasure.WriteLine(0) writeNumberTreasure.Close() End If Dim Question() As String = My.Resources.Questions.Split(vbNewLine) Dim QuestionData() As String = Question(question_number).Split("|") rtxtbx.Text = QuestionData(1) btnA.Text = QuestionData(2) btnB.Text = QuestionData(3) btnC.Text = QuestionData(4) btnD.Text = QuestionData(5) answer = QuestionData(6) sec = 10 proc_treasures() tmrCountdown.Start() End Sub Private Sub btnA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnA.Click If answer = "A" Then pro_corect() Else proc_wrong() End Sub Private Sub btnB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnB.Click If answer = "B" Then pro_corect() Else proc_wrong() End Sub Private Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnC.Click If answer = "C" Then pro_corect() Else proc_wrong()

End Sub Private Sub btnD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnD.Click If answer = "D" Then pro_corect() Else proc_wrong() End Sub Private Sub tmrCountdown_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrCountdown.Tick If sec < 10 Then lbltimer.Text = "0" & sec Else lbltimer.Text = sec sec = sec - 1 If sec = -1 Then proc_timesup() End Sub Sub pro_corect() Me.Close() tmrCountdown.Stop() frmGameProper.btnrolldice.Visible = True frmGameProper.btnquit.Visible = True proc_treasures() writeStatus = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\status.txt") writeStatus.WriteLine("Correct") writeStatus.Close() frmmsg.ShowDialog() End Sub Sub proc_wrong() Me.Close() tmrCountdown.Stop() readCURRENTposition = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") CURRENTposition = readCURRENTposition.ReadLine readCURRENTposition.Close()

readPASTposition = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") PASTposition = readPASTposition.ReadLine readPASTposition.Close() If mistake < 5 Then writeStatus = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\status.txt") writeStatus.WriteLine("Wrong") writeStatus.WriteLine(CURRENTposition - PASTposition) writeStatus.Close() frmmsg.ShowDialog() frmGameProper.btnrolldice.Visible = True frmGameProper.btnquit.Visible = True End If proc_mistake() End Sub Sub proc_timesup() Me.Close() frmGameProper.BringToFront() tmrCountdown.Stop() readCURRENTposition = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") CURRENTposition = readCURRENTposition.ReadLine readCURRENTposition.Close() readPASTposition = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") PASTposition = readPASTposition.ReadLine readPASTposition.Close() writeStatus = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\status.txt") writeStatus.WriteLine("Times Up") writeStatus.WriteLine(CURRENTposition - PASTposition) writeStatus.Close()

frmmsg.ShowDialog() frmGameProper.btnrolldice.Visible = True frmGameProper.btnquit.Visible = True proc_mistake() End Sub Sub proc_treasures() counter = counter + 1 If counter = 1 Then readCURRENTposition = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") CURRENTposition = readCURRENTposition.ReadLine readCURRENTposition.Close() If CURRENTposition = 4 Or CURRENTposition = 12 Or CURRENTposition = 17 Or CURRENTposition = 18 Or CURRENTposition = 21 Or CURRENTposition = 22 Or CURRENTposition = 24 Or CURRENTposition = 28 Or CURRENTposition = 30 Or CURRENTposition = 33 Or CURRENTposition = 35 Or CURRENTposition = 38 Then FoundTreasure = True flashX.Visible = True My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\xmark.swf", My.Resources.flash_xmark, False) flashX.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\xmark.swf" End If End If If counter = 2 Then If FoundTreasure = True Then readNumberTreasure = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") numberTreasure = readNumberTreasure.ReadLine() + 1 readNumberTreasure.Close() IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") writeNumberTreasure = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\numberTreasure.txt") writeNumberTreasure.WriteLine(numberTreasure) writeNumberTreasure.Close()

frmTREASURES.ShowDialog() If CURRENTposition = 4 Then frmGameProper.pctrbxT1.Image = My.Resources.TR1 If CURRENTposition = 12 Then frmGameProper.pctrbxT2.Image = My.Resources.TR2 If CURRENTposition = 17 Then frmGameProper.pctrbxT3.Image = My.Resources.TR3 If CURRENTposition = 18 Then frmGameProper.pctrbxT4.Image = My.Resources.TR4 If CURRENTposition = 21 Then frmGameProper.pctrbxT5.Image = My.Resources.TR5 If CURRENTposition = 22 Then frmGameProper.pctrbxT6.Image = My.Resources.TR6 If CURRENTposition = 24 Then frmGameProper.pctrbxT7.Image = My.Resources.TR7 If CURRENTposition = 28 Then frmGameProper.pctrbxT8.Image = My.Resources.TR8 If CURRENTposition = 30 Then frmGameProper.pctrbxT9.Image = My.Resources.TR9 If CURRENTposition = 33 Then frmGameProper.pctrbxT10.Image = My.Resources.TR10 If CURRENTposition = 35 Then frmGameProper.pctrbxT11.Image = My.Resources.TR11 If CURRENTposition = 38 Then frmGameProper.pctrbxT12.Image = My.Resources.TR12 FoundTreasure = False End If End If End Sub Sub proc_mistake() readmistake = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") mistake = readmistake.ReadLine() + 1 readmistake.Close() IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") createmistake = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\NumberofMistakes.txt") createmistake.WriteLine(mistake) createmistake.Close()

If mistake = 1 Then frmGameProper.pctrChance5.BackgroundImage = My.Resources.x_mistake If mistake = 2 Then frmGameProper.pctrChance4.BackgroundImage = My.Resources.x_mistake If mistake = 3 Then frmGameProper.pctrChance3.BackgroundImage = My.Resources.x_mistake If mistake = 4 Then frmGameProper.pctrChance2.BackgroundImage = My.Resources.x_mistake If mistake = 5 Then frmGameProper.pctrChance1.BackgroundImage = My.Resources.x_mistake If mistake = 5 Then writeStatus = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\status.txt") writeStatus.WriteLine("Game Over") writeStatus.Close() Me.Close() frmmsg.ShowDialog() Else proc_Shipgoback() End If End Sub Sub proc_Shipgoback() readPASTposition = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt") PASTposition = readPASTposition.ReadLine readPASTposition.Close() If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") = True Then IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") Dim createSetposition As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SetPosition.txt") createSetposition.WriteLine(PASTposition) createSetposition.Close() frmGameProper.flash.GotoFrame(PASTposition * 20) IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\PASTPosition.txt")

End Sub End Class frmTREASURES: Public Class frmTREASURES Dim sec As Integer Private Sub tmrshow_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrshow.Tick sec = sec + 1 If sec = 10 Then Me.Close() My.Computer.Audio.Stop() Dim audio_variable As Integer Randomize() audio_variable = CInt(Int(3 * Rnd()) + 1) If audio_variable = 1 Then My.Computer.Audio.Play(My.Resources.wav1, AudioPlayMode.BackgroundLoop) If audio_variable = 2 Then My.Computer.Audio.Play(My.Resources.wav2, AudioPlayMode.BackgroundLoop) If audio_variable = 3 Then My.Computer.Audio.Play(My.Resources.wav3, AudioPlayMode.BackgroundLoop) sec = 0 End If End Sub Private Sub frmTREASURES_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim readCURRENTPosition As IO.StreamReader Dim currentposition As Integer My.Computer.Audio.Stop() My.Computer.Audio.Play(My.Resources.interlude, AudioPlayMode.BackgroundLoop) My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\Treasure.swf", My.Resources.flash_treasures, False) flashTreasure.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\Treasure.swf" readCURRENTPosition = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\CURRENTPosition.txt") currentposition = readCURRENTPosition.ReadLine() readCURRENTPosition.Close()

If currentposition = 4 Then flashTreasure.GotoFrame(1) If currentposition = 12 Then flashTreasure.GotoFrame(81) If currentposition = 17 Then flashTreasure.GotoFrame(161) If currentposition = 18 Then flashTreasure.GotoFrame(241) If currentposition = 21 Then flashTreasure.GotoFrame(321) If currentposition = 22 Then flashTreasure.GotoFrame(401) If currentposition = 24 Then flashTreasure.GotoFrame(481) If currentposition = 28 Then flashTreasure.GotoFrame(561) If currentposition = 30 Then flashTreasure.GotoFrame(641) If currentposition = 33 Then flashTreasure.GotoFrame(721) If currentposition = 35 Then flashTreasure.GotoFrame(801) If currentposition = 38 Then flashTreasure.GotoFrame(881) flashTreasure.Play() End Sub End Class frmSM_Gameproper: Public Class frmSM_Gameproper Dim flash_variable As Integer Dim seaEvent_variable As Integer Dim script_position() As Integer = {4, 12, 17, 18, 21, 22, 24, 28, 30, 33, 35, 38} Dim N As Integer = 0 Dim wait As Integer = 0 Dim position As Integer = 0 Dim sec As Integer Private Sub frmStoryMode_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load My.Computer.FileSystem.CreateDirectory("C:\Program Files\The Pirate Quest\Gamedata\SM") proc_audio() Dim write_CurrentPosition As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\CURRENTPosition.txt") write_CurrentPosition.WriteLine(0) write_CurrentPosition.Close() Dim write_NumberofMistakes As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\NumberofMistakes.txt")

write_NumberofMistakes.WriteLine(0) write_NumberofMistakes.Close() Dim write_NumberofTreasures As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\NumberofTreasure.txt") write_NumberofTreasures.WriteLine(0) write_NumberofTreasures.Close() Dim write_Status As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status.WriteLine("Intro") write_Status.Close() frmSM_Script.ShowDialog() Randomize() flash_variable = CInt(Int(8 * Rnd()) + 1) If flash_variable = 1 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_black, False) If flash_variable = 2 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_blue, False) If flash_variable = 3 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_green, False) If flash_variable = 4 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_orange, False) If flash_variable = 5 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_pink, False) If flash_variable = 6 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_red, False) If flash_variable = 7 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_violet, False) If flash_variable = 8 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf", My.Resources.flash_white, False) flash.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\flash.swf" '!! Exported file is read and assigned to flash component flash.Stop() End Sub Private Sub btnbegin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbegin.Click btnbegin.Visible = False tmrsteps.Start()

End Sub Private Sub tmrsteps_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrsteps.Tick wait = wait + 1 If wait = 2 Then flash.Play() grpPosition.Visible = True End If If wait >= 2 Then proc_position() If position = script_position(N) + 1 Then tmrsteps.Stop() flash.Stop() grpPosition.Visible = False position = position - 1 N=N+1 wait = 0 proc_GETPosition() proc_Story() Else proc_SeaEvent() End If End If End Sub

Sub proc_position()

position = position + 1 If position < 10 Then lblPosition.Text = "0" & position Else lblPosition.Text = position

End Sub Sub proc_GETPosition() IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SM\CURRENTPosition.txt") Dim create_CURRENTposition As IO.StreamWriter create_CURRENTposition = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\CURRENTPosition.txt") create_CURRENTposition.WriteLine(position) create_CURRENTposition.Close() End Sub Sub proc_Story() IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") frmSM_Script.ShowDialog() End Sub Sub proc_SeaEvent() Dim write_SeaEventumber As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") Randomize() seaEvent_variable = CInt(Int(40 * Rnd()) + 1) If seaEvent_variable = 3 Then position = position - 1 If position < 10 Then lblPosition.Text = "0" & position Else lblPosition.Text = position flash.Stop() tmrsteps.Stop() wait = 0 write_SeaEventumber.WriteLine(3) write_SeaEventumber.Close() frmSM_msg.ShowDialog()

End If If seaEvent_variable = 5 Then position = position - 1 If position < 10 Then lblPosition.Text = "0" & position Else lblPosition.Text = position flash.Stop() tmrsteps.Stop() wait = 0 write_SeaEventumber.WriteLine(5) write_SeaEventumber.Close() frmSM_msg.ShowDialog() End If If seaEvent_variable = 7 Then position = position - 1 If position < 10 Then lblPosition.Text = "0" & position Else lblPosition.Text = position flash.Stop() tmrsteps.Stop() wait = 0 write_SeaEventumber.WriteLine(7) write_SeaEventumber.Close() frmSM_msg.ShowDialog() End If If seaEvent_variable = 15 Then position = position - 1 If position < 10 Then lblPosition.Text = "0" & position Else lblPosition.Text = position flash.Stop() tmrsteps.Stop() wait = 0 write_SeaEventumber.WriteLine(15) write_SeaEventumber.Close() frmSM_msg.ShowDialog() End If write_SeaEventumber.Close() End Sub Private Sub btnquit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnquit.Click Me.Close() frmTitleWindow.Show() End Sub

Sub proc_audio() '!! This procedure generates a number and assign it to a variable. The value assigned to the said variable represents audio files from my.resources to be played in loop in the background Dim audio_variable As Integer Randomize() audio_variable = CInt(Int(4 * Rnd()) + 1) If audio_variable = 1 Then My.Computer.Audio.Play(My.Resources.sm1, AudioPlayMode.BackgroundLoop) If audio_variable = 2 Then My.Computer.Audio.Play(My.Resources.sm2, AudioPlayMode.BackgroundLoop) If audio_variable = 3 Then My.Computer.Audio.Play(My.Resources.sm3, AudioPlayMode.BackgroundLoop) If audio_variable = 4 Then My.Computer.Audio.Play(My.Resources.sm4, AudioPlayMode.BackgroundLoop) End Sub End Class frmSM_dlgQuestion: Public Class frmSM_dlgQuestion Dim NumberofTreasure As Integer Dim NumberofMistake As Integer Dim question_number As Integer Dim answer As String Dim position As Integer Dim sec As Integer = 11 Private Sub frmSM_dlgQuestion_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Randomize() question_number = CInt(Int(188 * Rnd()) + 1) Dim Question() As String = My.Resources.Questions.Split(vbNewLine) Dim QuestionData() As String = Question(question_number).Split("|") rtxtbx.Text = QuestionData(1)

btnA.Text = QuestionData(2) btnB.Text = QuestionData(3) btnC.Text = QuestionData(4) btnD.Text = QuestionData(5) answer = QuestionData(6) Dim read_CurrentPosition As IO.StreamReader = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\SM\CURRENTPosition.txt") position = read_CurrentPosition.ReadLine() read_CurrentPosition.Close() tmrCountdown.Start() End Sub Private Sub btnA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnA.Click If answer = "A" Then proc_correct() Else proc_wrong() End Sub Private Sub btnB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnB.Click If answer = "B" Then proc_correct() Else proc_wrong() End Sub Private Sub btnD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnD.Click If answer = "D" Then proc_correct() Else proc_wrong() End Sub Private Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnC.Click If answer = "C" Then proc_correct() Else proc_wrong() End Sub Sub proc_correct() tmrCountdown.Stop() sec = 11 Dim write_Status As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status.WriteLine("Correct") write_Status.Close() proc_treasures()

End Sub Sub proc_wrong() tmrCountdown.Stop() sec = 11 Dim write_Status As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status.WriteLine("Wrong") write_Status.Close() proc_mistake() lbltimer.Text = 10 Me.Close() If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") = True Then Dim write_Status2 As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") frmSM_Gameproper.tmrsteps.Start() write_Status2.WriteLine("Intro") write_Status2.Close() End If If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") = False Then frmSM_Script.ShowDialog() End If

End Sub Sub proc_TimesUp() Dim write_Status As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status.WriteLine("Times Up") write_Status.Close() proc_mistake() lbltimer.Text = 10 Me.Close()

If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") = True Then frmSM_Gameproper.tmrsteps.Start() Dim write_Status2 As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status2.WriteLine("Intro") write_Status2.Close() End If If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") = False Then frmSM_Script.ShowDialog() End If End Sub Sub proc_treasures() Dim read_NumberofTreasure As IO.StreamReader = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\SM\NumberofTreasure.txt") NumberofTreasure = read_NumberofTreasure.ReadLine() + 1 read_NumberofTreasure.Close() IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SM\NumberofTreasure.txt") Dim write_NumberofTreasure As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\NumberofTreasure.txt") write_NumberofTreasure.WriteLine(NumberofTreasure) write_NumberofTreasure.Close() If position = 4 Then frmSM_Gameproper.pctrbxT1.BackgroundImage = My.Resources.smT1 If position = 12 Then frmSM_Gameproper.pctrbxT2.BackgroundImage = My.Resources.smT2 If position = 17 Then frmSM_Gameproper.pctrbxT3.BackgroundImage = My.Resources.smT3 If position = 18 Then frmSM_Gameproper.pctrbxT4.BackgroundImage = My.Resources.smT4 If position = 21 Then frmSM_Gameproper.pctrbxT5.BackgroundImage = My.Resources.smT5 If position = 22 Then frmSM_Gameproper.pctrbxT6.BackgroundImage = My.Resources.smT6

If position = 24 Then frmSM_Gameproper.pctrbxT7.BackgroundImage = My.Resources.smT7 If position = 28 Then frmSM_Gameproper.pctrbxT8.BackgroundImage = My.Resources.smT8 If position = 30 Then frmSM_Gameproper.pctrbxT9.BackgroundImage = My.Resources.smT9 If position = 33 Then frmSM_Gameproper.pctrbxT10.BackgroundImage = My.Resources.smT11 If position = 35 Then frmSM_Gameproper.pctrbxT11.BackgroundImage = My.Resources.smT12 If position = 38 Then frmSM_Gameproper.pctrbxT12.BackgroundImage = My.Resources.smT10 lbltimer.Text = 10 Me.Close() If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") = True Then frmSM_Gameproper.tmrsteps.Start() Dim write_Status As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status.WriteLine("Intro") write_Status.Close() End If If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") = False Then frmSM_Script.ShowDialog() End If End Sub Sub proc_mistake() Dim read_NumberofMistake As IO.StreamReader = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\SM\NumberofMistakes.txt") NumberofMistake = read_NumberofMistake.ReadLine() + 1 read_NumberofMistake.Close() IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SM\NumberofMistakes.txt") Dim write_NumberofMistake As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\NumberofMistakes.txt") write_NumberofMistake.WriteLine(NumberofMistake) write_NumberofMistake.Close()

If NumberofMistake = 1 Then frmSM_Gameproper.pctrChance3.BackgroundImage = My.Resources.x_mistake If NumberofMistake = 2 Then frmSM_Gameproper.pctrChance2.BackgroundImage = My.Resources.x_mistake If NumberofMistake = 3 Then frmSM_Gameproper.pctrChance1.BackgroundImage = My.Resources.x_mistake If NumberofMistake = 3 Then Dim write_Status As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status.WriteLine("GameOver") write_Status.Close() End If End Sub Private Sub tmrCountdown_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrCountdown.Tick sec = sec - 1 If sec < 10 Then lbltimer.Text = "0" & sec Else lbltimer.Text = sec If sec = 0 Then tmrCountdown.Stop() sec = 11 proc_TimesUp() End If End Sub End Class frmSM_msg.vb: Public Class frmSM_msg Dim counter As Integer = 1 Dim read_SeaEventNumber As IO.StreamReader Dim SeaEventNumber As Integer Dim status As String Dim check As Integer = 0 Dim clicks2close As Integer = 1 Dim unlocked As Integer

Dim treasure As Integer Dim position As Integer Private Sub frmSM_msg_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IO.File.Exists("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") = True Then read_SeaEventNumber = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") SeaEventNumber = read_SeaEventNumber.ReadLine() read_SeaEventNumber.Close() 'sea event pictures here If SeaEventNumber = 3 Then Me.BackgroundImage = My.Resources.msgSM_lost If SeaEventNumber = 5 Then Me.BackgroundImage = My.Resources.msgSM_storm If SeaEventNumber = 7 Then Me.BackgroundImage = My.Resources.msgSM_battle If SeaEventNumber = 15 Then Me.BackgroundImage = My.Resources.msgSM_monster End If

End Sub Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click Dim write_Status2 As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status2.WriteLine("Intro") write_Status2.Close() Me.Dispose() Me.Close() frmSM_dlgQuestion.ShowDialog() End Sub End Class frmSM_Script.vb: Public Class frmSM_Script

Dim position As Integer Dim status As String Dim sec As Integer Private Sub frmSM_Script_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed IO.File.Delete("C:\Program Files\The Pirate Quest\Gamedata\SM\SeaEventNumber.txt") End Sub Private Sub frmSM_Script_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim read_CurrentPosition As IO.StreamReader = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\SM\CURRENTPosition.txt") position = read_CurrentPosition.ReadLine() read_CurrentPosition.Close() If position = 0 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\Intro.swf", My.Resources.flash_SMINTRO, False) flash.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\Intro.swf" rtxtbx.Visible = False tmrshow.Start() End If If position <> 0 Then My.Computer.FileSystem.WriteAllBytes("C:\Program Files\The Pirate Quest\Gamedata\Flash\Script.swf", My.Resources.flash_SMScript, False) flash.Movie = "C:\Program Files\The Pirate Quest\Gamedata\Flash\Script.swf" flash.Stop() Dim read_Status As IO.StreamReader = IO.File.OpenText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") status = read_Status.ReadLine read_Status.Close() If status = "Intro" Then proc_DoIntro() If status = "Correct" Then proc_DoWin() If status = "Wrong" Or status = "Times Up" Then proc_DoLose() End If

End Sub Private Sub tmrshow_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrshow.Tick sec = sec + 1 If position = 0 Then If sec = 2 Then flash.Stop() tmrshow.Stop() sec = 0 Me.Dispose() Me.Close() rtxtbx.Visible = True End If End If If position <> 0 Then If sec = 3 Then tmrshow.Stop() sec = 0 btnok.Visible = True End If End If End Sub Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click btnok.Visible = False rtxtbx.Visible = True rtxtbx.Clear() If status = "Intro" Then Me.Dispose() frmSM_dlgQuestion.ShowDialog() Else Me.Dispose() frmSM_Gameproper.tmrsteps.Start() Dim write_Status As IO.StreamWriter = IO.File.CreateText("C:\Program Files\The Pirate Quest\Gamedata\SM\Status.txt") write_Status.WriteLine("Intro") write_Status.Close() End If End Sub

Sub proc_DoIntro() Dim intro() As String = My.Resources.script_intro.Split("%") If position = 4 Then flash.GotoFrame(1) rtxtbx.Text = intro(0) End If If position = 12 Then flash.GotoFrame(61) rtxtbx.Text = intro(1) End If If position = 17 Then flash.GotoFrame(122) rtxtbx.Text = intro(2) End If If position = 18 Then flash.GotoFrame(183) rtxtbx.Text = intro(3) End If If position = 21 Then flash.GotoFrame(244) rtxtbx.Text = intro(4) End If If position = 22 Then flash.GotoFrame(305) rtxtbx.Text = intro(5) End If If position = 24 Then flash.GotoFrame(366) rtxtbx.Text = intro(6) End If If position = 28 Then flash.GotoFrame(427) rtxtbx.Text = intro(7) End If If position = 30 Then flash.GotoFrame(488)

rtxtbx.Text = intro(8) End If If position = 33 Then flash.GotoFrame(549) rtxtbx.Text = intro(9) End If If position = 35 Then flash.GotoFrame(610) rtxtbx.Text = intro(10) End If If position = 38 Then flash.GotoFrame(671) rtxtbx.Text = intro(11) End If flash.Play() tmrshow.Start() End Sub Sub proc_DoWin() Dim win() As String = My.Resources.script_win.Split("%") If position = 4 Then flash.GotoFrame(21) rtxtbx.Text = win(0) End If If position = 12 Then flash.GotoFrame(81) rtxtbx.Text = win(1) End If If position = 17 Then flash.GotoFrame(141) rtxtbx.Text = win(2) End If If position = 18 Then flash.GotoFrame(201) rtxtbx.Text = win(3) End If

If position = 21 Then flash.GotoFrame(261) rtxtbx.Text = win(4) End If If position = 22 Then flash.GotoFrame(321) rtxtbx.Text = win(5) End If If position = 24 Then flash.GotoFrame(381) rtxtbx.Text = win(6) End If If position = 28 Then flash.GotoFrame(441) rtxtbx.Text = win(7) End If If position = 30 Then flash.GotoFrame(501) rtxtbx.Text = win(8) End If If position = 33 Then flash.GotoFrame(561) rtxtbx.Text = win(9) End If If position = 35 Then flash.GotoFrame(621) rtxtbx.Text = win(10) End If If position = 38 Then flash.GotoFrame(681) rtxtbx.Text = win(11) End If flash.Play() tmrshow.Start() End Sub

Sub proc_DoLose() Dim lose() As String = My.Resources.script_lose.Split("%") If position = 4 Then flash.GotoFrame(18) rtxtbx.Text = lose(0) End If If position = 12 Then flash.GotoFrame(78) rtxtbx.Text = lose(1) End If If position = 17 Then flash.GotoFrame(138) rtxtbx.Text = lose(2) End If If position = 18 Then flash.GotoFrame(189) rtxtbx.Text = lose(3) End If If position = 21 Then flash.GotoFrame(258) rtxtbx.Text = lose(4) End If If position = 22 Then flash.GotoFrame(318) rtxtbx.Text = lose(5) End If If position = 24 Then flash.GotoFrame(378) rtxtbx.Text = lose(6) End If If position = 28 Then flash.GotoFrame(438) rtxtbx.Text = lose(7) End If If position = 30 Then flash.GotoFrame(498)

rtxtbx.Text = lose(8) End If If position = 33 Then flash.GotoFrame(558) rtxtbx.Text = lose(9) End If If position = 35 Then flash.GotoFrame(618) rtxtbx.Text = lose(10) End If If position = 38 Then flash.GotoFrame(678) rtxtbx.Text = lose(11) End If tmrshow.Start() End Sub End Class

Windows:

También podría gustarte