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.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 = 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.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))
@ -164,6 +165,10 @@ class Game:
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))
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.state = 'game'
@ -331,15 +336,14 @@ class Game:
if self.maleChoiceBlit.collidepoint(pg.mouse.get_pos()) == True:
self.textColorMale = self.colorWhite; self.actualChoicePreview = self.malePreview
if event.type == pg.MOUSEBUTTONDOWN and event.button == 1:
print("male"); """save.newGame("male")"""
print("YOU CAN ONLY PLAY FEMALE FOR NOW")
print("male"); save.newGame("male"); self.continueGame()
break
else:
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
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
else:
self.textColorFemale = self.colorGrey

View File

@ -7,39 +7,42 @@ vec = math.Vector2
WIDTH = 1280
HEIGHT = 720
TITLE = "EXODUS (PRE-BETA RELEASE -- GITHUB EDITION)"
perso_x = 1280/2
perso_y = 720/2
playerAnimationLoop = 1
f_playerCoordinatesDown = {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)}
f_playerCoordinatesRight = {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)}
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 playerCoordinatesDown, playerAnimationLoop
global playerCoordinates, playerAnimationLoop
playerAnimationLoop += 2
if playerAnimationLoop >= 4:
playerAnimationLoop = 1
if gender == 'female':
if direction == 'down':
return f_playerCoordinatesDown[playerAnimationLoop]
elif direction == 'noneDown':
return f_playerCoordinatesDown[2]
elif direction == 'left':
return f_playerCoordinatesLeft[playerAnimationLoop]
elif direction == 'noneLeft':
return f_playerCoordinatesLeft[2]
elif direction == 'right':
return f_playerCoordinatesRight[playerAnimationLoop]
elif direction == 'noneRight':
return f_playerCoordinatesRight[2]
elif direction == 'up':
return f_playerCoordinatesUp[playerAnimationLoop]
elif direction == 'noneUp':
return f_playerCoordinatesUp[2]
playerCoordinatesLast = playerCoordinates[gender]
if direction == 'down' or direction == 'up' or direction == 'left' or direction == 'right':
playerCoordinatesLast = playerCoordinatesLast[direction]
return playerCoordinatesLast[playerAnimationLoop]
elif direction == 'noneDown':
playerCoordinatesLast = playerCoordinatesLast["down"]
return playerCoordinatesLast[2]
elif direction == 'noneLeft':
playerCoordinatesLast = playerCoordinatesLast["left"]
return playerCoordinatesLast[playerAnimationLoop]
elif direction == 'noneRight':
playerCoordinatesLast = playerCoordinatesLast["right"]
return playerCoordinatesLast[2]
elif direction == 'noneUp':
playerCoordinatesLast = playerCoordinatesLast["up"]
return playerCoordinatesLast[2]
POS = (753.00,143.67)