2018-12-30 15:20:24 +01:00
|
|
|
""" Coded by SergentThomasKelly"""
|
2018-04-10 20:38:18 +02:00
|
|
|
################################################################################
|
|
|
|
# INITIALISATION #
|
|
|
|
################################################################################
|
2018-12-30 15:20:24 +01:00
|
|
|
import pygame as pg
|
|
|
|
import settings
|
|
|
|
import sys
|
|
|
|
import pytmx
|
|
|
|
import os
|
|
|
|
import webbrowser
|
|
|
|
import savesystem as save
|
|
|
|
from settings import *
|
2018-04-10 20:38:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# CLASS GAME #
|
|
|
|
################################################################################
|
|
|
|
class Game:
|
|
|
|
""" This class is responsible for the well shape of the whole game.
|
|
|
|
In fact, this class IS the game. Firstly we initialize Pygame, then we
|
|
|
|
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 >>>
|
2018-12-30 15:20:24 +01:00
|
|
|
|
2018-04-10 20:38:18 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.state = 'starting'
|
|
|
|
self.debugMode = False
|
|
|
|
self.offline = False
|
2018-12-30 15:20:24 +01:00
|
|
|
self.decalageX, self.decalageY = 128, 0
|
2018-04-10 20:38:18 +02:00
|
|
|
pg.mixer.pre_init(44100, -16, 4, 2048)
|
|
|
|
pg.init()
|
2018-04-28 17:54:05 +02:00
|
|
|
pg.joystick.init
|
2018-04-10 20:38:18 +02:00
|
|
|
self.screen = pg.display.set_mode((WIDTH, HEIGHT))
|
|
|
|
self.clock = pg.time.Clock()
|
|
|
|
pg.mouse.set_visible(True)
|
|
|
|
pg.display.set_caption(TITLE)
|
|
|
|
pg.key.set_repeat(100, 100)
|
|
|
|
self.loadEverything()
|
|
|
|
if self.debugMode == True:
|
|
|
|
print('debugMode activé')
|
|
|
|
self.washTheScreen()
|
|
|
|
if self.debug():
|
|
|
|
self.clear()
|
|
|
|
self.run()
|
|
|
|
else:
|
2018-04-23 18:58:22 +02:00
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
else:
|
2018-04-23 18:58:22 +02:00
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
|
|
|
|
# >>> HERE'S THE GOD MODE, FOR THE GOD DAMN CREATOR ! >>>
|
|
|
|
def debug(self):
|
|
|
|
print(" =================== WELCOME IN DEBUG MODE ! ==================== ")
|
2018-12-30 15:20:24 +01:00
|
|
|
print(
|
|
|
|
" | [1] - Enter state : | ")
|
|
|
|
print(
|
|
|
|
" | [2] - Cheat Mode : | ")
|
2018-04-10 20:38:18 +02:00
|
|
|
print(" ================================================================ ")
|
|
|
|
self.debugCommand = input("[?] >>> Input something : ")
|
|
|
|
if self.debugCommand == "1":
|
2018-12-30 15:20:24 +01:00
|
|
|
self.clear()
|
|
|
|
print("[i] >>> [mainMenu, newMenu, settingsMenu, helpMenu, playMenu, game]")
|
|
|
|
self.debugState = input("[?] >>> What state to load ? ")
|
|
|
|
self.state = self.debugState
|
2018-04-10 20:38:18 +02:00
|
|
|
return True
|
|
|
|
if self.debugCommand == "2":
|
2018-12-30 15:20:24 +01:00
|
|
|
self.clear()
|
|
|
|
print("[!] Entered in cheat menu.")
|
2018-04-10 20:38:18 +02:00
|
|
|
return False
|
|
|
|
|
|
|
|
# >>> LOAD EVERYTHING WE NEED ONCE FOR ALL >>>
|
|
|
|
def loadEverything(self):
|
|
|
|
gameFolder = os.path.dirname(__file__)
|
|
|
|
imgFolder = os.path.join(gameFolder, 'sprites')
|
2018-12-30 15:20:24 +01:00
|
|
|
plyrSpriteFolder = self.playerFolder = os.path.join(
|
|
|
|
imgFolder, 'player')
|
|
|
|
femaleFolder = self.femaleFolder = os.path.join(
|
|
|
|
plyrSpriteFolder, 'female')
|
|
|
|
maleFolder = self.maleFolder = os.path.join(plyrSpriteFolder, 'male')
|
2018-04-10 20:38:18 +02:00
|
|
|
musicFolder = os.path.join(gameFolder, 'music')
|
2018-12-30 15:20:24 +01:00
|
|
|
fxFolder = os.path.join(musicFolder, 'fx')
|
2018-04-10 20:38:18 +02:00
|
|
|
fontFolder = os.path.join(gameFolder, 'font')
|
|
|
|
loadingFolder = os.path.join(imgFolder, 'loading')
|
|
|
|
menuFolder = os.path.join(imgFolder, 'menus')
|
|
|
|
mapFolder = os.path.join(gameFolder, 'map')
|
2018-12-30 15:20:24 +01:00
|
|
|
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)
|
2018-04-10 20:38:18 +02:00
|
|
|
self.clear = lambda: os.system('cls')
|
2018-12-30 15:20:24 +01:00
|
|
|
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)
|
2018-04-10 20:38:18 +02:00
|
|
|
self.allSprites = pg.sprite.LayeredUpdates()
|
2018-12-30 15:20:24 +01:00
|
|
|
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()
|
2018-04-10 20:38:18 +02:00
|
|
|
self.actualChoicePreview = self.screenWasher
|
|
|
|
self.textColorPlay = self.textColorSettings = self.textColorHelp = self.textColorQuit = self.colorGrey
|
|
|
|
self.textColorContinue = self.textColorNewGame = self.textColorReturn = self.colorGrey
|
|
|
|
self.textColorMale = self.textColorFemale = self.textColorReturn = self.colorGrey
|
|
|
|
self.textColorMusicToggle = self.textColorFullscreenToggle = self.textColordisplayFPSToggle = self.resetSaveColor = self.resetSettingsColor = self.textColorReturn = self.colorGrey
|
|
|
|
self.textColorResume = self.textColorQuitGame = self.textColorMainMenu = self.colorGrey
|
2018-04-28 17:54:05 +02:00
|
|
|
self.textColorMusicPlus = self.textColorMusicMoins = self.textColorFxPlus = self.textColorFxMoins = self.colorGrey
|
2018-05-12 15:08:32 +02:00
|
|
|
self.textColorReturn = self.colorMusicMenu = self.textColorCredits = self.colorGrey
|
|
|
|
self.textColorYes = self.textColorNo = self.textColorMusicMenu = self.textColorBandcamp = self.colorGrey
|
2018-04-10 20:38:18 +02:00
|
|
|
self.lastMove = "+Y"
|
2018-12-30 15:20:24 +01:00
|
|
|
self.mapPosX = self.decalageX
|
|
|
|
self.mapPosY = self.decalageY
|
2018-04-10 20:38:18 +02:00
|
|
|
if os.path.isfile("settings.txt"):
|
|
|
|
settingsSaved = save.readSettings()
|
2018-12-30 15:20:24 +01:00
|
|
|
self.musicState = settingsSaved[0]
|
|
|
|
self.fullscreenState = settingsSaved[1]
|
|
|
|
self.displayFPS = settingsSaved[2]
|
|
|
|
self.musicLevel = float(settingsSaved[3])
|
|
|
|
self.fxLevel = float(settingsSaved[4])
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.fullscreenState == "ON":
|
|
|
|
pg.display.set_mode((WIDTH, HEIGHT), pg.FULLSCREEN)
|
|
|
|
else:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.musicState = "ON"
|
|
|
|
self.displayFPS = "OFF"
|
|
|
|
self.fullscreenState = "OFF"
|
|
|
|
self.musicLevel = 0.5
|
|
|
|
self.fxLevel = 1.0
|
2018-04-10 20:38:18 +02:00
|
|
|
self.wallsList = []
|
|
|
|
for walls in WALLS:
|
|
|
|
self.wallsList.append((walls[0]+self.decalageX, walls[1]+self.decalageY,
|
2018-12-30 15:20:24 +01:00
|
|
|
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'))
|
2018-04-10 20:38:18 +02:00
|
|
|
self.playMusic = pg.mixer.Sound(os.path.join(musicFolder, 'play.ogg'))
|
2018-12-30 15:20:24 +01:00
|
|
|
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'))
|
2018-04-28 17:54:05 +02:00
|
|
|
print("Joystick/Controller detected : " + str(pg.joystick.get_count()))
|
|
|
|
if pg.joystick.get_count() >= 1:
|
|
|
|
pg.joystick.Joystick(0).init()
|
|
|
|
print("Hats detected : " + str(pg.joystick.Joystick(0).get_numhats()))
|
|
|
|
print("Joystick name : " + str(pg.joystick.Joystick(0).get_name()))
|
2018-04-10 20:38:18 +02:00
|
|
|
|
2018-04-23 18:58:22 +02:00
|
|
|
# >>> CHANGE THE MENU YOU ARE INTO >>>
|
2018-12-30 15:20:24 +01:00
|
|
|
def changeMenu(self, nextState):
|
|
|
|
pg.key.set_repeat(0, 100)
|
|
|
|
self.previousState = self.state
|
|
|
|
pg.mouse.set_visible(True)
|
2018-04-23 18:58:22 +02:00
|
|
|
if nextState == "pause":
|
2018-12-30 15:20:24 +01:00
|
|
|
self.screen.blit(self.dimScreen, (0, 0))
|
2018-04-28 17:54:05 +02:00
|
|
|
save.saveGame(self.gender, self.lifeLevel, self.gameLevel)
|
2018-04-23 18:58:22 +02:00
|
|
|
if self.musicState == "ON" and pg.mixer.Channel(0).get_busy():
|
|
|
|
pg.mixer.Channel(0).pause()
|
|
|
|
else:
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.musicState == "ON":
|
|
|
|
pg.mixer.Channel(1).play(self.changeMenuFx, 0)
|
2018-04-23 18:58:22 +02:00
|
|
|
self.washTheScreen()
|
|
|
|
if nextState == "mainMenu":
|
|
|
|
if not pg.mixer.Channel(0).get_busy() or pg.mixer.Channel(0).get_sound() != self.mainMenuMusic:
|
|
|
|
if self.musicState == "ON":
|
|
|
|
pg.mixer.Channel(0).play(self.mainMenuMusic, -1)
|
|
|
|
self.state = nextState
|
2018-05-12 15:08:32 +02:00
|
|
|
if self.state != 'loading':
|
2018-12-30 15:20:24 +01:00
|
|
|
self.screen.blit(self.warningVersion, (0, 0))
|
2018-04-10 20:38:18 +02:00
|
|
|
self.run()
|
|
|
|
|
|
|
|
# >>> LET THE MAGIC HAPPEN >>>
|
|
|
|
def continueGame(self):
|
|
|
|
pg.mouse.set_visible(False)
|
|
|
|
if self.musicState == "ON":
|
|
|
|
if pg.mixer.Channel(0).get_sound() != self.playMusic:
|
|
|
|
pg.mixer.Channel(0).play(self.playMusic, -1)
|
|
|
|
if self.state == 'pause':
|
|
|
|
pg.mixer.Channel(0).unpause()
|
|
|
|
actualGame = save.readGame()
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-22 20:43:27 +02:00
|
|
|
if self.gender == 'male':
|
|
|
|
self.playerImg = self.playerImgMale
|
|
|
|
else:
|
|
|
|
self.playerImg = self.playerImgFemale
|
2018-04-10 20:38:18 +02:00
|
|
|
self.picCoordinates = playerAnimation('noneDown', self.gender)
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
pg.key.set_repeat(100, 100)
|
|
|
|
self.previousState = self.state
|
2018-04-10 20:38:18 +02:00
|
|
|
self.state = 'game'
|
|
|
|
self.run()
|
|
|
|
|
|
|
|
# >>> TOGGLE FULLSCREEN MODE >>>
|
|
|
|
def toggleFullscreen(self):
|
|
|
|
if self.screen.get_flags() != pg.FULLSCREEN:
|
2018-12-30 15:20:24 +01:00
|
|
|
pg.display.set_mode((WIDTH, HEIGHT), pg.FULLSCREEN)
|
|
|
|
self.fullscreenState = "ON"
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.musicState == "ON":
|
|
|
|
pg.mixer.Channel(1).play(self.positiveFx, 0)
|
2018-04-10 20:38:18 +02:00
|
|
|
else:
|
2018-12-30 15:20:24 +01:00
|
|
|
pg.display.set_mode((WIDTH, HEIGHT))
|
|
|
|
self.fullscreenState = "OFF"
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.musicState == "ON":
|
|
|
|
pg.mixer.Channel(1).play(self.negativeFx, 0)
|
2018-04-10 20:38:18 +02:00
|
|
|
|
|
|
|
# >>> TOGGLE MUSIC STATE >>>
|
|
|
|
def toggleMusic(self):
|
|
|
|
if self.musicState == "ON":
|
|
|
|
self.musicState = "OFF"
|
|
|
|
if pg.mixer.Channel(0).get_busy():
|
|
|
|
pg.mixer.Channel(0).stop()
|
|
|
|
else:
|
|
|
|
self.musicState = "ON"
|
|
|
|
pg.mixer.Channel(0).play(self.mainMenuMusic, -1)
|
2018-04-28 17:54:05 +02:00
|
|
|
pg.mixer.Channel(1).play(self.positiveFx, 0)
|
2018-04-10 20:38:18 +02:00
|
|
|
|
|
|
|
# >>> TOGGLE FPS COUNTER >>>
|
|
|
|
def toggleFPS(self):
|
|
|
|
if self.displayFPS == "ON":
|
|
|
|
self.displayFPS = "OFF"
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.musicState == "ON":
|
|
|
|
pg.mixer.Channel(1).play(self.negativeFx, 0)
|
2018-04-10 20:38:18 +02:00
|
|
|
else:
|
|
|
|
self.displayFPS = "ON"
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.musicState == "ON":
|
|
|
|
pg.mixer.Channel(1).play(self.positiveFx, 0)
|
2018-04-10 20:38:18 +02:00
|
|
|
|
|
|
|
# >>> INFINITE LOOP TO LISTEN KEYS AND THEN RENDER WINDOW >>>
|
|
|
|
def run(self):
|
|
|
|
while True:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.clock.tick(60)
|
|
|
|
self.lastUpdate = pg.time.get_ticks()
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.displayFPS == "ON":
|
2018-12-30 15:20:24 +01:00
|
|
|
pg.display.set_caption(
|
|
|
|
str(TITLE)+" -- FPS :"+str(int(self.clock.get_fps())))
|
2018-04-10 20:38:18 +02:00
|
|
|
else:
|
|
|
|
pg.display.set_caption(TITLE)
|
|
|
|
self.renderWindow()
|
|
|
|
if self.state == "game":
|
|
|
|
self.collideWithWalls()
|
2018-12-30 15:20:24 +01:00
|
|
|
pg.mixer.Channel(0).set_volume(self.musicLevel)
|
|
|
|
pg.mixer.Channel(1).set_volume(self.fxLevel)
|
2018-04-10 20:38:18 +02:00
|
|
|
self.KeyListener()
|
|
|
|
|
|
|
|
# >>> COLLISION DETECTION (WITH WALLS OF COURSE) >>>
|
|
|
|
def collideWithWalls(self):
|
|
|
|
for walls in self.wallsList:
|
|
|
|
if self.persoRect.colliderect(walls):
|
|
|
|
if self.lastMove == "+X":
|
|
|
|
self.posX -= 16
|
|
|
|
elif self.lastMove == "+Y":
|
|
|
|
self.posY -= 16
|
|
|
|
elif self.lastMove == "-X":
|
|
|
|
self.posX += 16
|
|
|
|
elif self.lastMove == "-Y":
|
|
|
|
self.posY += 16
|
|
|
|
|
|
|
|
# >>> SCROLLING SYSTEM >>>
|
|
|
|
def scrolling(self):
|
|
|
|
reload = 0
|
|
|
|
if self.posX+128 >= WIDTH:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.mapPosX += 16
|
|
|
|
self.decalageX += 16
|
|
|
|
self.posX += 16
|
|
|
|
reload += 1
|
2018-04-10 20:38:18 +02:00
|
|
|
elif self.posY+128 >= HEIGHT:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.mapPosY -= 16
|
|
|
|
self.decalageY -= 16
|
|
|
|
self.posY -= 16
|
|
|
|
reload += 1
|
2018-04-10 20:38:18 +02:00
|
|
|
elif self.posX-128 <= 0:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.mapPosX -= 16
|
|
|
|
self.decalageX -= 16
|
|
|
|
self.posX -= 16
|
|
|
|
reload += 1
|
2018-04-10 20:38:18 +02:00
|
|
|
elif self.posY-128 <= 0:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.mapPosY += 16
|
|
|
|
self.decalageY += 16
|
|
|
|
self.posY += 16
|
|
|
|
reload += 1
|
2018-04-10 20:38:18 +02:00
|
|
|
if reload != 0:
|
|
|
|
self.wallsList = []
|
|
|
|
for walls in WALLS:
|
|
|
|
self.wallsList.append((walls[0]+self.decalageX, walls[1]+self.decalageY,
|
2018-12-30 15:20:24 +01:00
|
|
|
walls[2], walls[3]))
|
2018-04-10 20:38:18 +02:00
|
|
|
|
2018-04-28 17:54:05 +02:00
|
|
|
# >>> NICE DIALOG BOX >>>
|
|
|
|
def dialogBoxShow(self, character, text):
|
2018-12-30 15:20:24 +01:00
|
|
|
pg.key.set_repeat(0, 100)
|
|
|
|
self.previousState = self.state
|
|
|
|
pg.mouse.set_visible(True)
|
2018-04-28 17:54:05 +02:00
|
|
|
save.saveGame(self.gender, self.lifeLevel, self.gameLevel)
|
2018-12-30 15:20:24 +01:00
|
|
|
self.screen.blit(self.dimScreen, (0, 0))
|
2018-04-28 17:54:05 +02:00
|
|
|
character += str(" said :")
|
2018-12-30 15:20:24 +01:00
|
|
|
self.whoSpoke = character
|
|
|
|
self.textDialog = text
|
2018-04-28 17:54:05 +02:00
|
|
|
self.state = "dialog"
|
|
|
|
self.run()
|
|
|
|
|
|
|
|
# >>> CHANGE MUSIC AND EFFECTS VOLUME >>>
|
|
|
|
def changeVolume(self, channel, moreOrLess):
|
|
|
|
self.washTheScreen()
|
|
|
|
if moreOrLess == "more":
|
|
|
|
if channel == "music":
|
|
|
|
self.musicLevel += 0.25
|
|
|
|
if self.musicLevel >= 1.25:
|
|
|
|
self.musicLevel = 1.0
|
|
|
|
if channel == "fx":
|
|
|
|
self.fxLevel += 0.25
|
|
|
|
if self.fxLevel >= 1.25:
|
|
|
|
self.fxLevel = 1.0
|
|
|
|
if moreOrLess == "less":
|
|
|
|
if channel == "music":
|
|
|
|
self.musicLevel -= 0.25
|
2018-05-12 15:08:32 +02:00
|
|
|
if self.musicLevel <= -0.25:
|
|
|
|
self.musicLevel = 0.0
|
2018-04-28 17:54:05 +02:00
|
|
|
if channel == "fx":
|
|
|
|
self.fxLevel -= 0.25
|
2018-05-12 15:08:32 +02:00
|
|
|
if self.fxLevel <= -0.25:
|
|
|
|
self.fxLevel = 0.0
|
2018-04-28 17:54:05 +02:00
|
|
|
|
2018-04-10 20:38:18 +02:00
|
|
|
# >>> LISTEN INPUT FROM PLAYER (MOUSE, KEYS,...) >>>
|
|
|
|
def KeyListener(self):
|
|
|
|
# ========================================== GAME STATE ====================================================== #
|
|
|
|
if self.state == 'game':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if event.type == pg.KEYDOWN:
|
2018-04-28 17:54:05 +02:00
|
|
|
#print("Your position is X=" + str(self.posX) + " and Y=" + str(self.posY))
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_s or event.key == pg.K_DOWN:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.picCoordinates = playerAnimation(
|
|
|
|
'down', self.gender)
|
|
|
|
self.posY += 16
|
|
|
|
self.lastMove = "+Y"
|
|
|
|
self.scrolling()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_d or event.key == pg.K_RIGHT:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.picCoordinates = playerAnimation(
|
|
|
|
'right', self.gender)
|
|
|
|
self.posX += 16
|
|
|
|
self.lastMove = "+X"
|
|
|
|
self.scrolling()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_w or event.key == pg.K_UP:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.picCoordinates = playerAnimation(
|
|
|
|
'up', self.gender)
|
|
|
|
self.posY -= 16
|
|
|
|
self.lastMove = "-Y"
|
|
|
|
self.scrolling()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_a or event.key == pg.K_LEFT:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.picCoordinates = playerAnimation(
|
|
|
|
'left', self.gender)
|
|
|
|
self.posX -= 16
|
|
|
|
self.lastMove = "-X"
|
|
|
|
self.scrolling()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_ESCAPE:
|
2018-04-26 19:32:01 +02:00
|
|
|
self.changeMenu("pause")
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.posX >= 975 and self.posY <= 995:
|
|
|
|
if self.posY >= 285:
|
|
|
|
if not L1EVENTLIST[0]:
|
|
|
|
L1EVENTLIST[0] = True
|
2018-12-30 15:20:24 +01:00
|
|
|
self.dialogBoxShow(
|
|
|
|
"GOD", ["Welcome in this game.", "Enjoy! And please report bugs."])
|
2018-04-26 21:01:01 +02:00
|
|
|
if event.key == pg.K_F11:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.toggleFullscreen()
|
|
|
|
print('fullscreen toggled to ' +
|
|
|
|
str(self.fullscreenState))
|
2018-04-10 20:38:18 +02:00
|
|
|
elif event.type == pg.KEYUP:
|
|
|
|
if self.lastMove == "+Y":
|
2018-12-30 15:20:24 +01:00
|
|
|
self.picCoordinates = playerAnimation(
|
|
|
|
'noneDown', self.gender)
|
2018-04-10 20:38:18 +02:00
|
|
|
elif self.lastMove == "+X":
|
2018-12-30 15:20:24 +01:00
|
|
|
self.picCoordinates = playerAnimation(
|
|
|
|
'noneRight', self.gender)
|
2018-04-10 20:38:18 +02:00
|
|
|
elif self.lastMove == "-X":
|
2018-12-30 15:20:24 +01:00
|
|
|
self.picCoordinates = playerAnimation(
|
|
|
|
'noneLeft', self.gender)
|
2018-04-10 20:38:18 +02:00
|
|
|
elif self.lastMove == "-Y":
|
2018-12-30 15:20:24 +01:00
|
|
|
self.picCoordinates = playerAnimation(
|
|
|
|
'noneUp', self.gender)
|
2018-04-28 17:54:05 +02:00
|
|
|
elif event.type == pg.QUIT:
|
2018-04-25 17:50:36 +02:00
|
|
|
self.changeMenu("pause")
|
2018-04-28 17:54:05 +02:00
|
|
|
# ========================================== DIALOG BOX ====================================================== #
|
|
|
|
if self.state == 'dialog':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if event.type == pg.KEYUP and event.key == pg.K_RETURN:
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
# ========================================== PAUSE SCREEN ==================================================== #
|
|
|
|
if self.state == 'pause':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if self.resumeBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorResume = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('resume game')
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorResume = self.colorGrey
|
|
|
|
if self.mainMenuBlit.collidepoint(pg.mouse.get_pos()) == True:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.textColorMainMenu = self.colorWhite
|
|
|
|
self.actualChoicePreview = self.malePreview
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("main menu")
|
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorMainMenu = self.colorGrey
|
|
|
|
if self.quitGameBlit.collidepoint(pg.mouse.get_pos()) == True:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.textColorQuitGame = self.colorWhite
|
|
|
|
self.actualChoicePreview = self.femalePreview
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("quit game")
|
|
|
|
self.changeMenu("areYouSureToQuit")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorQuitGame = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
2018-04-27 08:31:48 +02:00
|
|
|
if event.key == pg.K_a:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("quit")
|
|
|
|
self.changeMenu("areYouSureToQuit")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_r or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("resume game")
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_SEMICOLON:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("main menu")
|
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.QUIT:
|
|
|
|
self.quit()
|
|
|
|
# ========================================== NEW GAME ======================================================== #
|
|
|
|
if self.state == 'newGame':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorReturn = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorReturn = self.colorGrey
|
|
|
|
if self.maleChoiceBlit.collidepoint(pg.mouse.get_pos()) == True:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.textColorMale = self.colorWhite
|
|
|
|
self.actualChoicePreview = self.malePreview
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("male")
|
|
|
|
save.newGame("male")
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.textColorMale = self.colorGrey
|
|
|
|
self.actualChoicePreview = self.screenWasher
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.femaleChoiceBlit.collidepoint(pg.mouse.get_pos()) == True:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.textColorFemale = self.colorWhite
|
|
|
|
self.actualChoicePreview = self.femalePreview
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("female")
|
|
|
|
save.newGame("female")
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorFemale = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
|
|
|
if event.key == pg.K_f:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("female")
|
|
|
|
save.newGame("female")
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_SEMICOLON:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("male")
|
|
|
|
save.newGame("male")
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_r or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("return")
|
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.QUIT:
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("areYouSureToQuit")
|
2018-05-12 15:08:32 +02:00
|
|
|
# ========================================== MUSIC MENU ==================================================== #
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.state == 'musicMenu':
|
2018-04-10 20:38:18 +02:00
|
|
|
for event in pg.event.get():
|
|
|
|
if self.musicToggleBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorMusicToggle = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.toggleMusic()
|
|
|
|
print('music toggle to ' + str(self.musicState))
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorMusicToggle = self.colorGrey
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.musicButtonMoinsBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorMusicMoins = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.changeVolume("music", "less")
|
|
|
|
print("music - volume set to " + str(self.musicLevel))
|
2018-04-28 17:54:05 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.changeVolume("music", "more")
|
|
|
|
print("music + volume set to " + str(self.musicLevel))
|
2018-04-28 17:54:05 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.changeVolume("fx", "less")
|
|
|
|
print("fx - volume set to " + str(self.musicLevel))
|
2018-04-28 17:54:05 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.changeVolume("fx", "more")
|
|
|
|
print("fx + volume set to " + str(self.musicLevel))
|
2018-04-28 17:54:05 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
save.saveSettings(
|
|
|
|
self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel)
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("settingsMenu")
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorReturn = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
|
|
|
if event.key == pg.K_SEMICOLON:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.toggleMusic()
|
|
|
|
print('toggle music')
|
2018-04-28 17:54:05 +02:00
|
|
|
if event.key == pg.K_r or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
save.saveSettings(
|
|
|
|
self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel)
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("settingsMenu")
|
|
|
|
if event.type == pg.QUIT:
|
|
|
|
self.changeMenu("areYouSureToQuit")
|
|
|
|
# ========================================== SETTINGS MENU 2 ================================================= #
|
|
|
|
if self.state == 'settingsMenu':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if self.musicMenuBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorMusicMenu = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
print('music menu')
|
|
|
|
self.changeMenu("musicMenu")
|
2018-04-28 17:54:05 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorMusicMenu = self.colorGrey
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.fullScreenToggleBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorFullscreenToggle = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.toggleFullscreen()
|
|
|
|
print('fullscreen toggle to ' +
|
|
|
|
str(self.fullscreenState))
|
2018-04-10 20:38:18 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.lastDestroy = "saves"
|
|
|
|
self.changeMenu("areYouSureToDestroy")
|
2018-04-10 20:38:18 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.lastDestroy = "settings"
|
|
|
|
self.changeMenu("areYouSureToDestroy")
|
2018-04-10 20:38:18 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.toggleFPS()
|
|
|
|
print('displayFPS toggle to ' + str(self.displayFPS))
|
2018-04-10 20:38:18 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
save.saveSettings(
|
|
|
|
self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel)
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorReturn = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
2018-04-28 17:54:05 +02:00
|
|
|
if event.key == pg.K_q:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.changeMenu("musicMenu")
|
|
|
|
print('music menu')
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_f:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.toggleFullscreen()
|
|
|
|
print('fullscreen toggle to ' +
|
|
|
|
str(self.fullscreenState))
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_c:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.washTheScreen()
|
|
|
|
self.toggleFPS()
|
|
|
|
print('displayFPS toggle to ' + str(self.displayFPS))
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_r or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
save.saveSettings(
|
|
|
|
self.musicState, self.fullscreenState, self.displayFPS, self.musicLevel, self.fxLevel)
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.QUIT:
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("areYouSureToQuit")
|
2018-04-10 20:38:18 +02:00
|
|
|
# ========================================== SURE TO QUIT SCREEN ============================================= #
|
|
|
|
if self.state == 'areYouSureToQuit':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if self.yesBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorYes = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('yes')
|
|
|
|
self.quit()
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorYes = self.colorGrey
|
|
|
|
if self.noBlit.collidepoint(pg.mouse.get_pos()) == True:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.textColorNo = self.colorWhite
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('no')
|
|
|
|
self.changeMenu(self.previousState)
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorNo = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
|
|
|
if event.key == pg.K_y:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('yes')
|
|
|
|
self.quit()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_n or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('no')
|
|
|
|
self.changeMenu(self.previousState)
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.QUIT:
|
|
|
|
self.quit()
|
|
|
|
# ========================================== SURE TO DESTROY SCREEN ========================================== #
|
|
|
|
if self.state == 'areYouSureToDestroy':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if self.yesBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorYes = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
|
|
|
print('reset ' + str(self.lastDestroy))
|
|
|
|
if self.lastDestroy == "settings":
|
2018-12-30 15:20:24 +01:00
|
|
|
save.resetSettings()
|
|
|
|
self.restartGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
elif self.lastDestroy == "saves":
|
2018-12-30 15:20:24 +01:00
|
|
|
save.resetSave()
|
|
|
|
self.changeMenu("settingsMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorYes = self.colorGrey
|
|
|
|
if self.noBlit.collidepoint(pg.mouse.get_pos()) == True:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.textColorNo = self.colorWhite
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('no')
|
|
|
|
self.changeMenu("settingsMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorNo = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
|
|
|
if event.key == pg.K_y:
|
|
|
|
print('reset ' + str(self.lastDestroy))
|
|
|
|
if self.lastDestroy == "settings":
|
2018-12-30 15:20:24 +01:00
|
|
|
save.resetSettings()
|
|
|
|
self.restartGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
elif self.lastDestroy == "saves":
|
2018-12-30 15:20:24 +01:00
|
|
|
save.resetSave()
|
|
|
|
self.changeMenu("settingsMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_n or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('no')
|
|
|
|
self.changeMenu("settingsMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.QUIT:
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("areYouSureToDestroy")
|
2018-04-10 20:38:18 +02:00
|
|
|
# ========================================== PLAY MENU ======================================================= #
|
|
|
|
if self.state == 'playMenu':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if os.path.isfile("savegames.txt") == True:
|
|
|
|
if self.continueBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorContinue = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('continue')
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorContinue = self.colorGrey
|
|
|
|
else:
|
|
|
|
if self.newGameBlit.collidepoint(pg.mouse.get_pos()) == True:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.textColorNewGame = self.colorWhite
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('new game')
|
|
|
|
self.changeMenu("newGame")
|
2018-04-10 20:38:18 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorReturn = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
|
|
|
if event.key == pg.K_c:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('continue')
|
|
|
|
self.continueGame()
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_n:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('new game')
|
|
|
|
self.changeMenu("newGame")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_r or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.QUIT:
|
2018-12-30 15:20:24 +01:00
|
|
|
self.changeMenu("areYouSureToQuit")
|
|
|
|
print('quit')
|
2018-04-10 20:38:18 +02:00
|
|
|
# ========================================== 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:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('play')
|
|
|
|
self.changeMenu("playMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('settings')
|
|
|
|
self.changeMenu("settingsMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('help')
|
|
|
|
self.changeMenu("helpMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
print("quit")
|
|
|
|
self.changeMenu("areYouSureToQuit")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorQuit = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
|
|
|
if event.key == pg.K_p:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('play')
|
|
|
|
self.changeMenu("playMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_s:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('settings')
|
|
|
|
self.changeMenu("settingsMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_h:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('help')
|
|
|
|
self.changeMenu("helpMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.key == pg.K_a or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('quit')
|
|
|
|
self.changeMenu("areYouSureToQuit")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.QUIT:
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("areYouSureToQuit")
|
2018-04-10 20:38:18 +02:00
|
|
|
# ========================================== HELP MENU ======================================================= #
|
|
|
|
if self.state == 'helpMenu':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorReturn = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
self.changeMenu("mainMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorReturn = self.colorGrey
|
2018-05-12 15:08:32 +02:00
|
|
|
if self.creditsBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorCredits = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('credits menu')
|
|
|
|
self.changeMenu("creditsMenu")
|
2018-05-12 15:08:32 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorCredits = self.colorGrey
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.KEYDOWN:
|
|
|
|
if event.key == pg.K_r or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
self.changeMenu("mainMenu")
|
|
|
|
if event.key == pg.K_r or event.key == pg.K_c:
|
|
|
|
print('credits menu')
|
|
|
|
self.changeMenu("creditsMenu")
|
2018-05-12 15:08:32 +02:00
|
|
|
if event.type == pg.QUIT:
|
|
|
|
self.changeMenu("areYouSureToQuit")
|
|
|
|
# ========================================== CREDITS MENU =================================================== #
|
|
|
|
if self.state == 'creditsMenu':
|
|
|
|
for event in pg.event.get():
|
|
|
|
if self.returnBlit.collidepoint(pg.mouse.get_pos()) == True:
|
|
|
|
self.textColorReturn = self.colorWhite
|
|
|
|
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
self.changeMenu("helpMenu")
|
2018-05-12 15:08:32 +02:00
|
|
|
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:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('open bandcamp')
|
|
|
|
webbrowser.open("https://donbor.bandcamp.com", new=2)
|
2018-05-12 15:08:32 +02:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.textColorBandcamp = self.colorGrey
|
|
|
|
if event.type == pg.KEYDOWN:
|
|
|
|
if event.key == pg.K_r or event.key == pg.K_ESCAPE:
|
2018-12-30 15:20:24 +01:00
|
|
|
print('return')
|
|
|
|
self.changeMenu("helpMenu")
|
2018-04-10 20:38:18 +02:00
|
|
|
if event.type == pg.QUIT:
|
2018-04-28 17:54:05 +02:00
|
|
|
self.changeMenu("areYouSureToQuit")
|
2018-04-10 20:38:18 +02:00
|
|
|
|
|
|
|
# >>> RENDER THE WINDOW. REALLY. >>>
|
|
|
|
def renderWindow(self):
|
|
|
|
if self.state == 'loadingScreen':
|
2018-12-30 15:20:24 +01:00
|
|
|
self.loadingBlit = self.screen.blit(self.loadingScreen, (0, 0))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'mainMenu':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'playMenu':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
else:
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'newGame':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'settingsMenu':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.state == 'musicMenu':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'helpMenu':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-05-12 15:08:32 +02:00
|
|
|
if self.state == 'creditsMenu':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'areYouSureToQuit':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'areYouSureToDestroy':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'pause':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
if self.state == 'game':
|
2018-12-30 15:20:24 +01:00
|
|
|
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)
|
2018-04-28 17:54:05 +02:00
|
|
|
if self.state == 'dialog':
|
2018-12-30 15:20:24 +01:00
|
|
|
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))
|
2018-04-10 20:38:18 +02:00
|
|
|
pg.display.update()
|
|
|
|
|
2018-04-28 17:54:05 +02:00
|
|
|
# >>> WASH THE SCREEN >>>
|
|
|
|
def washTheScreen(self):
|
2018-12-30 15:20:24 +01:00
|
|
|
self.screen.blit(self.screenWasher, (0, 0))
|
2018-05-12 15:08:32 +02:00
|
|
|
if self.state != 'loading':
|
2018-12-30 15:20:24 +01:00
|
|
|
self.screen.blit(self.warningVersion, (0, 0))
|
2018-04-28 17:54:05 +02:00
|
|
|
pg.display.update()
|
|
|
|
|
2018-04-10 20:38:18 +02:00
|
|
|
# >>> DO YOU REALLY NEED COMMENTS FOR THIS ONE ? >>>
|
|
|
|
def quit(self):
|
|
|
|
pg.quit()
|
2018-12-30 15:20:24 +01:00
|
|
|
# sys.exit()
|
2018-04-10 20:38:18 +02:00
|
|
|
|
|
|
|
# >>> RESTART THE WHOLE GAME >>>
|
|
|
|
def restartGame(self):
|
|
|
|
os.startfile(r"core.py")
|
|
|
|
self.quit()
|
|
|
|
|
2018-12-30 15:20:24 +01:00
|
|
|
|
2018-04-10 20:38:18 +02:00
|
|
|
Game()
|