added Male support and reorganizing playerCoordinates

[IN SOURCE CODE ONLY]
because now male can play.
and because being organized is better. Even in code.
This commit is contained in:
SergentThomasKelly 2018-04-22 20:43:27 +02:00
parent c906edb121
commit ade89a45ee
2 changed files with 35 additions and 28 deletions

View File

@ -78,7 +78,8 @@ class Game:
self.mapPic = pg.image.load(os.path.join(mapFolder, 'l1.png')).convert_alpha() 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.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.dimScreen = pg.Surface(self.screen.get_size()).convert_alpha(); self.dimScreen.fill((0, 0, 0, 200))
self.playerImgFemale = self.playerImg = pg.image.load(os.path.join(femaleFolder, 'ante.png')).convert_alpha() 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.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.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.menuNukem = pg.image.load(os.path.join(menuFolder, "main.jpg")).convert(); self.menuNukem = pg.transform.scale(self.menuNukem, (500,500))
@ -164,6 +165,10 @@ class Game:
actualGame = save.readGame() actualGame = save.readGame()
self.gender = actualGame[0]; self.lifeLevel = actualGame[1]; self.gameLevel = actualGame[2] 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)) 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.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.state = 'game'
@ -331,15 +336,14 @@ class Game:
if self.maleChoiceBlit.collidepoint(pg.mouse.get_pos()) == True: 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: if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
print("male"); """save.newGame("male")""" print("male"); save.newGame("male"); self.continueGame()
print("YOU CAN ONLY PLAY FEMALE FOR NOW")
break break
else: 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: 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: if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
print("female"); save.newGame("female"); self.gender = "female"; self.continueGame() print("female"); save.newGame("female"); self.continueGame()
break break
else: else:
self.textColorFemale = self.colorGrey self.textColorFemale = self.colorGrey

View File

@ -7,39 +7,42 @@ vec = math.Vector2
WIDTH = 1280 WIDTH = 1280
HEIGHT = 720 HEIGHT = 720
TITLE = "EXODUS (PRE-BETA RELEASE -- GITHUB EDITION)" TITLE = "EXODUS (PRE-BETA RELEASE -- GITHUB EDITION)"
perso_x = 1280/2
perso_y = 720/2
playerAnimationLoop = 1 playerAnimationLoop = 1
f_playerCoordinatesDown = {1:(2,0,30,33), 2:(32,0,33,32), 3:(64,0,31,33)} playerCoordinates = {"female":{"down":{1:(2,0,30,33), 2:(32,0,33,32), 3:(64,0,31,33)},
f_playerCoordinatesLeft = {1:(4,33,27,31), 2:(36,32,25,33), 3:(68,33,24,31)} "left":{1:(4,33,27,31), 2:(36,32,25,33), 3:(68,33,24,31)},
f_playerCoordinatesRight = {1:(1,65,27,31), 2:(35,64,25,32), 3:(68,65,24,31)} "right":{1:(1,65,27,31), 2:(35,64,25,32), 3:(68,65,24,31)},
f_playerCoordinatesUp = {1:(3,97,28,31), 2:(33,96,31,32), 3:(66,97,28,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 # # PLAYER ANIMATION #
################################################################################ ################################################################################
def playerAnimation(direction, gender): def playerAnimation(direction, gender):
global playerCoordinatesDown, playerAnimationLoop global playerCoordinates, playerAnimationLoop
playerAnimationLoop += 2 playerAnimationLoop += 2
if playerAnimationLoop >= 4: if playerAnimationLoop >= 4:
playerAnimationLoop = 1 playerAnimationLoop = 1
if gender == 'female': playerCoordinatesLast = playerCoordinates[gender]
if direction == 'down': if direction == 'down' or direction == 'up' or direction == 'left' or direction == 'right':
return f_playerCoordinatesDown[playerAnimationLoop] playerCoordinatesLast = playerCoordinatesLast[direction]
return playerCoordinatesLast[playerAnimationLoop]
elif direction == 'noneDown': elif direction == 'noneDown':
return f_playerCoordinatesDown[2] playerCoordinatesLast = playerCoordinatesLast["down"]
elif direction == 'left': return playerCoordinatesLast[2]
return f_playerCoordinatesLeft[playerAnimationLoop]
elif direction == 'noneLeft': elif direction == 'noneLeft':
return f_playerCoordinatesLeft[2] playerCoordinatesLast = playerCoordinatesLast["left"]
elif direction == 'right': return playerCoordinatesLast[playerAnimationLoop]
return f_playerCoordinatesRight[playerAnimationLoop]
elif direction == 'noneRight': elif direction == 'noneRight':
return f_playerCoordinatesRight[2] playerCoordinatesLast = playerCoordinatesLast["right"]
elif direction == 'up': return playerCoordinatesLast[2]
return f_playerCoordinatesUp[playerAnimationLoop]
elif direction == 'noneUp': elif direction == 'noneUp':
return f_playerCoordinatesUp[2] playerCoordinatesLast = playerCoordinatesLast["up"]
return playerCoordinatesLast[2]
POS = (753.00,143.67) POS = (753.00,143.67)