diff --git a/assets/Interface/money.webp b/assets/Interface/money.webp new file mode 100644 index 0000000000000000000000000000000000000000..638cb88455852ec8afdbbbf12070a645d79cb3ed Binary files /dev/null and b/assets/Interface/money.webp differ diff --git a/assets/Temps/ensoleillee.png b/assets/Temps/ensoleillee.png new file mode 100644 index 0000000000000000000000000000000000000000..75e3024948bf6bed7af9f10eefdae966cdcbbbc4 Binary files /dev/null and b/assets/Temps/ensoleillee.png differ diff --git a/src/Champs.py b/src/Champs.py old mode 100755 new mode 100644 index 2302bfa7168a3219dae7fa349e82976d0a20bd55..480c8980f228c8b36103025439a2329ad82f1b1e --- a/src/Champs.py +++ b/src/Champs.py @@ -3,15 +3,17 @@ import numpy as np from Temps import * from Image import transformImage -listeImage = [pygame.transform.scale(pygame.image.load('../assets/Plantation/crop'+str(i)+'phase.png'),(120,120)) for i in range(1,5)] - +listeImage = [transformImage(pygame.image.load('../assets/Plantation/crop'+str(i)+'phase.png'), 120, 120) for i in range(1,5)] +iconStaticSize = (100,100) #TODO : mettre une proba que les plantes meurent si il fait trop froid/chaud, et baisser cette proba de mourir avec une serre ou des torche pour l'hiver class Champs: - iconInsecteStatic = pygame.transform.scale(pygame.image.load("../assets/Plantation/leech.png"),(90,90)) + def __init__ (self, temperature, humidite, tempsAvantMaturation, pos, image): + self.PourcentagePlanteFane = 10 + self.temperature = temperature self.humidite = humidite self.TAM = tempsAvantMaturation @@ -25,40 +27,32 @@ class Champs: self.indiceImage = 0 self.champZoom = pygame.rect.Rect(self.pos,self.imgZoom.get_rect().size) self.isInfeste = False + self.descripteurChamps = { - "Temperature" : None, - "Humidite" : None, - "Acidite" : None, "Occupe" : None, + #"Nom" : None + } + self.imageSurfaceinfo = { - "Temperature" : None, - "Humidite" : None, - "Acidite" : None, "Occupe" : None, + #"Nom" : None } - self.setInformation("Temperature",self.temperature) - self.setInformation("Humidite", self.humidite) - self.setInformation("Acidite",0) - self.setInformation("Occupe", False) - + + self.setInformation("Occupe", "Non") + #self.setInformation("Nom",self.) def plantationGrandit(self): - self.indiceImage +=1 - if self.indiceImage <4: - + self.indiceImage += 1 + if self.indiceImage < 4: self.imageChamp = listeImage[self.indiceImage] else: if(self.indiceImage == 4): - self.imageChamp =pygame.transform.scale(pygame.image.load('../assets/Plantation/damage.png'),(120,120)) + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/damage.png'), 120, 120) elif(self.indiceImage == 5): self.isInfeste = False - self.imageChamp =pygame.transform.scale(pygame.image.load('../assets/Plantation/fanne.png'),(120,120)) - - - - + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/fanne.png'), 120, 120) def draw (self, screen, camera): @@ -87,7 +81,7 @@ class Champs: (self.rectScale.h-self.rectChampScal.h) /2) ) - self.setInformation("Occupe", True) + self.setInformation("Occupe", "Oui") if(self.isInfeste): scaleInfecte = camera.scaleImage(Champs.iconInsecteStatic) @@ -112,9 +106,6 @@ class Champs: if scaleText: self.zoomText = scaleText - def setInformation(self,clef,valeur): - self.descr - def setInformation(self,clef,valeur): self.descripteurChamps[clef] = valeur self.imageSurfaceinfo[clef] = police.render(clef+ " : "+ str(valeur),False,(0,0,0)) @@ -152,7 +143,7 @@ class TerrainVide(Champs): class Houblon (Champs): - iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/houblon.png'),(150,150)) + iconStatic = transformImage(pygame.image.load('../assets/Plantation/houblon.png'), *iconStaticSize) textStatic = police.render('Houblon',False, (0,0,0)) textDescriptionStatic = police.render("Houblon sa marche bien",False,(0,0,0)) montantAchat = 250 @@ -162,11 +153,11 @@ class Houblon (Champs): self.text = self.police.render("Température : " + str(self.temperature), False, (0,0,0)) self.zoomText = self.text - self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) class Ble (Champs): - iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/wheat.png'),(150,150)) + iconStatic = transformImage(pygame.image.load('../assets/Plantation/wheat.png'), *iconStaticSize) textStatic = police.render('Ble',False, (0,0,0)) textDescriptionStatic = police.render("Ble sa marche bien",False,(0,0,0)) montantAchat = 250 @@ -174,43 +165,43 @@ class Ble (Champs): def __init__ (self,pos): super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) class Malt (Champs): - iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/malt.png'),(150,150)) + iconStatic = transformImage(pygame.image.load('../assets/Plantation/malt.png'), *iconStaticSize) textStatic = police.render('Malt',False, (0,0,0)) textDescriptionStatic = police.render("Malt sa marche bien",False,(0,0,0)) montantAchat = 300 montantVente = 800 def __init__ (self,pos): super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) class Chanvre(Champs): - iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/weed.png'),(150,150)) + iconStatic = transformImage(pygame.image.load('../assets/Plantation/weed.png'), *iconStaticSize) textStatic = police.render("Chanvre",False, (0,0,0)) textDescriptionStatic = police.render("Pour des spaces bières",False,(0,0,0)) montantAchat = 1000 montantVente = 5000 def __init__ (self,pos): - super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) + super().__init__(0,0,0,pos,'../assets//Plantation/champ.png') + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) class OrgeHiver(Champs): - iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/orge.png'),(150,150)) + iconStatic = transformImage(pygame.image.load('../assets/Plantation/orge.png'), *iconStaticSize) textStatic = police.render("Orge hiver",False, (0,0,0)) textDescriptionStatic = police.render("Orge hiver sa marche bien",False,(0,0,0)) montantAchat = 300 montantVente = 800 def __init__ (self,pos): super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) class OrgePrintemps(Champs): - iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/OrgePrintemps.png'),(150,150)) + iconStatic = transformImage(pygame.image.load('../assets/Plantation/OrgePrintemps.png'), *iconStaticSize) textStatic = police.render("Orge printemps",False, (0,0,0)) textDescriptionStatic = police.render("Orge printemps sa marche bien",False,(0,0,0)) montantAchat = 500 @@ -218,22 +209,22 @@ class OrgePrintemps(Champs): def __init__ (self,pos): super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) class Seigle(Champs): - iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/seigle.png'),(150,150)) + iconStatic = transformImage(pygame.image.load('../assets/Plantation/seigle.png'), *iconStaticSize) textStatic = police.render("Seigle",False, (0,0,0)) textDescriptionStatic = police.render("Seigle sa marche bien",False,(0,0,0)) montantAchat = 200 montantVente = 600 def __init__ (self,pos): super().__init__(0,0,0,pos,'../assets/Plantation/champ.png') - self.imageChamp = pygame.transform.scale(pygame.image.load('../assets/Plantation/crop1phase.png'),(120,120)) + self.imageChamp = transformImage(pygame.image.load('../assets/Plantation/crop1phase.png'), 120, 120) class Pesticide(Champs): - iconStatic = pygame.transform.scale(pygame.image.load('../assets/Plantation/pesticide.png'),(150,150)) + iconStatic = transformImage(pygame.image.load('../assets/Plantation/pesticide.png'), *iconStaticSize) textStatic = police.render("Pesticide",False, (0,0,0)) textDescriptionStatic = police.render("Pour tuer les insectes",False,(0,0,0)) montantAchat = 200 diff --git a/src/Game.py b/src/Game.py old mode 100755 new mode 100644 index d8836e22ca2d94ff8b443d756bd06a9fc95bb233..9f44513360df39f190c26a6c64320b851c58189d --- a/src/Game.py +++ b/src/Game.py @@ -1,11 +1,11 @@ import pygame import random -from Champs import Champs,Houblon,Buisson,TerrainVide,Pesticide,typePlantation +from Champs import * import numpy as np from Camera import Camera -from Image import transformImage,Image +from Image import * from Temps import Temps -from Infrastructure import Infrastructure,typeBatiment,Serre,Torche +from Infrastructure import * RAYON_MUR_INVISIBLE = 2000 SAISONS = ["Printemps", "Été", "Automne", "Hiver"] @@ -34,7 +34,7 @@ class Game: self.clock = pygame.time.Clock() self.selectedChamp = None - self.imageMoney = pygame.transform.scale(self.image.moneyImage, np.array(self.image.moneyImage.get_size())/2) + self.imageMoney = pygame.transform.scale(self.image.moneyImage, np.array(self.image.moneyImage.get_size())/5) self.camera = Camera(np.array(self.screen.get_size())/2) @@ -92,9 +92,7 @@ class Game: self.screen.blit(self.temps.nexticonSaison,(self.temps.getImageSaison().get_width() - self.temps.nexticonSaison.get_width(),self.screen.get_height() - self.temps.getImageSaison().get_height() +20)) self.screen.blit(self.temps.tempsaisonImageDeuxPosiiton,(self.temps.getImageSaison().get_width() - self.temps.nexticonSaison.get_width(),self.screen.get_height() - self.temps.getImageSaison().get_height())) - - print(self.rectPlantation.w) - print(self.rectPlantation.h) + #Onglet plantation self.screen.blit(self.rectPlantationimage,(0,0)) @@ -105,15 +103,14 @@ class Game: for i,c in enumerate(typePlantation): x = self.rectPlantation.x + ( 0 if i%2 else 170) - y = self.rectPlantation.y + (i//2) * 200 - r = pygame.rect.Rect(x,y,c.iconStatic.get_width(),c.iconStatic.get_height()+ 30 ) + y = self.rectPlantation.y + (i//2) * 140 + r = pygame.rect.Rect(x,y,c.iconStatic.get_width(),c.iconStatic.get_height()+ 20 ) self.screen.blit(c.textStatic, (x,y)) - self.screen.blit(c.iconStatic,(x,y+30 )) + self.screen.blit(c.iconStatic,(x,y+20 )) if ( (r.collidepoint(pygame.mouse.get_pos()))): pygame.draw.rect(self.screen,(138, 227, 237), r,1) self.screen.blit(c.textDescriptionStatic,(self.recInformation.x,self.recInformation.y)) #self.screen.blit(self.text,(screen.get_width()*0.85,screen.get_height()*0.18)) - @@ -133,8 +130,6 @@ class Game: isChamp = False - - # if self.money < self.displayMoney: @@ -179,7 +174,7 @@ class Game: for i,c in enumerate(typePlantation): x = self.rectPlantation.x + ( 0 if i%2 else 170) - y = self.rectPlantation.y + (i//2) * 200 + y = self.rectPlantation.y + (i//2) * 140 r = pygame.rect.Rect(x,y,c.iconStatic.get_width() + 20 ,c.iconStatic.get_height()+ 30 ) if ( (r.collidepoint(event.pos))): self.dragPlantation = c @@ -288,7 +283,7 @@ class Game: if self.frame < self.buyFrame + 20: - self.screen.blit(self.moneyChange, (self.screen.get_width() -200, (self.frame-self.buyFrame)*1.5)) + self.screen.blit(self.moneyChange, (self.screen.get_width() - self.imageMoney.get_width() - textMoney.get_width(), (self.frame-self.buyFrame)*1.5)) #self.screen.blit(self.moneyChange, (200, self.screen.get_height()-textMoney.get_height()*4+(self.frame-self.buyFrame)*1.5)) if self.selectedChamp: diff --git a/src/Image.py b/src/Image.py index 3c78181e146abde7e04118056a31fddb9d3f84f1..ae9a66244bb80d54516e9c06a9f12416aa6e7ed7 100644 --- a/src/Image.py +++ b/src/Image.py @@ -6,7 +6,7 @@ class Image: self.screen = screen # Chargement des images - self.moneyImage = pygame.image.load("../assets/Interface/money.png") + self.moneyImage = pygame.image.load("../assets/Interface/money.webp") self.backgroundImage = pygame.image.load("../assets/Interface/terre.png") self.rainImage = pygame.image.load("../assets/Temps/pluie.png") self.arrowNextImage = pygame.image.load("../assets/Interface/suite.png") diff --git a/src/Infrastructure.py b/src/Infrastructure.py index 08cc96d9fd3694fd05449ea1520e89b4fe80b95c..2e1dfba85913d227da8f7b71a18c687e506c389a 100644 --- a/src/Infrastructure.py +++ b/src/Infrastructure.py @@ -47,9 +47,6 @@ class Infrastructure: (self.rectScale.h-self.rectbatScal.h) /2) ) - - - def changeText (self, camera): scaleText = camera.scaleImage(self.text) diff --git a/src/Plantation.py b/src/Plantation.py deleted file mode 100644 index 33cc37437b8317930471bf166758248dd7cdeb27..0000000000000000000000000000000000000000 --- a/src/Plantation.py +++ /dev/null @@ -1,3 +0,0 @@ -class Plantation: - - def __init__ (self): \ No newline at end of file diff --git a/src/Temps.py b/src/Temps.py index 33046d08e985532314d8190c88490a54903368aa..ce2dde15f1bac750804ceb8956ed08814ae44565 100755 --- a/src/Temps.py +++ b/src/Temps.py @@ -4,16 +4,14 @@ from Image import transformImage from random import triangular police = pygame.font.SysFont("Alef", 30) police2 = pygame.font.SysFont("Alef", 20) -class Temps: - """ - climats = { - - "janvier" : { - "temp" : [2,7.8], - "humidité" : [78,90] - }, - "février" : { +""" +climats = { + "janvier" : { + "temp" : [2,7.8], + "humidité" : [78,90] + }, + "février" : { "temp" : [4.5,11.8], "humidité" : [60,85] }, @@ -59,15 +57,16 @@ class Temps: } } - """ - +""" + +class Temps: climats = { "Automne" : { "temp" : [4.8,13.3], "humidité" : [70,95] }, - "Hiver" : { + "Hiver" : { "temp" : [-5,10.3], "humidité" : [50,90] }, @@ -82,31 +81,34 @@ class Temps: } def __init__(self): + self.ListTemps = ["neige","orage","pluie","ensoleillee","vent","secheresse","canicule","froid","chaud"] + self.indice = 2 self.currentSeason = self.getSaisonName(self.indice) - self.globaltemp = self.tirageAuSortChiffreIntervalleTemp(self.currentSeason) + self.globaltemp = self.tirageTemperature(self.currentSeason) self.humidite = self.tirageAuSortChiffreIntervallehumidite(self.currentSeason) - self.temps = pygame.image.load(self.tempAAfficher(self.globaltemp,self.humidite)) + self.temps = pygame.image.load(self.tempAAfficher(self.currentSeason,self.tirageTemps())) self.iconSaison = transformImage(self.temps,200,200) - self.nextSaison = self.getSaisonName(self.indice+1) - self.nextglobalTemps = self.tirageAuSortChiffreIntervalleTemp(self.nextSaison) - self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSaison) - self.nextTemps = pygame.image.load(self.tempAAfficher(self.nextglobalTemps,self.nexthumidite)) + self.nextSeason = self.getSaisonName(self.indice+1) + self.nextglobalTemps = self.tirageTemperature(self.nextSeason) + self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSeason) + self.nextTemps = pygame.image.load(self.tempAAfficher(self.nextSeason,self.tirageTemps())) self.nexticonSaison = transformImage(self.nextTemps,100,100) self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,1))+" °C",True,(0,0,0)) - - self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSaison +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0)) + + + self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSeason +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0)) for key,value in self.climats.items(): self.climats.get(key)['image'] = transformImage(pygame.image.load("../assets/Saison/"+key+".png"),400,300) - self.ListTemps = [] + def NextTurn(self): #Le next qui devien current self.indice += 1 - self.currentSeason = self.nextSaison + self.currentSeason = self.nextSeason self.globaltemp = self.nextglobalTemps self.humidite = self.nexthumidite self.temps = self.nextTemps @@ -114,20 +116,18 @@ class Temps: self.tempsaisonImage = police.render(self.currentSeason +" : "+ str(round(self.globaltemp,1))+" °C",True,(0,0,0)) #Nouveau turn - self.nextSaison = self.getSaisonName(self.indice+1) - self.nextglobalTemps = self.tirageAuSortChiffreIntervalleTemp(self.nextSaison) - self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSaison) - self.nextTemps = pygame.image.load(self.tempAAfficher(self.nextglobalTemps,self.nexthumidite)) + self.nextSeason = self.getSaisonName(self.indice+1) + self.nextglobalTemps = self.tirageTemperature(self.nextSeason) + self.nexthumidite = self.tirageAuSortChiffreIntervallehumidite(self.nextSeason) + self.nextTemps = pygame.image.load(self.tempAAfficher(self.currentSeason,self.tirageTemps())) self.nexticonSaison = transformImage(self.nextTemps,100,100) - - self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSaison +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0)) - + self.tempsaisonImageDeuxPosiiton = police2.render(self.nextSeason +" : "+ str(round(self.nextglobalTemps,1))+" °C",True,(0,0,0)) def getSaisonName(self,indice:int)->str: return list(self.climats.keys())[indice%4] - def tirageAuSortChiffreIntervalleTemp(self,clef): + def tirageTemperature(self,clef): #tirage au sort pour avoir un nombre representatif dans son domaine; par exemple [0,10], la temp sera de 5 intervalle = self.getClimatTemp(clef) @@ -144,25 +144,32 @@ class Temps: #randomNombre = random.random() * (intervalle[1]-intervalle[0]) + intervalle[0] return random.triangular(low = intervalle[0],high = intervalle[1]) - def tempAAfficher(self,temperature:float,humidite)-> str: - #Determination du temps a afficher - if( temperature < 0 and humidite >80): - return "../assets/Temps/neige.png" - elif (temperature < 10): - return "../assets/Temps/froid.png" - elif (temperature < 35): - return "../assets/Temps/chaud.png" - elif (temperature > 34): - if(humidite > 85): - return "../assets/Temps/orage.png" - - if(humidite < 65): - return "../assets/Temps/secheresse.png" - else: - return "../assets/Temps/canicule.png" + def tirageTemps(self): + nbrandom = random.randint(0,len(self.ListTemps)-1) + print("nbrandom"+ str(nbrandom)) + print(self.ListTemps[nbrandom]) + return self.ListTemps[nbrandom] + + def tempAAfficher(self, saison,temps:str)-> str: + #Determination du temps a afficher + + if saison == "Automne" and temps not in ["secheresse","canicule","chaud"]: + print("Automne") + return str("../assets/Temps/"+temps+".png") + elif saison == "Hiver" and temps not in ["secheresse","canicule","chaud"]: + print("rentrer hiver") + return str("../assets/Temps/"+temps+".png") + elif saison == "Printemps" and temps not in ["secheresse","canicule","neige"]: + print("Printemps") + return str("../assets/Temps/"+temps+".png") + elif saison == "été" and temps not in ["froid","neige"]: + print("été") + return str("../assets/Temps/"+temps+".png") else: - pass + return self.tempAAfficher(saison,self.tirageTemps()) + + def getClimatTemp(self,clef): return self.climats[clef]["temp"]