diff --git a/.vs/EXODUS/v15/.suo b/.vs/EXODUS/v15/.suo new file mode 100644 index 0000000..f07597e Binary files /dev/null and b/.vs/EXODUS/v15/.suo differ diff --git a/EXODUS.pyperf b/EXODUS.pyperf new file mode 100644 index 0000000..a178025 --- /dev/null +++ b/EXODUS.pyperf @@ -0,0 +1,8 @@ + + + + cf93a377-56fe-4882-a1f8-eaf0951d4499 + EXODUS + + + \ No newline at end of file diff --git a/EXODUS.pyproj b/EXODUS.pyproj new file mode 100644 index 0000000..99aa646 --- /dev/null +++ b/EXODUS.pyproj @@ -0,0 +1,58 @@ + + + + Debug + 2.0 + {cf93a377-56fe-4882-a1f8-eaf0951d4499} + + core.py + + . + . + {888888a0-9f3d-457c-b088-3a5042f75d52} + Standard Python launcher + + + + + + 10.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EXODUS.sln b/EXODUS.sln new file mode 100644 index 0000000..6db8200 --- /dev/null +++ b/EXODUS.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.168 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "EXODUS", "EXODUS.pyproj", "{CF93A377-56FE-4882-A1F8-EAF0951D4499}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CF93A377-56FE-4882-A1F8-EAF0951D4499}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF93A377-56FE-4882-A1F8-EAF0951D4499}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DEF92828-376F-453B-971C-331B92C9A760} + EndGlobalSection +EndGlobal diff --git a/core.py b/core.py index e53dcb4..95c7cd8 100644 --- a/core.py +++ b/core.py @@ -1,9 +1,15 @@ -## Coded by SergentThomasKelly +""" Coded by SergentThomasKelly""" ################################################################################ # INITIALISATION # ################################################################################ -import pygame as pg; import sys, pytmx, os, webbrowser -import savesystem as save; from settings import *; +import pygame as pg +import settings +import sys +import pytmx +import os +import webbrowser +import savesystem as save +from settings import * ################################################################################ @@ -15,11 +21,12 @@ class Game: load every bit of data we need to use, and the we run the game. First, we listen to keys and mouse inputs and then we render the screen.""" # >>> INITIALISATION >>> + def __init__(self): self.state = 'starting' self.debugMode = False self.offline = False - self.decalageX, self.decalageY = 128,0 + self.decalageX, self.decalageY = 128, 0 pg.mixer.pre_init(44100, -16, 4, 2048) pg.init() pg.joystick.init @@ -43,53 +50,89 @@ class Game: # >>> HERE'S THE GOD MODE, FOR THE GOD DAMN CREATOR ! >>> def debug(self): print(" =================== WELCOME IN DEBUG MODE ! ==================== ") - print(" | [1] - Enter state : | ") - print(" | [2] - Cheat Mode : | ") + print( + " | [1] - Enter state : | ") + print( + " | [2] - Cheat Mode : | ") print(" ================================================================ ") self.debugCommand = input("[?] >>> Input something : ") if self.debugCommand == "1": - self.clear(); print("[i] >>> [mainMenu, newMenu, settingsMenu, helpMenu, playMenu, game]") - self.debugState = input("[?] >>> What state to load ? "); self.state = self.debugState + self.clear() + print("[i] >>> [mainMenu, newMenu, settingsMenu, helpMenu, playMenu, game]") + self.debugState = input("[?] >>> What state to load ? ") + self.state = self.debugState return True if self.debugCommand == "2": - self.clear(); print("[!] Entered in cheat menu.") + self.clear() + print("[!] Entered in cheat menu.") return False # >>> LOAD EVERYTHING WE NEED ONCE FOR ALL >>> def loadEverything(self): gameFolder = os.path.dirname(__file__) imgFolder = os.path.join(gameFolder, 'sprites') - plyrSpriteFolder = self.playerFolder = os.path.join(imgFolder,'player') - femaleFolder = self.femaleFolder = os.path.join(plyrSpriteFolder, 'female'); maleFolder = self.maleFolder = os.path.join(plyrSpriteFolder,'male') + plyrSpriteFolder = self.playerFolder = os.path.join( + imgFolder, 'player') + femaleFolder = self.femaleFolder = os.path.join( + plyrSpriteFolder, 'female') + maleFolder = self.maleFolder = os.path.join(plyrSpriteFolder, 'male') musicFolder = os.path.join(gameFolder, 'music') - fxFolder = os.path.join(musicFolder,'fx') + fxFolder = os.path.join(musicFolder, 'fx') fontFolder = os.path.join(gameFolder, 'font') loadingFolder = os.path.join(imgFolder, 'loading') menuFolder = os.path.join(imgFolder, 'menus') mapFolder = os.path.join(gameFolder, 'map') - iconFolder = os.path.join(imgFolder, 'icon'); self.icon = pg.image.load(os.path.join(iconFolder,'icon2.png')).convert_alpha(); pg.display.set_icon(self.icon) + iconFolder = os.path.join(imgFolder, 'icon') + self.icon = pg.image.load(os.path.join( + iconFolder, 'icon2.png')).convert_alpha() + pg.display.set_icon(self.icon) self.clear = lambda: os.system('cls') - self.loadingScreen = pg.image.load(os.path.join(loadingFolder, 'loading.png')).convert_alpha() - self.warningVersion = pg.image.load(os.path.join(loadingFolder, "warn.png")).convert_alpha() - self.dialogBox = pg.image.load(os.path.join(menuFolder, 'ui.png')).convert_alpha(); #self.dialogBox = pg.transform.scale(self.dialogBox, (1280,300)) - self.state = 'loadingScreen'; self.renderWindow() - self.guiFont= pg.font.Font(os.path.join(fontFolder, 'Savior1.ttf'), 95) - self.guiFontSub = pg.font.Font(os.path.join(fontFolder, 'Savior1.ttf'), 65) - self.dialogFont = pg.font.Font(os.path.join(fontFolder, 'ToxTypewriter.ttf'), 45) - self.screenWasher = pg.Surface(self.screen.get_size()).convert_alpha(); self.screenWasher.fill((0, 0, 0, 255)) - self.colorGrey = (128,128,128); self.colorWhite = (255,255,255) + self.loadingScreen = pg.image.load(os.path.join( + loadingFolder, 'loading.png')).convert_alpha() + self.warningVersion = pg.image.load(os.path.join( + loadingFolder, "warn.png")).convert_alpha() + # self.dialogBox = pg.transform.scale(self.dialogBox, (1280,300)) + self.dialogBox = pg.image.load(os.path.join( + menuFolder, 'ui.png')).convert_alpha() + self.state = 'loadingScreen' + self.renderWindow() + self.guiFont = pg.font.Font( + os.path.join(fontFolder, 'Savior1.ttf'), 95) + self.guiFontSub = pg.font.Font( + os.path.join(fontFolder, 'Savior1.ttf'), 65) + self.dialogFont = pg.font.Font( + os.path.join(fontFolder, 'ToxTypewriter.ttf'), 45) + self.screenWasher = pg.Surface(self.screen.get_size()).convert_alpha() + self.screenWasher.fill((0, 0, 0, 255)) + self.colorGrey = (128, 128, 128) + self.colorWhite = (255, 255, 255) self.allSprites = pg.sprite.LayeredUpdates() - self.mapPic = pg.image.load(os.path.join(mapFolder, 'l1.png')).convert_alpha() - self.mapWIDTH = self.mapPic.get_width; self.mapHEIGHT = self.mapPic.get_height - self.dimScreen = pg.Surface(self.screen.get_size()).convert_alpha(); self.dimScreen.fill((0, 0, 0, 200)) - self.playerImgFemale = pg.image.load(os.path.join(femaleFolder, 'ante.png')).convert_alpha() - self.playerImgMale = pg.image.load(os.path.join(maleFolder, 'ante.png')).convert_alpha() - self.femalePreview = pg.image.load(os.path.join(plyrSpriteFolder, 'female.png')).convert_alpha(); self.femalePreview = pg.transform.scale(self.femalePreview, (500,500)) - self.malePreview = pg.image.load (os.path.join(plyrSpriteFolder, 'male.png')).convert_alpha(); self.malePreview = pg.transform.scale(self.malePreview, (500,500)) - self.menuNukem = pg.image.load(os.path.join(menuFolder, "main.jpg")).convert(); self.menuNukem = pg.transform.scale(self.menuNukem, (500,500)) - self.playButton = pg.image.load(os.path.join(menuFolder, "play.jpg")).convert(); self.playButton = pg.transform.scale(self.playButton, (500,500)) - self.settingsWheel = pg.image.load(os.path.join(menuFolder, "settings.jpg")).convert() - self.musicIcon = pg.image.load(os.path.join(menuFolder, "music.jpg")).convert() + self.mapPic = pg.image.load(os.path.join( + mapFolder, 'l1.png')).convert_alpha() + self.mapWIDTH = self.mapPic.get_width + self.mapHEIGHT = self.mapPic.get_height + self.dimScreen = pg.Surface(self.screen.get_size()).convert_alpha() + self.dimScreen.fill((0, 0, 0, 200)) + self.playerImgFemale = pg.image.load( + os.path.join(femaleFolder, 'ante.png')).convert_alpha() + self.playerImgMale = pg.image.load( + os.path.join(maleFolder, 'ante.png')).convert_alpha() + self.femalePreview = pg.image.load(os.path.join( + plyrSpriteFolder, 'female.png')).convert_alpha() + self.femalePreview = pg.transform.scale(self.femalePreview, (500, 500)) + self.malePreview = pg.image.load(os.path.join( + plyrSpriteFolder, 'male.png')).convert_alpha() + self.malePreview = pg.transform.scale(self.malePreview, (500, 500)) + self.menuNukem = pg.image.load( + os.path.join(menuFolder, "main.jpg")).convert() + self.menuNukem = pg.transform.scale(self.menuNukem, (500, 500)) + self.playButton = pg.image.load( + os.path.join(menuFolder, "play.jpg")).convert() + self.playButton = pg.transform.scale(self.playButton, (500, 500)) + self.settingsWheel = pg.image.load( + os.path.join(menuFolder, "settings.jpg")).convert() + self.musicIcon = pg.image.load( + os.path.join(menuFolder, "music.jpg")).convert() self.actualChoicePreview = self.screenWasher self.textColorPlay = self.textColorSettings = self.textColorHelp = self.textColorQuit = self.colorGrey self.textColorContinue = self.textColorNewGame = self.textColorReturn = self.colorGrey @@ -100,24 +143,38 @@ class Game: self.textColorReturn = self.colorMusicMenu = self.textColorCredits = self.colorGrey self.textColorYes = self.textColorNo = self.textColorMusicMenu = self.textColorBandcamp = self.colorGrey self.lastMove = "+Y" - self.mapPosX = self.decalageX; self.mapPosY = self.decalageY + self.mapPosX = self.decalageX + self.mapPosY = self.decalageY if os.path.isfile("settings.txt"): settingsSaved = save.readSettings() - self.musicState=settingsSaved[0]; self.fullscreenState=settingsSaved[1]; self.displayFPS=settingsSaved[2] - self.musicLevel=float(settingsSaved[3]); self.fxLevel=float(settingsSaved[4]) + self.musicState = settingsSaved[0] + self.fullscreenState = settingsSaved[1] + self.displayFPS = settingsSaved[2] + self.musicLevel = float(settingsSaved[3]) + self.fxLevel = float(settingsSaved[4]) if self.fullscreenState == "ON": pg.display.set_mode((WIDTH, HEIGHT), pg.FULLSCREEN) else: - self.musicState = "ON"; self.displayFPS = "OFF"; self.fullscreenState = "OFF"; self.musicLevel = 0.5; self.fxLevel = 1.0 + self.musicState = "ON" + self.displayFPS = "OFF" + self.fullscreenState = "OFF" + self.musicLevel = 0.5 + self.fxLevel = 1.0 self.wallsList = [] for walls in WALLS: self.wallsList.append((walls[0]+self.decalageX, walls[1]+self.decalageY, - walls[2], walls[3])) - self.posX = POS[0]+self.decalageX; self.posY = POS[1]+self.decalageY - self.mainMenuMusic = pg.mixer.Sound(os.path.join(musicFolder, 'mainMenu.ogg')) + walls[2], walls[3])) + self.posX = POS[0]+self.decalageX + self.posY = POS[1]+self.decalageY + self.mainMenuMusic = pg.mixer.Sound( + os.path.join(musicFolder, 'mainMenu.ogg')) self.playMusic = pg.mixer.Sound(os.path.join(musicFolder, 'play.ogg')) - self.positiveFx = pg.mixer.Sound(os.path.join(fxFolder, 'positive.ogg'));self.negativeFx = pg.mixer.Sound(os.path.join(fxFolder, 'negative.ogg')) - self.changeMenuFx = pg.mixer.Sound(os.path.join(fxFolder, 'changeMenu.ogg')) + self.positiveFx = pg.mixer.Sound( + os.path.join(fxFolder, 'positive.ogg')) + self.negativeFx = pg.mixer.Sound( + os.path.join(fxFolder, 'negative.ogg')) + self.changeMenuFx = pg.mixer.Sound( + os.path.join(fxFolder, 'changeMenu.ogg')) print("Joystick/Controller detected : " + str(pg.joystick.get_count())) if pg.joystick.get_count() >= 1: pg.joystick.Joystick(0).init() @@ -125,10 +182,12 @@ class Game: print("Joystick name : " + str(pg.joystick.Joystick(0).get_name())) # >>> CHANGE THE MENU YOU ARE INTO >>> - def changeMenu (self, nextState): - pg.key.set_repeat(0, 100); self.previousState = self.state; pg.mouse.set_visible(True) + def changeMenu(self, nextState): + pg.key.set_repeat(0, 100) + self.previousState = self.state + pg.mouse.set_visible(True) if nextState == "pause": - self.screen.blit(self.dimScreen,(0,0)) + self.screen.blit(self.dimScreen, (0, 0)) save.saveGame(self.gender, self.lifeLevel, self.gameLevel) if self.musicState == "ON" and pg.mixer.Channel(0).get_busy(): pg.mixer.Channel(0).pause() @@ -142,7 +201,7 @@ class Game: pg.mixer.Channel(0).play(self.mainMenuMusic, -1) self.state = nextState if self.state != 'loading': - self.screen.blit(self.warningVersion,(0,0)) + self.screen.blit(self.warningVersion, (0, 0)) self.run() # >>> LET THE MAGIC HAPPEN >>> @@ -154,25 +213,32 @@ class Game: if self.state == 'pause': pg.mixer.Channel(0).unpause() actualGame = save.readGame() - self.gender = actualGame[0]; self.lifeLevel = actualGame[1]; self.gameLevel = actualGame[2] - print("I'm a {} and I have {} percent life and I'm in level {}".format(actualGame[0],self.lifeLevel, self.gameLevel)) + self.gender = actualGame[0] + self.lifeLevel = actualGame[1] + self.gameLevel = actualGame[2] + print("I'm a {} and I have {} percent life and I'm in level {}".format( + actualGame[0], self.lifeLevel, self.gameLevel)) if self.gender == 'male': self.playerImg = self.playerImgMale else: self.playerImg = self.playerImgFemale self.picCoordinates = playerAnimation('noneDown', self.gender) - self.washTheScreen(); pg.key.set_repeat(100, 100); self.previousState = self.state + self.washTheScreen() + pg.key.set_repeat(100, 100) + self.previousState = self.state self.state = 'game' self.run() # >>> TOGGLE FULLSCREEN MODE >>> def toggleFullscreen(self): if self.screen.get_flags() != pg.FULLSCREEN: - pg.display.set_mode((WIDTH, HEIGHT), pg.FULLSCREEN); self.fullscreenState = "ON" + pg.display.set_mode((WIDTH, HEIGHT), pg.FULLSCREEN) + self.fullscreenState = "ON" if self.musicState == "ON": pg.mixer.Channel(1).play(self.positiveFx, 0) else: - pg.display.set_mode((WIDTH, HEIGHT)); self.fullscreenState = "OFF" + pg.display.set_mode((WIDTH, HEIGHT)) + self.fullscreenState = "OFF" if self.musicState == "ON": pg.mixer.Channel(1).play(self.negativeFx, 0) @@ -201,15 +267,18 @@ class Game: # >>> INFINITE LOOP TO LISTEN KEYS AND THEN RENDER WINDOW >>> def run(self): while True: - self.clock.tick(60); self.lastUpdate = pg.time.get_ticks() + self.clock.tick(60) + self.lastUpdate = pg.time.get_ticks() if self.displayFPS == "ON": - pg.display.set_caption(str(TITLE)+" -- FPS :"+str(int(self.clock.get_fps()))) + pg.display.set_caption( + str(TITLE)+" -- FPS :"+str(int(self.clock.get_fps()))) else: pg.display.set_caption(TITLE) self.renderWindow() if self.state == "game": self.collideWithWalls() - pg.mixer.Channel(0).set_volume(self.musicLevel); pg.mixer.Channel(1).set_volume(self.fxLevel) + pg.mixer.Channel(0).set_volume(self.musicLevel) + pg.mixer.Channel(1).set_volume(self.fxLevel) self.KeyListener() # >>> COLLISION DETECTION (WITH WALLS OF COURSE) >>> @@ -229,26 +298,41 @@ class Game: def scrolling(self): reload = 0 if self.posX+128 >= WIDTH: - self.mapPosX+=16; self.decalageX+= 16; self.posX+=16; reload+=1 + self.mapPosX += 16 + self.decalageX += 16 + self.posX += 16 + reload += 1 elif self.posY+128 >= HEIGHT: - self.mapPosY-=16; self.decalageY-=16; self.posY-=16; reload+=1 + self.mapPosY -= 16 + self.decalageY -= 16 + self.posY -= 16 + reload += 1 elif self.posX-128 <= 0: - self.mapPosX-=16; self.decalageX-=16; self.posX-=16; reload+=1 + self.mapPosX -= 16 + self.decalageX -= 16 + self.posX -= 16 + reload += 1 elif self.posY-128 <= 0: - self.mapPosY+=16; self.decalageY+= 16; self.posY+=16; reload+=1 + self.mapPosY += 16 + self.decalageY += 16 + self.posY += 16 + reload += 1 if reload != 0: self.wallsList = [] for walls in WALLS: self.wallsList.append((walls[0]+self.decalageX, walls[1]+self.decalageY, - walls[2], walls[3])) + walls[2], walls[3])) # >>> NICE DIALOG BOX >>> def dialogBoxShow(self, character, text): - pg.key.set_repeat(0, 100); self.previousState = self.state; pg.mouse.set_visible(True) + pg.key.set_repeat(0, 100) + self.previousState = self.state + pg.mouse.set_visible(True) save.saveGame(self.gender, self.lifeLevel, self.gameLevel) - self.screen.blit(self.dimScreen,(0,0)) + self.screen.blit(self.dimScreen, (0, 0)) character += str(" said :") - self.whoSpoke = character; self.textDialog = text + self.whoSpoke = character + self.textDialog = text self.state = "dialog" self.run() @@ -282,35 +366,54 @@ class Game: if event.type == pg.KEYDOWN: #print("Your position is X=" + str(self.posX) + " and Y=" + str(self.posY)) if event.key == pg.K_s or event.key == pg.K_DOWN: - self.picCoordinates = playerAnimation('down',self.gender) - self.posY += 16; self.lastMove = "+Y"; self.scrolling() + self.picCoordinates = playerAnimation( + 'down', self.gender) + self.posY += 16 + self.lastMove = "+Y" + self.scrolling() if event.key == pg.K_d or event.key == pg.K_RIGHT: - self.picCoordinates = playerAnimation('right',self.gender) - self.posX += 16; self.lastMove = "+X"; self.scrolling() + self.picCoordinates = playerAnimation( + 'right', self.gender) + self.posX += 16 + self.lastMove = "+X" + self.scrolling() if event.key == pg.K_w or event.key == pg.K_UP: - self.picCoordinates = playerAnimation('up',self.gender) - self.posY -= 16; self.lastMove = "-Y"; self.scrolling() + self.picCoordinates = playerAnimation( + 'up', self.gender) + self.posY -= 16 + self.lastMove = "-Y" + self.scrolling() if event.key == pg.K_a or event.key == pg.K_LEFT: - self.picCoordinates = playerAnimation('left',self.gender) - self.posX -= 16; self.lastMove = "-X"; self.scrolling() + self.picCoordinates = playerAnimation( + 'left', self.gender) + self.posX -= 16 + self.lastMove = "-X" + self.scrolling() if event.key == pg.K_ESCAPE: self.changeMenu("pause") if self.posX >= 975 and self.posY <= 995: if self.posY >= 285: if not L1EVENTLIST[0]: L1EVENTLIST[0] = True - self.dialogBoxShow("GOD",["Welcome in this game.", "Enjoy! And please report bugs."]) + self.dialogBoxShow( + "GOD", ["Welcome in this game.", "Enjoy! And please report bugs."]) if event.key == pg.K_F11: - self.toggleFullscreen(); print('fullscreen toggled to ' + str(self.fullscreenState)) + self.toggleFullscreen() + print('fullscreen toggled to ' + + str(self.fullscreenState)) elif event.type == pg.KEYUP: if self.lastMove == "+Y": - self.picCoordinates = playerAnimation('noneDown', self.gender) + self.picCoordinates = playerAnimation( + 'noneDown', self.gender) elif self.lastMove == "+X": - self.picCoordinates = playerAnimation('noneRight', self.gender) + self.picCoordinates = playerAnimation( + 'noneRight', self.gender) elif self.lastMove == "-X": - self.picCoordinates = playerAnimation('noneLeft', self.gender) + self.picCoordinates = playerAnimation( + 'noneLeft', self.gender) elif self.lastMove == "-Y": - self.picCoordinates = playerAnimation('noneUp', self.gender) + self.picCoordinates = playerAnimation( + 'noneUp', self.gender) elif event.type == pg.QUIT: self.changeMenu("pause") # ========================================== DIALOG BOX ====================================================== # @@ -324,31 +427,39 @@ class Game: if self.resumeBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorResume = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('resume game'); self.continueGame() + print('resume game') + self.continueGame() break else: self.textColorResume = self.colorGrey if self.mainMenuBlit.collidepoint(pg.mouse.get_pos()) == True: - self.textColorMainMenu = self.colorWhite; self.actualChoicePreview = self.malePreview + self.textColorMainMenu = self.colorWhite + self.actualChoicePreview = self.malePreview if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print("main menu"); self.changeMenu("mainMenu") + print("main menu") + self.changeMenu("mainMenu") break else: self.textColorMainMenu = self.colorGrey if self.quitGameBlit.collidepoint(pg.mouse.get_pos()) == True: - self.textColorQuitGame = self.colorWhite; self.actualChoicePreview = self.femalePreview + self.textColorQuitGame = self.colorWhite + self.actualChoicePreview = self.femalePreview if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print("quit game"); self.changeMenu("areYouSureToQuit") + print("quit game") + self.changeMenu("areYouSureToQuit") break else: self.textColorQuitGame = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_a: - print("quit"); self.changeMenu("areYouSureToQuit") + print("quit") + self.changeMenu("areYouSureToQuit") if event.key == pg.K_r or event.key == pg.K_ESCAPE: - print("resume game"); self.continueGame() + print("resume game") + self.continueGame() if event.key == pg.K_SEMICOLON: - print("main menu"); self.changeMenu("mainMenu") + print("main menu") + self.changeMenu("mainMenu") if event.type == pg.QUIT: self.quit() # ========================================== NEW GAME ======================================================== # @@ -357,31 +468,44 @@ class Game: if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorReturn = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('return'); self.changeMenu("mainMenu") + print('return') + self.changeMenu("mainMenu") break else: self.textColorReturn = self.colorGrey if self.maleChoiceBlit.collidepoint(pg.mouse.get_pos()) == True: - self.textColorMale = self.colorWhite; self.actualChoicePreview = self.malePreview + self.textColorMale = self.colorWhite + self.actualChoicePreview = self.malePreview if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print("male"); save.newGame("male"); self.continueGame() + print("male") + save.newGame("male") + self.continueGame() break else: - self.textColorMale = self.colorGrey; self.actualChoicePreview = self.screenWasher + self.textColorMale = self.colorGrey + self.actualChoicePreview = self.screenWasher if self.femaleChoiceBlit.collidepoint(pg.mouse.get_pos()) == True: - self.textColorFemale = self.colorWhite; self.actualChoicePreview = self.femalePreview + self.textColorFemale = self.colorWhite + self.actualChoicePreview = self.femalePreview if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print("female"); save.newGame("female"); self.continueGame() + print("female") + save.newGame("female") + self.continueGame() break else: self.textColorFemale = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_f: - print("female"); save.newGame("female"); self.continueGame() + print("female") + save.newGame("female") + self.continueGame() if event.key == pg.K_SEMICOLON: - print("male"); save.newGame("male"); self.continueGame() + print("male") + save.newGame("male") + self.continueGame() if event.key == pg.K_r or event.key == pg.K_ESCAPE: - print("return"); self.changeMenu("mainMenu") + print("return") + self.changeMenu("mainMenu") if event.type == pg.QUIT: self.changeMenu("areYouSureToQuit") # ========================================== MUSIC MENU ==================================================== # @@ -390,51 +514,63 @@ class Game: if self.musicToggleBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorMusicToggle = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.washTheScreen(); self.toggleMusic(); print('music toggle to ' + str(self.musicState)) + self.washTheScreen() + self.toggleMusic() + print('music toggle to ' + str(self.musicState)) break else: self.textColorMusicToggle = self.colorGrey if self.musicButtonMoinsBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorMusicMoins = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.changeVolume("music","less"); print("music - volume set to " +str(self.musicLevel)) + self.changeVolume("music", "less") + print("music - volume set to " + str(self.musicLevel)) break else: self.textColorMusicMoins = self.colorGrey if self.musicButtonPlusBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorMusicPlus = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.changeVolume("music","more"); print("music + volume set to " +str(self.musicLevel)) + self.changeVolume("music", "more") + print("music + volume set to " + str(self.musicLevel)) break else: self.textColorMusicPlus = self.colorGrey if self.fxButtonMoinsBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorFxMoins = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.changeVolume("fx","less"); print("fx - volume set to " +str(self.musicLevel)) + self.changeVolume("fx", "less") + print("fx - volume set to " + str(self.musicLevel)) break else: self.textColorFxMoins = self.colorGrey if self.fxButtonPlusBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorFxPlus = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.changeVolume("fx","more"); print("fx + volume set to " +str(self.musicLevel)) + self.changeVolume("fx", "more") + print("fx + volume set to " + str(self.musicLevel)) break else: self.textColorFxPlus = self.colorGrey if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorReturn = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('return'); save.saveSettings(self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel) + print('return') + save.saveSettings( + self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel) self.changeMenu("settingsMenu") break else: self.textColorReturn = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_SEMICOLON: - self.washTheScreen(); self.toggleMusic(); print('toggle music') + self.washTheScreen() + self.toggleMusic() + print('toggle music') if event.key == pg.K_r or event.key == pg.K_ESCAPE: - print('return'); save.saveSettings(self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel) + print('return') + save.saveSettings( + self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel) self.changeMenu("settingsMenu") if event.type == pg.QUIT: self.changeMenu("areYouSureToQuit") @@ -444,55 +580,77 @@ class Game: if self.musicMenuBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorMusicMenu = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.washTheScreen(); print('music menu'); self.changeMenu("musicMenu") + self.washTheScreen() + print('music menu') + self.changeMenu("musicMenu") break else: self.textColorMusicMenu = self.colorGrey if self.fullScreenToggleBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorFullscreenToggle = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.washTheScreen(); self.toggleFullscreen(); print('fullscreen toggle to ' + str(self.fullscreenState)) + self.washTheScreen() + self.toggleFullscreen() + print('fullscreen toggle to ' + + str(self.fullscreenState)) break else: self.textColorFullscreenToggle = self.colorGrey if self.resetSaveBlit.collidepoint(pg.mouse.get_pos()) == True: self.resetSaveColor = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.washTheScreen(); self.lastDestroy = "saves"; self.changeMenu("areYouSureToDestroy") + self.washTheScreen() + self.lastDestroy = "saves" + self.changeMenu("areYouSureToDestroy") break else: self.resetSaveColor = self.colorGrey if self.resetSettingsBlit.collidepoint(pg.mouse.get_pos()) == True: self.resetSettingsColor = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.washTheScreen(); self.lastDestroy = "settings" ; self.changeMenu("areYouSureToDestroy") + self.washTheScreen() + self.lastDestroy = "settings" + self.changeMenu("areYouSureToDestroy") break else: self.resetSettingsColor = self.colorGrey if self.displayFPSToggleBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColordisplayFPSToggle = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - self.washTheScreen(); self.toggleFPS(); print('displayFPS toggle to ' + str(self.displayFPS)) + self.washTheScreen() + self.toggleFPS() + print('displayFPS toggle to ' + str(self.displayFPS)) break else: self.textColordisplayFPSToggle = self.colorGrey if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorReturn = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('return'); save.saveSettings(self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel) + print('return') + save.saveSettings( + self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel) self.changeMenu("mainMenu") break else: self.textColorReturn = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_q: - self.washTheScreen(); self.changeMenu("musicMenu"); print('music menu') + self.washTheScreen() + self.changeMenu("musicMenu") + print('music menu') if event.key == pg.K_f: - self.washTheScreen(); self.toggleFullscreen(); print('fullscreen toggle to ' + str(self.fullscreenState)) + self.washTheScreen() + self.toggleFullscreen() + print('fullscreen toggle to ' + + str(self.fullscreenState)) if event.key == pg.K_c: - self.washTheScreen(); self.toggleFPS(); print('displayFPS toggle to ' + str(self.displayFPS)) + self.washTheScreen() + self.toggleFPS() + print('displayFPS toggle to ' + str(self.displayFPS)) if event.key == pg.K_r or event.key == pg.K_ESCAPE: - print('return'); save.saveSettings(self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel) + print('return') + save.saveSettings( + self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel) self.changeMenu("mainMenu") if event.type == pg.QUIT: self.changeMenu("areYouSureToQuit") @@ -502,22 +660,26 @@ class Game: if self.yesBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorYes = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('yes'); self.quit() + print('yes') + self.quit() break else: self.textColorYes = self.colorGrey if self.noBlit.collidepoint(pg.mouse.get_pos()) == True: - self.textColorNo= self.colorWhite + self.textColorNo = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('no'); self.changeMenu(self.previousState) + print('no') + self.changeMenu(self.previousState) break else: self.textColorNo = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_y: - print('yes'); self.quit() + print('yes') + self.quit() if event.key == pg.K_n or event.key == pg.K_ESCAPE: - print('no'); self.changeMenu(self.previousState) + print('no') + self.changeMenu(self.previousState) if event.type == pg.QUIT: self.quit() # ========================================== SURE TO DESTROY SCREEN ========================================== # @@ -528,16 +690,19 @@ class Game: if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: print('reset ' + str(self.lastDestroy)) if self.lastDestroy == "settings": - save.resetSettings(); self.restartGame() + save.resetSettings() + self.restartGame() elif self.lastDestroy == "saves": - save.resetSave(); self.changeMenu("settingsMenu") + save.resetSave() + self.changeMenu("settingsMenu") break else: self.textColorYes = self.colorGrey if self.noBlit.collidepoint(pg.mouse.get_pos()) == True: - self.textColorNo= self.colorWhite + self.textColorNo = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('no'); self.changeMenu("settingsMenu") + print('no') + self.changeMenu("settingsMenu") break else: self.textColorNo = self.colorGrey @@ -545,11 +710,14 @@ class Game: if event.key == pg.K_y: print('reset ' + str(self.lastDestroy)) if self.lastDestroy == "settings": - save.resetSettings(); self.restartGame() + save.resetSettings() + self.restartGame() elif self.lastDestroy == "saves": - save.resetSave(); self.changeMenu("settingsMenu") + save.resetSave() + self.changeMenu("settingsMenu") if event.key == pg.K_n or event.key == pg.K_ESCAPE: - print('no'); self.changeMenu("settingsMenu") + print('no') + self.changeMenu("settingsMenu") if event.type == pg.QUIT: self.changeMenu("areYouSureToDestroy") # ========================================== PLAY MENU ======================================================= # @@ -559,74 +727,89 @@ class Game: if self.continueBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorContinue = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('continue'); self.continueGame() + print('continue') + self.continueGame() break else: self.textColorContinue = self.colorGrey else: if self.newGameBlit.collidepoint(pg.mouse.get_pos()) == True: - self.textColorNewGame= self.colorWhite + self.textColorNewGame = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('new game'); self.changeMenu("newGame") + print('new game') + self.changeMenu("newGame") break else: self.textColorNewGame = self.colorGrey if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorReturn = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('return'); self.changeMenu("mainMenu") + print('return') + self.changeMenu("mainMenu") break else: self.textColorReturn = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_c: - print('continue'); self.continueGame() + print('continue') + self.continueGame() if event.key == pg.K_n: - print('new game'); self.changeMenu("newGame") + print('new game') + self.changeMenu("newGame") if event.key == pg.K_r or event.key == pg.K_ESCAPE: - print('return'); self.changeMenu("mainMenu") + print('return') + self.changeMenu("mainMenu") if event.type == pg.QUIT: - self.changeMenu("areYouSureToQuit"); print('quit') + self.changeMenu("areYouSureToQuit") + print('quit') # ========================================== MAIN MENU ======================================================= # if self.state == 'mainMenu': for event in pg.event.get(): if self.playOptionBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorPlay = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('play'); self.changeMenu("playMenu") + print('play') + self.changeMenu("playMenu") break else: self.textColorPlay = self.colorGrey if self.settingsOptionBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorSettings = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('settings'); self.changeMenu("settingsMenu") + print('settings') + self.changeMenu("settingsMenu") break else: self.textColorSettings = self.colorGrey if self.helpOptionBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorHelp = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('help'); self.changeMenu("helpMenu") + print('help') + self.changeMenu("helpMenu") break else: self.textColorHelp = self.colorGrey if self.quitOptionBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorQuit = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print("quit"); self.changeMenu("areYouSureToQuit") + print("quit") + self.changeMenu("areYouSureToQuit") break else: self.textColorQuit = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_p: - print('play'); self.changeMenu("playMenu") + print('play') + self.changeMenu("playMenu") if event.key == pg.K_s: - print('settings'); self.changeMenu("settingsMenu") + print('settings') + self.changeMenu("settingsMenu") if event.key == pg.K_h: - print('help'); self.changeMenu("helpMenu") + print('help') + self.changeMenu("helpMenu") if event.key == pg.K_a or event.key == pg.K_ESCAPE: - print('quit'); self.changeMenu("areYouSureToQuit") + print('quit') + self.changeMenu("areYouSureToQuit") if event.type == pg.QUIT: self.changeMenu("areYouSureToQuit") # ========================================== HELP MENU ======================================================= # @@ -635,22 +818,26 @@ class Game: if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorReturn = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('return'); self.changeMenu("mainMenu") + print('return') + self.changeMenu("mainMenu") break else: self.textColorReturn = self.colorGrey if self.creditsBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorCredits = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('credits menu'); self.changeMenu("creditsMenu") + print('credits menu') + self.changeMenu("creditsMenu") break else: self.textColorCredits = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_r or event.key == pg.K_ESCAPE: - print('return'); self.changeMenu("mainMenu") - if event.key == pg.K_r or event.key == pg.K_c : - print('credits menu'); self.changeMenu("creditsMenu") + print('return') + self.changeMenu("mainMenu") + if event.key == pg.K_r or event.key == pg.K_c: + print('credits menu') + self.changeMenu("creditsMenu") if event.type == pg.QUIT: self.changeMenu("areYouSureToQuit") # ========================================== CREDITS MENU =================================================== # @@ -659,126 +846,195 @@ class Game: if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorReturn = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('return'); self.changeMenu("helpMenu") + print('return') + self.changeMenu("helpMenu") break else: self.textColorReturn = self.colorGrey if self.openBandcampBlit.collidepoint(pg.mouse.get_pos()) == True: self.textColorBandcamp = self.colorWhite if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: - print('open bandcamp'); webbrowser.open("https://donbor.bandcamp.com", new=2) + print('open bandcamp') + webbrowser.open("https://donbor.bandcamp.com", new=2) break else: self.textColorBandcamp = self.colorGrey if event.type == pg.KEYDOWN: if event.key == pg.K_r or event.key == pg.K_ESCAPE: - print('return'); self.changeMenu("helpMenu") + print('return') + self.changeMenu("helpMenu") if event.type == pg.QUIT: self.changeMenu("areYouSureToQuit") # >>> RENDER THE WINDOW. REALLY. >>> def renderWindow(self): if self.state == 'loadingScreen': - self.loadingBlit = self.screen.blit(self.loadingScreen,(0,0)) + self.loadingBlit = self.screen.blit(self.loadingScreen, (0, 0)) if self.state == 'mainMenu': - self.titleBlit = self.screen.blit(self.guiFont.render("Main Menu", 4, (255,255,255)), (100,175)) - self.playOptionBlit = self.screen.blit(self.guiFontSub.render ("(P) - Play", 4, self.textColorPlay), (115, 250)) - self.settingsOptionBlit = self.screen.blit(self.guiFontSub.render ("(S) - Settings", 4, self.textColorSettings),(115, 300)) - self.helpOptionBlit = self.screen.blit(self.guiFontSub.render ("(H) - Help", 4, self.textColorHelp), (115, 350)) - self.quitOptionBlit = self.screen.blit(self.guiFontSub.render ("(Q) - Quit", 4, self.textColorQuit), (115, 400)) - self.menuNukemBlit = self.screen.blit(self.menuNukem, (700,100)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "Main Menu", 4, (255, 255, 255)), (100, 175)) + self.playOptionBlit = self.screen.blit(self.guiFontSub.render( + "(P) - Play", 4, self.textColorPlay), (115, 250)) + self.settingsOptionBlit = self.screen.blit(self.guiFontSub.render( + "(S) - Settings", 4, self.textColorSettings), (115, 300)) + self.helpOptionBlit = self.screen.blit(self.guiFontSub.render( + "(H) - Help", 4, self.textColorHelp), (115, 350)) + self.quitOptionBlit = self.screen.blit(self.guiFontSub.render( + "(Q) - Quit", 4, self.textColorQuit), (115, 400)) + self.menuNukemBlit = self.screen.blit(self.menuNukem, (700, 100)) if self.state == 'playMenu': - self.titleBlit = self.screen.blit (self.guiFont.render("Play Menu", 4, (255,255,255)), (100,175)) - if os.path.isfile("savegames.txt") == True : - self.continueBlit = self.screen.blit(self.guiFontSub.render("(C) - Continue", 4, self.textColorContinue), (115, 250)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "Play Menu", 4, (255, 255, 255)), (100, 175)) + if os.path.isfile("savegames.txt") == True: + self.continueBlit = self.screen.blit(self.guiFontSub.render( + "(C) - Continue", 4, self.textColorContinue), (115, 250)) else: - self.newGameBlit = self.screen.blit(self.guiFontSub.render ("(N) - New game", 4, self.textColorNewGame), (115, 250)) - self.returnBlit = self.screen.blit(self.guiFontSub.render ("(R) - Return", 4, self.textColorReturn), (115, 300)) - self.playButtonBlit = self.screen.blit(self.playButton, (700,100)) + self.newGameBlit = self.screen.blit(self.guiFontSub.render( + "(N) - New game", 4, self.textColorNewGame), (115, 250)) + self.returnBlit = self.screen.blit(self.guiFontSub.render( + "(R) - Return", 4, self.textColorReturn), (115, 300)) + self.playButtonBlit = self.screen.blit(self.playButton, (700, 100)) if self.state == 'newGame': - self.titleBlit = self.screen.blit(self.guiFont.render("New Game", 4, (255,255,255)), (100,175)) - self.femaleChoiceBlit = self.screen.blit(self.guiFontSub.render("(F) - I'm a female.", 4 , self.textColorFemale), (115,250)) - self.maleChoiceBlit = self.screen.blit(self.guiFontSub.render("(M) - I'm a male.", 4, self.textColorMale), (115, 325)) - self.returnBlit = self.screen.blit(self.guiFontSub.render ("(R) - Return", 4, self.textColorReturn), (115, 400)) - self.actualChoicePreviewBlit = self.screen.blit(self.actualChoicePreview, (700, 100)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "New Game", 4, (255, 255, 255)), (100, 175)) + self.femaleChoiceBlit = self.screen.blit(self.guiFontSub.render( + "(F) - I'm a female.", 4, self.textColorFemale), (115, 250)) + self.maleChoiceBlit = self.screen.blit(self.guiFontSub.render( + "(M) - I'm a male.", 4, self.textColorMale), (115, 325)) + self.returnBlit = self.screen.blit(self.guiFontSub.render( + "(R) - Return", 4, self.textColorReturn), (115, 400)) + self.actualChoicePreviewBlit = self.screen.blit( + self.actualChoicePreview, (700, 100)) if self.state == 'settingsMenu': - self.titleBlit = self.screen.blit(self.guiFont.render("Settings Menu", 4, (255,255,255)), (100,175)) - self.fullScreenToggleBlit = self.screen.blit(self.guiFontSub.render("(F) - Fullscreen : " + str(self.fullscreenState), 4, self.textColorFullscreenToggle), (115,250)) - self.displayFPSToggleBlit = self.screen.blit(self.guiFontSub.render("(C) - FPS Counter : " + str(self.displayFPS),4, self.textColordisplayFPSToggle), (115,300)) - self.musicMenuBlit = self.screen.blit(self.guiFontSub.render("(A) - Audio Menu",4,self.textColorMusicMenu),(115,350)) - self.resetSaveBlit = self.screen.blit(self.guiFontSub.render("/!\ RESET SAVES /!\ ", 4, self.resetSaveColor),(115,400)) - self.resetSettingsBlit = self.screen.blit(self.guiFontSub.render("/!\ RESET SETTINGS /!\ ", 4, self.resetSettingsColor),(115,450)) - self.returnBlit = self.screen.blit(self.guiFontSub.render ("(R) - Return", 4, self.textColorReturn), (115, 500)) - self.settingsWheelBlit = self.screen.blit(self.settingsWheel, (700,100)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "Settings Menu", 4, (255, 255, 255)), (100, 175)) + self.fullScreenToggleBlit = self.screen.blit(self.guiFontSub.render( + "(F) - Fullscreen : " + str(self.fullscreenState), 4, self.textColorFullscreenToggle), (115, 250)) + self.displayFPSToggleBlit = self.screen.blit(self.guiFontSub.render( + "(C) - FPS Counter : " + str(self.displayFPS), 4, self.textColordisplayFPSToggle), (115, 300)) + self.musicMenuBlit = self.screen.blit(self.guiFontSub.render( + "(A) - Audio Menu", 4, self.textColorMusicMenu), (115, 350)) + self.resetSaveBlit = self.screen.blit(self.guiFontSub.render( + "/!\\ RESET SAVES /!\\ ", 4, self.resetSaveColor), (115, 400)) + self.resetSettingsBlit = self.screen.blit(self.guiFontSub.render( + "/!\\ RESET SETTINGS /!\\ ", 4, self.resetSettingsColor), (115, 450)) + self.returnBlit = self.screen.blit(self.guiFontSub.render( + "(R) - Return", 4, self.textColorReturn), (115, 500)) + self.settingsWheelBlit = self.screen.blit( + self.settingsWheel, (700, 100)) if self.state == 'musicMenu': - self.titleBlit = self.screen.blit(self.guiFont.render("Audio Menu", 4, (255,255,255)), (100,175)) - self.musicToggleBlit = self.screen.blit(self.guiFontSub.render("(M) - Music : " + str(self.musicState), 4, self.textColorMusicToggle), (115, 250)) - self.musicButtonPlusBlit = self.screen.blit(self.guiFontSub.render("+",4, self.textColorMusicPlus), (385,300)) - self.musicButtonMoinsBlit = self.screen.blit(self.guiFontSub.render("-",4, self.textColorMusicMoins), (115,300)) - self.musicBlit = self.screen.blit(self.guiFontSub.render("Music Level",4, self.colorGrey), (150,300)) - self.musicLevelBlit = self.screen.blit(self.guiFontSub.render("["+str(self.musicLevel)+"]",4,self.colorGrey),(420,300)) - self.fxButtonPlusBlit = self.screen.blit(self.guiFontSub.render("+",4, self.textColorFxPlus), (385,350)) - self.fxButtonMoinsBlit = self.screen.blit(self.guiFontSub.render("-",4, self.textColorFxMoins), (115,350)) - self.fxBlit = self.screen.blit(self.guiFontSub.render("FX Level",4, self.colorGrey), (175,350)) - self.fxLevelBlit = self.screen.blit(self.guiFontSub.render("["+str(self.fxLevel)+"]",4,self.colorGrey),(420,350)) - self.returnBlit = self.screen.blit(self.guiFontSub.render ("(R) - Return", 4, self.textColorReturn), (115, 400)) - self.musicIconBlit = self.screen.blit(self.musicIcon, (700,100)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "Audio Menu", 4, (255, 255, 255)), (100, 175)) + self.musicToggleBlit = self.screen.blit(self.guiFontSub.render( + "(M) - Music : " + str(self.musicState), 4, self.textColorMusicToggle), (115, 250)) + self.musicButtonPlusBlit = self.screen.blit( + self.guiFontSub.render("+", 4, self.textColorMusicPlus), (385, 300)) + self.musicButtonMoinsBlit = self.screen.blit( + self.guiFontSub.render("-", 4, self.textColorMusicMoins), (115, 300)) + self.musicBlit = self.screen.blit(self.guiFontSub.render( + "Music Level", 4, self.colorGrey), (150, 300)) + self.musicLevelBlit = self.screen.blit(self.guiFontSub.render( + "["+str(self.musicLevel)+"]", 4, self.colorGrey), (420, 300)) + self.fxButtonPlusBlit = self.screen.blit( + self.guiFontSub.render("+", 4, self.textColorFxPlus), (385, 350)) + self.fxButtonMoinsBlit = self.screen.blit( + self.guiFontSub.render("-", 4, self.textColorFxMoins), (115, 350)) + self.fxBlit = self.screen.blit(self.guiFontSub.render( + "FX Level", 4, self.colorGrey), (175, 350)) + self.fxLevelBlit = self.screen.blit(self.guiFontSub.render( + "["+str(self.fxLevel)+"]", 4, self.colorGrey), (420, 350)) + self.returnBlit = self.screen.blit(self.guiFontSub.render( + "(R) - Return", 4, self.textColorReturn), (115, 400)) + self.musicIconBlit = self.screen.blit(self.musicIcon, (700, 100)) if self.state == 'helpMenu': - self.titleBlit = self.screen.blit(self.guiFont.render("Help Menu", 4, (255,255,255)), (100,175)) - self.helpText1Blit = self.screen.blit(self.guiFontSub.render("This game is a project from SergentThomasKelly", 4, self.colorGrey), (115,250)) - self.helpText2Blit = self.screen.blit(self.guiFontSub.render("This is a post apolyptic game about strategy and", 4, self.colorGrey), (115,300)) - self.helpText3Blit = self.screen.blit(self.guiFontSub.render("saving your life (at least). And Philosophy too.", 4, self.colorGrey), (115,350)) - self.helpText3Blit = self.screen.blit(self.guiFontSub.render("> To move, use arrows and ZQSD or WASD. <", 4, self.colorGrey), (115,400)) - self.creditsBlit = self.screen.blit(self.guiFontSub.render ("(C) - Credits", 4, self.textColorCredits), (115, 460)) - self.returnBlit = self.screen.blit(self.guiFontSub.render ("(R) - Return", 4, self.textColorReturn), (115, 510)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "Help Menu", 4, (255, 255, 255)), (100, 175)) + self.helpText1Blit = self.screen.blit(self.guiFontSub.render( + "This game is a project from SergentThomasKelly", 4, self.colorGrey), (115, 250)) + self.helpText2Blit = self.screen.blit(self.guiFontSub.render( + "This is a post apolyptic game about strategy and", 4, self.colorGrey), (115, 300)) + self.helpText3Blit = self.screen.blit(self.guiFontSub.render( + "saving your life (at least). And Philosophy too.", 4, self.colorGrey), (115, 350)) + self.helpText3Blit = self.screen.blit(self.guiFontSub.render( + "> To move, use arrows and ZQSD or WASD. <", 4, self.colorGrey), (115, 400)) + self.creditsBlit = self.screen.blit(self.guiFontSub.render( + "(C) - Credits", 4, self.textColorCredits), (115, 460)) + self.returnBlit = self.screen.blit(self.guiFontSub.render( + "(R) - Return", 4, self.textColorReturn), (115, 510)) if self.state == 'creditsMenu': - self.titleBlit = self.screen.blit(self.guiFont.render("Credits Menu", 4, (255,255,255)), (100,175)) - self.helpText1Blit = self.screen.blit(self.guiFontSub.render("Main Menu Music : Donbor - Void643", 4, self.colorGrey), (115,250)) - self.helpText2Blit = self.screen.blit(self.guiFontSub.render("Level1 Music : Donbor - Blind", 4, self.colorGrey), (115,300)) - self.helpText3Blit = self.screen.blit(self.guiFontSub.render("Visit his bandcamp ", 4, self.colorGrey), (115,350)) - self.openBandcampBlit = self.screen.blit(self.guiFontSub.render(">here<", 4, self.textColorBandcamp), (500,350)) - self.helpText3Blit = self.screen.blit(self.guiFontSub.render("All credits to this artist ! He's doing an amazing job !", 4, self.colorGrey), (115,400)) - self.returnBlit = self.screen.blit(self.guiFontSub.render ("(R) - Return", 4, self.textColorReturn), (115, 460)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "Credits Menu", 4, (255, 255, 255)), (100, 175)) + self.helpText1Blit = self.screen.blit(self.guiFontSub.render( + "Main Menu Music : Donbor - Void643", 4, self.colorGrey), (115, 250)) + self.helpText2Blit = self.screen.blit(self.guiFontSub.render( + "Level1 Music : Donbor - Blind", 4, self.colorGrey), (115, 300)) + self.helpText3Blit = self.screen.blit(self.guiFontSub.render( + "Visit his bandcamp ", 4, self.colorGrey), (115, 350)) + self.openBandcampBlit = self.screen.blit(self.guiFontSub.render( + ">here<", 4, self.textColorBandcamp), (500, 350)) + self.helpText3Blit = self.screen.blit(self.guiFontSub.render( + "All credits to this artist ! He's doing an amazing job !", 4, self.colorGrey), (115, 400)) + self.returnBlit = self.screen.blit(self.guiFontSub.render( + "(R) - Return", 4, self.textColorReturn), (115, 460)) if self.state == 'areYouSureToQuit': - self.titleBlit = self.screen.blit(self.guiFont.render("ARE YOU SURE ?", 4, (255,255,255)), (400,175)) - self.yesBlit = self.screen.blit(self.guiFontSub.render("(Y) - Yes, let me leave", 4, self.textColorYes), (300, 250)) - self.noBlit = self.screen.blit(self.guiFontSub.render("(N) - No, I regret, let me come back", 4, self.textColorNo), (300, 300)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "ARE YOU SURE ?", 4, (255, 255, 255)), (400, 175)) + self.yesBlit = self.screen.blit(self.guiFontSub.render( + "(Y) - Yes, let me leave", 4, self.textColorYes), (300, 250)) + self.noBlit = self.screen.blit(self.guiFontSub.render( + "(N) - No, I regret, let me come back", 4, self.textColorNo), (300, 300)) if self.state == 'areYouSureToDestroy': - self.titleBlit = self.screen.blit(self.guiFont.render("SOME DATA WILL BE DESTROYED!", 4, (255,255,255)), (100,175)) - self.yesBlit = self.screen.blit(self.guiFontSub.render("(Y) - I don't care. Destroy.", 4, self.textColorYes), (115, 250)) - self.noBlit = self.screen.blit(self.guiFontSub.render("(N) - Don't destroy!", 4, self.textColorNo), (115, 350)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "SOME DATA WILL BE DESTROYED!", 4, (255, 255, 255)), (100, 175)) + self.yesBlit = self.screen.blit(self.guiFontSub.render( + "(Y) - I don't care. Destroy.", 4, self.textColorYes), (115, 250)) + self.noBlit = self.screen.blit(self.guiFontSub.render( + "(N) - Don't destroy!", 4, self.textColorNo), (115, 350)) if self.state == 'pause': - self.titleBlit = self.screen.blit(self.guiFont.render("Paused", 4, (255,255,255)), (100,175)) - self.resumeBlit = self.screen.blit(self.guiFontSub.render("(R) - Resume game", 4, self.textColorResume), (115, 250)) - self.mainMenuBlit = self.screen.blit(self.guiFontSub.render("(M) - Main Menu", 4, self.textColorMainMenu), (115, 300)) - self.quitGameBlit = self.screen.blit(self.guiFontSub.render("(Q) - Quit", 4, self.textColorQuitGame), (115, 350)) + self.titleBlit = self.screen.blit(self.guiFont.render( + "Paused", 4, (255, 255, 255)), (100, 175)) + self.resumeBlit = self.screen.blit(self.guiFontSub.render( + "(R) - Resume game", 4, self.textColorResume), (115, 250)) + self.mainMenuBlit = self.screen.blit(self.guiFontSub.render( + "(M) - Main Menu", 4, self.textColorMainMenu), (115, 300)) + self.quitGameBlit = self.screen.blit(self.guiFontSub.render( + "(Q) - Quit", 4, self.textColorQuitGame), (115, 350)) if self.state == 'game': - self.screen.blit(self.screenWasher,(0,0)) - self.mapBlit = self.screen.blit(self.mapPic, (self.mapPosX, self.mapPosY)) - self.persoBlit = self.screen.blit(self.playerImg, (self.posX, self.posY), self.picCoordinates); self.persoRect = pg.Rect(self.posX, self.posY, self.persoBlit.w-2, self.persoBlit.h-2) + self.screen.blit(self.screenWasher, (0, 0)) + self.mapBlit = self.screen.blit( + self.mapPic, (self.mapPosX, self.mapPosY)) + self.persoBlit = self.screen.blit( + self.playerImg, (self.posX, self.posY), self.picCoordinates) + self.persoRect = pg.Rect( + self.posX, self.posY, self.persoBlit.w-2, self.persoBlit.h-2) if self.state == 'dialog': - self.screen.blit(self.dialogBox,(230,400)) - self.screen.blit(self.dialogFont.render(self.whoSpoke, 4, self.colorWhite), (275, 435)) - self.screen.blit(self.dialogFont.render(self.textDialog[0], 4, self.colorWhite), (300, 500)) - self.screen.blit(self.dialogFont.render(self.textDialog[1], 4, self.colorWhite), (300, 540)) - self.screen.blit(self.dialogFont.render("Press RETURN", 4, self.colorGrey),(710,635)) + self.screen.blit(self.dialogBox, (230, 400)) + self.screen.blit(self.dialogFont.render( + self.whoSpoke, 4, self.colorWhite), (275, 435)) + self.screen.blit(self.dialogFont.render( + self.textDialog[0], 4, self.colorWhite), (300, 500)) + self.screen.blit(self.dialogFont.render( + self.textDialog[1], 4, self.colorWhite), (300, 540)) + self.screen.blit(self.dialogFont.render( + "Press RETURN", 4, self.colorGrey), (710, 635)) pg.display.update() # >>> WASH THE SCREEN >>> def washTheScreen(self): - self.screen.blit(self.screenWasher, (0,0)) + self.screen.blit(self.screenWasher, (0, 0)) if self.state != 'loading': - self.screen.blit(self.warningVersion,(0,0)) + self.screen.blit(self.warningVersion, (0, 0)) pg.display.update() # >>> DO YOU REALLY NEED COMMENTS FOR THIS ONE ? >>> def quit(self): pg.quit() - #sys.exit() + # sys.exit() # >>> RESTART THE WHOLE GAME >>> def restartGame(self): os.startfile(r"core.py") self.quit() + Game() diff --git a/settings.py b/settings.py index 31a45c3..3d9b3d9 100644 --- a/settings.py +++ b/settings.py @@ -1,4 +1,4 @@ -##Coded by SergentThomasKelly +# Coded by SergentThomasKelly ################################################################################ # INITIALISATION # ################################################################################ @@ -9,20 +9,22 @@ HEIGHT = 720 TITLE = "EXODUS (PRE-BETA RELEASE -- GITHUB EDITION)" playerAnimationLoop = 1 leaveRoomTrigger = bathBloodHorrorTrigger = False -L1EVENTLIST = [leaveRoomTrigger,bathBloodHorrorTrigger] -playerCoordinates = {"female":{"down":{1:(2,0,30,33), 2:(32,0,33,32), 3:(64,0,31,33)}, - "left":{1:(4,33,27,31), 2:(36,32,25,33), 3:(68,33,24,31)}, - "right":{1:(1,65,27,31), 2:(35,64,25,32), 3:(68,65,24,31)}, - "up":{1:(3,97,28,31), 2:(33,96,31,32), 3:(66,97,28,31)}}, - "male":{"down":{1:(4,1,26,31), 2:(35,0,27,32), 3:(68,0,26,32)}, - "left":{1:(3,33,25,31), 2:(35,32,25,32), 3:(67,33,25,31)}, - "right":{1:(4,65,25,31), 2:(36,64,25,32), 3:(68,65,25,31)}, - "up":{1:(3,97,26,31), 2:(35,96,26,32), 3:(67,97,26,31)}} - } +L1EVENTLIST = [leaveRoomTrigger, bathBloodHorrorTrigger] +playerCoordinates = {"female": {"down": {1: (2, 0, 30, 33), 2: (32, 0, 33, 32), 3: (64, 0, 31, 33)}, + "left": {1: (4, 33, 27, 31), 2: (36, 32, 25, 33), 3: (68, 33, 24, 31)}, + "right": {1: (1, 65, 27, 31), 2: (35, 64, 25, 32), 3: (68, 65, 24, 31)}, + "up": {1: (3, 97, 28, 31), 2: (33, 96, 31, 32), 3: (66, 97, 28, 31)}}, + "male": {"down": {1: (4, 1, 26, 31), 2: (35, 0, 27, 32), 3: (68, 0, 26, 32)}, + "left": {1: (3, 33, 25, 31), 2: (35, 32, 25, 32), 3: (67, 33, 25, 31)}, + "right": {1: (4, 65, 25, 31), 2: (36, 64, 25, 32), 3: (68, 65, 25, 31)}, + "up": {1: (3, 97, 26, 31), 2: (35, 96, 26, 32), 3: (67, 97, 26, 31)}} + } ################################################################################ # PLAYER ANIMATION # ################################################################################ + + def playerAnimation(direction, gender): global playerCoordinates, playerAnimationLoop playerAnimationLoop += 2 @@ -30,8 +32,8 @@ def playerAnimation(direction, gender): playerAnimationLoop = 1 playerCoordinatesLast = playerCoordinates[gender] if direction == 'down' or direction == 'up' or direction == 'left' or direction == 'right': - playerCoordinatesLast = playerCoordinatesLast[direction] - return playerCoordinatesLast[playerAnimationLoop] + playerCoordinatesLast = playerCoordinatesLast[direction] + return playerCoordinatesLast[playerAnimationLoop] elif direction == 'noneDown': playerCoordinatesLast = playerCoordinatesLast["down"] return playerCoordinatesLast[2] @@ -46,67 +48,67 @@ def playerAnimation(direction, gender): return playerCoordinatesLast[2] -POS = (753.00,143.67) +POS = (753.00, 143.67) -WALLS=[(176.0,32.0,765.333,79.6667), -(178.667,33.3333,26.6667,268.0), -(50.6667,146.667,154.667,155.333), -(48.0,144.0,29.3333,1054.67), -(180.0,222.667,73.3333,79.0), -(305.333,224.0,154.833,77.0), -(337.333,34.6667,26.0,265.667), -(526.667,34.6667,33.3333,266.333), -(512.167,223.333,141.667,80.0), -(704.0,228.333,138.5,74.1667), -(724.333,34.6667,25.0,265.0), -(916.0,35.0,26.6667,1162.34), -(899.5,229.334,41.8333,73.0), -(177.333,417.333,188.0,93.3333), -(176.0,416.0,29.3333,282.333), -(178.667,592.0,317.333,80.3333), -(431.333,421.667,493.0,74.0), -(465.0,421.334,29.3333,601.0), -(470.667,641.333,313.333,109.0), -(848.0,640.0,93.3333,92.6667), -(177.333,754.667,28.0,265.667), -(182.667,833.333,598.667,76.3333), -(848.0,832.0,94.6667,78.3333), -(49.3333,1108.0,638.667,90.6667), -(785.333,1106.67,158.667,90.6667), -(362.0,450.0,78.0,61.0), -(207.0,112.0,134.0,31.0), -(305.0,103.0,33.0,56.0), -(402.0,114.0,57.0,43.0), -(361.0,201.0,85.0,50.0), -(503.0,152.0,26.0,21.0), -(594.0,114.5,54.0,42.0), -(550.0,201.5,89.0,50.0), -(692.0,152.5,26.0,21.0), -(786.0,115.5,57.0,41.0), -(745.0,202.5,89.0,50.0), -(886.0,152.5,26.0,10.0), -(258.0,771.0,88.0,24.0), -(205.0,663.0,64.0,36.0), -(369.0,665.0,104.0,40.0), -(370.0,697.0,64.0,103.0), -(484.0,790.0,43.0,48.0), -(686.0,1197.0,104.0,32.0), -(280.0,898.0,51.0,109.0), -(198.0,898.0,40.0,93.0), -(369.0,880.0,75.0,46.0), -(369.0,961.0,27.0,46.0), -(439.0,897.0,29.0,111.0), -(483.0,882.0,122.0,107.0), -(696.0,892.0,55.0,33.0), -(524.0,816.0,180.0,22.0), -(880.0,705.0,36.0,60.0), -(495.0,470.0,286.0,42.0), -(495.0,509.0,206.0,56.0), -(491.0,616.0,213.0,25.0), -(492.0,566.0,260.0,51.0), -(750.0,579.0,31.0,25.0), -(885.0,517.0,27.0,44.0), -(887.0,907.0,29.0,201.0), -(602.0,901.0,38.0,26.0), -(641.0,901.0,87.0,91.0), -(78.0,1088.0,400.0,15.0)] +WALLS = [(176.0, 32.0, 765.333, 79.6667), + (178.667, 33.3333, 26.6667, 268.0), + (50.6667, 146.667, 154.667, 155.333), + (48.0, 144.0, 29.3333, 1054.67), + (180.0, 222.667, 73.3333, 79.0), + (305.333, 224.0, 154.833, 77.0), + (337.333, 34.6667, 26.0, 265.667), + (526.667, 34.6667, 33.3333, 266.333), + (512.167, 223.333, 141.667, 80.0), + (704.0, 228.333, 138.5, 74.1667), + (724.333, 34.6667, 25.0, 265.0), + (916.0, 35.0, 26.6667, 1162.34), + (899.5, 229.334, 41.8333, 73.0), + (177.333, 417.333, 188.0, 93.3333), + (176.0, 416.0, 29.3333, 282.333), + (178.667, 592.0, 317.333, 80.3333), + (431.333, 421.667, 493.0, 74.0), + (465.0, 421.334, 29.3333, 601.0), + (470.667, 641.333, 313.333, 109.0), + (848.0, 640.0, 93.3333, 92.6667), + (177.333, 754.667, 28.0, 265.667), + (182.667, 833.333, 598.667, 76.3333), + (848.0, 832.0, 94.6667, 78.3333), + (49.3333, 1108.0, 638.667, 90.6667), + (785.333, 1106.67, 158.667, 90.6667), + (362.0, 450.0, 78.0, 61.0), + (207.0, 112.0, 134.0, 31.0), + (305.0, 103.0, 33.0, 56.0), + (402.0, 114.0, 57.0, 43.0), + (361.0, 201.0, 85.0, 50.0), + (503.0, 152.0, 26.0, 21.0), + (594.0, 114.5, 54.0, 42.0), + (550.0, 201.5, 89.0, 50.0), + (692.0, 152.5, 26.0, 21.0), + (786.0, 115.5, 57.0, 41.0), + (745.0, 202.5, 89.0, 50.0), + (886.0, 152.5, 26.0, 10.0), + (258.0, 771.0, 88.0, 24.0), + (205.0, 663.0, 64.0, 36.0), + (369.0, 665.0, 104.0, 40.0), + (370.0, 697.0, 64.0, 103.0), + (484.0, 790.0, 43.0, 48.0), + (686.0, 1197.0, 104.0, 32.0), + (280.0, 898.0, 51.0, 109.0), + (198.0, 898.0, 40.0, 93.0), + (369.0, 880.0, 75.0, 46.0), + (369.0, 961.0, 27.0, 46.0), + (439.0, 897.0, 29.0, 111.0), + (483.0, 882.0, 122.0, 107.0), + (696.0, 892.0, 55.0, 33.0), + (524.0, 816.0, 180.0, 22.0), + (880.0, 705.0, 36.0, 60.0), + (495.0, 470.0, 286.0, 42.0), + (495.0, 509.0, 206.0, 56.0), + (491.0, 616.0, 213.0, 25.0), + (492.0, 566.0, 260.0, 51.0), + (750.0, 579.0, 31.0, 25.0), + (885.0, 517.0, 27.0, 44.0), + (887.0, 907.0, 29.0, 201.0), + (602.0, 901.0, 38.0, 26.0), + (641.0, 901.0, 87.0, 91.0), + (78.0, 1088.0, 400.0, 15.0)]