def Initialize(self, initializer): #file where scores are stored self.filename = "save.txt" #getting User info for file i/o self.UserDirect = Zero.GetUserDirectory() #run open file function self.OpenFile()
def Initialize(self, initializer): #for file i/o for checking game progress self.UserDirect = Zero.GetUserDirectory() self.filename = "save.txt" #starts check marks as invisible self.Owner.Sprite.Visible = False #runs check function self.Check()
def Initialize(self, initializer): #for file i/o for checking game progress self.UserDirect = Zero.GetUserDirectory() self.filename = "save.txt" #setting up an array to hold score values self.scores = [[0] * 11 for i in range(11)] #checking if this path exists if (os.path.isfile(self.UserDirect + "Castellum\\" + self.filename)): #opens file ScoreFile = open(self.UserDirect + "Castellum\\" + self.filename, "r") #reads in scores stores in file for i in range(11): #changes scores to integers self.scores[i] = int(ScoreFile.readline()) #Close file ScoreFile.close() else: for i in range(11): #changes scores to integers self.scores[i] = 0 #sets if a win screen should be played based on whether scores have been stored #Win Screen for Tutorials if (self.scores[0] > 0 and self.scores[1] > 0): self.WinTutorial = True else: self.WinTutorial = False #Win Screen for Doug Mode if (self.scores[2] > 0 and self.scores[3] > 0 and self.scores[4] > 0): self.WinDougMode = True else: self.WinDougMode = False #Win Screen for Adventure if (self.scores[5] > 0 and self.scores[6] > 0 and self.scores[7] > 0): self.WinAdventure = True else: self.WinAdventure = False #Win Screen for Daredevil if (self.scores[8] > 0 and self.scores[9] > 0 and self.scores[10] > 0): self.WinDaredevil = True else: self.WinDaredevil = False #Win screen for entire game self.WinAll = False #makes object persistant throughtout game self.Owner.Persistent = True
def Initialize(self, initializer): #file where scores are stored self.filename = "save.txt" #set score after player reaches the end of a level self.score = self.Owner.EndLevelLogic.LevelFinalScore #check which level the player has finished self.LevelNumber = Zero.Game.Score.LevelNumber #getting user info for file i/o self.UserDirect = Zero.GetUserDirectory() #run write file function self.WriteFile()
def onMouseUp(self, MouseEvent): #Write the changed volume to file self.file = open( Zero.GetUserDirectory() + "Castellum\\" + "volume_options.txt", 'w') self.file.write(str(round(self.percent))) self.file.close() #closes file #Tells Global Volume Script to change volume self.Space.FindObjectByName("LevelSettings").GlobalVolume.setVolume() self.clicked = False
def setVolume(self): #Reads the text file (we already checked that it exists) as an integer and then closes file self.file = open( Zero.GetUserDirectory() + "Castellum\\" + "volume_options.txt", 'r+') self.volume = int(self.file.readline()) self.file.close() #changes the volume in the SoundEmitter for object playing background music self.backgroundMusicObject = self.Space.FindObjectByName( "BackgroundMusic") self.backgroundMusicObject.SoundEmitter.Volume = self.volume / 100 #also changes volume in soundspace for other sounds self.Space.SoundSpace.Volume = self.volume / 100.0
def Initialize(self, initializer): #Checks if there is a volume text file and creates one if it doesn't exist if os.path.exists(Zero.GetUserDirectory() + "Castellum") and os.path.isfile( Zero.GetUserDirectory() + "Castellum\\volume_options.txt"): #opens file for reading self.file = open( Zero.GetUserDirectory() + "Castellum\\" + "volume_options.txt", 'r+') #reads in value after converting it to an integer self.percent = int(self.file.readline()) #closes file self.file.close() elif os.path.exists(Zero.GetUserDirectory() + "Castellum"): #opens file for writing self.file = open( Zero.GetUserDirectory() + "Castellum\\" + "volume_options.txt", 'w') #writes to fiile 100 (max volume) self.file.write("100") #closes file self.file.close() #re-Intitializes script so we can check to read file self.Initialize(initializer) else: #Creating a file if there wasn't one os.mkdir(Zero.GetUserDirectory() + "Castellum") self.file = open( Zero.GetUserDirectory() + "Castellum" + "volume_options.txt", 'w') #writes to file 100 (max Volume) self.file.write("100") #Closes file self.file.close() #re-Intitializes script so we can check to read file self.Initialize(initializer) #Set of Logic Update Event Zero.Connect(self.Space, Events.LogicUpdate, self.onLogicUpdate) #Set variable for whether volume is trying to be changed self.changeVolume = False
def Initialize(self, initializer): self.yvalue = -5.5 #Checks if there is a volume text file and creates one if it doesn't exist if os.path.exists(Zero.GetUserDirectory() + "Castellum") and os.path.isfile( Zero.GetUserDirectory() + "Castellum\\volume_options.txt"): #opens file for reading self.file = open( Zero.GetUserDirectory() + "Castellum\\" + "volume_options.txt", 'r+') #reads in value after converting it to an integer self.percent = int(self.file.readline()) #closes file self.file.close() elif os.path.exists(Zero.GetUserDirectory() + "Castellum"): #opens file for writing self.file = open( Zero.GetUserDirectory() + "Castellum\\" + "volume_options.txt", 'w') #writes to fiile 100 (max volume) self.file.write("100") #closes file self.file.close() #re-Intitializes script so we can check to read file self.Initialize(initializer) else: #Creating a file if there wasn't one os.mkdir(Zero.GetUserDirectory() + "Castellum") self.file = open( Zero.GetUserDirectory() + "Castellum\\" + "volume_options.txt", 'w') #writes to file 100 (max Volume) self.file.write("100") #Closes file self.file.close() #re-Intitializes script so we can check to read file self.Initialize(initializer) self.currentSpace = 0 #Max left and right movement self.x_left = -3.125 self.x_right = 3.155 #Total length of movement self.total = -self.x_left + self.x_right #sets it to what the percent is self.Owner.Transform.Translation = VectorMath.Vec3( self.x_left + (self.percent * self.total / 100.0), self.yvalue, -1) #finds volume and sets text self.volume = self.Space.FindObjectByName("Volume") self.volume.SpriteText.Text = "Volume: " + str(round( self.percent)) + "%" self.clicked = False #camera varaible cameracog = self.Space.FindObjectByName("Camera") #setting up mouse events Zero.Connect(self.Owner, Events.MouseDown, self.onMouseDown) Zero.Connect(self.Owner, Events.MouseUp, self.onMouseUp) Zero.Connect(cameracog.Camera.Viewport, Events.MouseMove, self.onMouseMove) Zero.Connect(cameracog.Camera.Viewport, Events.MouseUpdate, self.onMouseUpdate)
def Initialize(self, initializer): #Create Update event Zero.Connect(self.Space, Events.LogicUpdate, self.OnLogicUpdate) #------------------------------------------------------------------ #Setting Variables #This is the timer for adding the score self.levelProgression = 0.0 #This sets beginning score from time to 0 self.startTimeScore = 0 #This sets beginning score from Gold to 0 self.startGoldScore = 0 #This sets beginning score from deaths to 0 self.startDeathScore = 0 #------------------------------------------------------------------ #for live calculating of score self.deathsAreDone = False self.timeIsDone = False self.goldIsDone = False #checks to display stats immediately or end level self.getStats = False self.endLevel = False #your total score for the level self.LevelFinalScore = 0 #Get your final time and level par from level just completed self.finalTime = Zero.Game.Score.finalTime self.par = Zero.Game.Score.par #Get final deaths from level just completed self.finalDeaths = Zero.Game.Score.finalDeaths #Get final gold from level just completed self.finalGold = Zero.Game.Score.finalGold #------------------------------------------------------------------ #Calculations: #Calculate time score if (self.finalTime < self.par): self.tscore = (round(self.par - self.finalTime)) * 100 else: self.tscore = 0 #Calculate gold score self.tgold = self.finalGold * 200 #Calculate Death score self.tdeath = self.finalDeaths * 100 #calculate final score self.LevelFinalScore = self.tscore + self.tgold - self.tdeath self.Owner.AddComponentByName("SaveHighscore") #------------------------------------------------------------------ #for file i/o for checking game progress self.UserDirect = Zero.GetUserDirectory() self.filename = "save.txt" #------------------------------------------------------------------ #setting up checks that win screens have been achieved self.WinTutorial = False self.WinDougMode = False self.WinAdventure = False self.WinDaredevil = False self.WinAll = False