Console
Clique sur « Exécuter » pour lancer le programme.
Code CoddyRun
@ CONFIGURATION
ecran est une toile
dimension(ecran, 640, 540)
TF est un nombre
TF vaut 10
OX est un nombre
OX vaut 320
OY est un nombre
OY vaut 132
DXT est un nombre
DXT vaut 28
DYT est un nombre
DYT vaut 14
DUREE_JOUR est un nombre
DUREE_JOUR vaut 420
OBJECTIF est un nombre
OBJECTIF vaut 10000
@ LES CULTURES (index 1 a 5)
// saisons : P printemps, E ete, A automne, H hiver
cNom est un tableau
cNom vaut ["", "Carotte", "Fraise", "Tomate", "Maïs", "Citrouille"]
cSaisons est un tableau
cSaisons vaut ["", "PA", "P", "E", "E", "A"]
cJours est un tableau
cJours vaut [0, 3, 4, 5, 6, 8]
cRepousse est un tableau
cRepousse vaut [0, 0, 3, 3, 0, 0]
cGraine est un tableau
cGraine vaut [0, 5, 12, 10, 15, 30]
cCoul est un tableau
cCoul ajoute #000000
cCoul ajoute #FF8C1A
cCoul ajoute #E53935
cCoul ajoute #D32F2F
cCoul ajoute #FBC02D
cCoul ajoute #F57C00
@ LES PRODUITS (1 a 5 : cultures, 6 oeufs, 7 lait)
pNom est un tableau
pNom vaut ["", "Carottes", "Fraises", "Tomates", "Maïs", "Citrouilles", "Oeufs", "Lait"]
pBase est un tableau
pBase vaut [0, 15, 35, 30, 45, 120, 12, 40]
stock est un tableau
prixJour est un tableau
@ LES SAISONS
sNom est un tableau
sNom vaut ["Printemps", "Été", "Automne", "Hiver"]
sLettre est un tableau
sLettre vaut ["P", "E", "A", "H"]
sHerbe est un tableau
sHerbe ajoute #7CC56B
sHerbe ajoute #A5C459
sHerbe ajoute #C9A24D
sHerbe ajoute #E8EEF2
sHerbeOmbre est un tableau
sHerbeOmbre ajoute #5E9E50
sHerbeOmbre ajoute #84A043
sHerbeOmbre ajoute #A27F37
sHerbeOmbre ajoute #BFCAD3
@ LA BOUTIQUE
achNom est un tableau
achNom vaut ["Poulailler (avec 2 poules)", "Une poule de plus", "Étable (avec 1 vache)", "Une vache de plus", "Arroseur automatique"]
achPrix est un tableau
achPrix vaut [400, 60, 800, 250, 120]
achDescr est un tableau
achDescr vaut ["Chaque poule pond un oeuf par jour (nourriture : 2 EUR/jour)", "6 poules au maximum", "Chaque vache donne du lait chaque jour (nourriture : 6 EUR/jour)", "4 vaches au maximum", "Arrose chaque matin les 8 cases autour de lui"]
@ LES OUTILS
oNom est un tableau
oNom vaut ["Houe", "Graines", "Arrosoir", "Faucille", "Arroseur"]
oDescr est un tableau
oDescr vaut ["labourer l'herbe, nettoyer", "semer la graine choisie", "arroser", "récolter", "poser un arroseur"]
@ LA FERME
// sol : 0 herbe, 1 terre labouree
// objet : 0 rien, 1 maison, 2 poulailler, 3 etable, 4 arroseur, 5 arbre, 6 enclos vide
sol est un tableau
objet est un tableau
culture est un tableau
stade est un tableau
arrose est un tableau
secJours est un tableau
mort est un tableau
pour i de 0 à TF * TF - 1
sol ajoute 0
objet ajoute 0
culture ajoute 0
stade ajoute 0
arrose ajoute faux
secJours ajoute 0
mort ajoute faux
fin pour
@ ETAT DU JEU
// etat : 0 titre, 1 jeu, 2 marche, 3 aide, 4 domaine prospere, 5 pause
etat est un nombre
etat vaut 0
appActif est un booléen
appActif vaut vrai
argent, totalGagne, jour, saison, jourSaison, annee, tickJour, tic est un nombre
curX, curY, outil, graineSel, nbPoules, nbVaches, nbArroseurs est un nombre
pluie, aPoulailler, aEtable, objectifAtteint est un booléen
message est un texte
banniere est un texte
banniereT est un nombre
ongletMarche, ligneMarche est un nombre
msgMarche est un texte
action, ptX, ptY est un nombre
popTxt, popX, popY, popT est un tableau
paliers est un tableau
paliers vaut [1000, 3000, 6000, 10000]
palNoms est un tableau
palNoms vaut ["Petite ferme", "Ferme", "Grande ferme", "Domaine prospère"]
palierIdx est un nombre
@ OUTILS
fonction ecranX(gx, gy)
retourne OX + (gx - gy) * DXT
fin fonction
fonction ecranY(gx, gy)
retourne OY + (gx + gy) * DYT
fin fonction
fonction bonneSaison(sorte)
retourne position(sLettre[saison], cSaisons[sorte]) > 0
fin fonction
fonction estMure(k)
retourne culture[k] > 0 et non mort[k] et stade[k] >= cJours[culture[k]]
fin fonction
procédure annoncer(txt)
message vaut txt
fin procédure
procédure ajouterPop(txt, x, y)
popTxt ajoute txt
popX ajoute x
popY ajoute y
popT ajoute 18
fin procédure
procédure majPrix()
kp est un nombre
pour kp de 0 à 7
prixJour[kp] vaut arrondi(pBase[kp] * hasard(75, 130) / 100)
fin pour
fin procédure
procédure nouvellePartie()
ki est un nombre
pour ki de 0 à TF * TF - 1
sol[ki] vaut 0
objet[ki] vaut 0
culture[ki] vaut 0
stade[ki] vaut 0
arrose[ki] vaut faux
secJours[ki] vaut 0
mort[ki] vaut faux
fin pour
// la maison, deux enclos a construire, quelques arbres
objet[0] vaut 1
objet[9] vaut 6
objet[90] vaut 6
objet[3] vaut 5
objet[60] vaut 5
objet[69] vaut 5
objet[95] vaut 5
// un petit potager pour commencer
pour ki de 0 à 2
sol[3 * TF + 3 + ki] vaut 1
sol[4 * TF + 3 + ki] vaut 1
fin pour
vide stock
vide prixJour
pour ki de 0 à 7
stock ajoute 0
prixJour ajoute pBase[ki]
fin pour
appelle majPrix()
vide popTxt
vide popX
vide popY
vide popT
argent vaut 200
totalGagne vaut 0
jour vaut 1
saison vaut 0
jourSaison vaut 1
annee vaut 1
tickJour vaut 0
curX vaut 4
curY vaut 4
outil vaut 1
graineSel vaut 1
nbPoules vaut 0
nbVaches vaut 0
nbArroseurs vaut 0
pluie vaut faux
aPoulailler vaut faux
aEtable vaut faux
objectifAtteint vaut faux
palierIdx vaut 0
banniere vaut "Jour 1 - Printemps : une belle saison pour les carottes !"
banniereT vaut 40
appelle annoncer("Avance avec ZQSD, choisis un outil (1 à 5), ESPACE pour l'utiliser.")
fin procédure
@ UNE NOUVELLE JOURNEE
procédure nouvelleJournee()
ki est un nombre
jour ajoute 1
jourSaison ajoute 1
changement est un booléen
changement vaut faux
si jourSaison > 10 alors
jourSaison vaut 1
saison vaut (saison + 1) mod 4
changement vaut vrai
si saison = 0 alors
annee ajoute 1
fin si
fin si
// les cultures poussent si elles ont ete arrosees
gelees est un nombre
gelees vaut 0
fanees est un nombre
fanees vaut 0
pour ki de 0 à TF * TF - 1
si culture[ki] > 0 et non mort[ki] alors
si arrose[ki] alors
stade[ki] vaut minimum(stade[ki] + 1, cJours[culture[ki]])
secJours[ki] vaut 0
sinon
secJours[ki] vaut secJours[ki] + 1
si secJours[ki] >= 3 alors
mort[ki] vaut vrai
fanees ajoute 1
fin si
fin si
// la nouvelle saison ne convient pas a cette culture
si changement et non bonneSaison(culture[ki]) alors
mort[ki] vaut vrai
gelees ajoute 1
fin si
fin si
arrose[ki] vaut faux
fin pour
// la meteo du jour
pluie vaut saison <> 3 et hasard(0, 99) < 25
si pluie alors
pour ki de 0 à TF * TF - 1
si sol[ki] = 1 alors
arrose[ki] vaut vrai
fin si
fin pour
fin si
// les arroseurs automatiques
pour ki de 0 à TF * TF - 1
si objet[ki] = 4 alors
gx est un nombre
gx vaut ki mod TF
gy est un nombre
gy vaut arrondi_inferieur(ki / TF)
dy est un nombre
pour dy de -1 à 1
dx est un nombre
pour dx de -1 à 1
si gx + dx >= 0 et gx + dx < TF et gy + dy >= 0 et gy + dy < TF alors
si sol[(gy + dy) * TF + gx + dx] = 1 alors
arrose[(gy + dy) * TF + gx + dx] vaut vrai
fin si
fin si
fin pour
fin pour
fin si
fin pour
// les animaux
txtAnimaux est un texte
txtAnimaux vaut ""
si nbPoules > 0 alors
si argent >= nbPoules * 2 alors
argent vaut argent - nbPoules * 2
stock[6] vaut stock[6] + nbPoules
txtAnimaux vaut " +" + convertir_texte(nbPoules) + " oeufs"
sinon
txtAnimaux vaut " Les poules ont faim !"
fin si
fin si
si nbVaches > 0 alors
si argent >= nbVaches * 6 alors
argent vaut argent - nbVaches * 6
stock[7] vaut stock[7] + nbVaches
txtAnimaux vaut txtAnimaux + " +" + convertir_texte(nbVaches) + " lait"
sinon
txtAnimaux vaut txtAnimaux + " Les vaches ont faim !"
fin si
fin si
appelle majPrix()
banniere vaut "Jour " + convertir_texte(jour) + " - " + sNom[saison] + " (" + convertir_texte(jourSaison) + "/10)"
si pluie alors
banniere vaut banniere + " - il pleut, tout est arrosé !"
fin si
banniereT vaut 45
message vaut "Bonjour !" + txtAnimaux
si gelees > 0 alors
message vaut "Nouvelle saison : " + convertir_texte(gelees) + " cultures n'ont pas supporté le changement..."
sinon si fanees > 0 alors
message vaut convertir_texte(fanees) + " cultures ont fané : pense à arroser !"
sinon si jourSaison >= 9 alors
message vaut "Bientôt la fin du " + sNom[saison] + " : récolte vite !"
fin si
tickJour vaut 0
fin procédure
@ LES ACTIONS DU FERMIER
procédure utiliserOutil()
k est un nombre
k vaut curY * TF + curX
ex est un nombre
ex vaut ecranX(curX, curY)
ey est un nombre
ey vaut ecranY(curX, curY) - 30
si outil = 1 alors
// HOUE
si objet[k] > 0 et objet[k] <> 4 alors
appelle annoncer("Impossible de labourer ici.")
sinon si objet[k] = 4 alors
objet[k] vaut 0
nbArroseurs ajoute 1
appelle annoncer("Arroseur ramassé.")
sinon si culture[k] > 0 et mort[k] alors
culture[k] vaut 0
mort[k] vaut faux
appelle annoncer("Culture fanée arrachée.")
sinon si culture[k] > 0 alors
appelle annoncer("Une culture pousse ici !")
sinon si sol[k] = 0 alors
sol[k] vaut 1
appelle annoncer("Terre labourée.")
sinon
appelle annoncer("La terre est déjà prête : sème des graines (outil 2).")
fin si
sinon si outil = 2 alors
// GRAINES
si sol[k] <> 1 ou objet[k] > 0 alors
appelle annoncer("Laboure d'abord la terre (outil 1).")
sinon si culture[k] > 0 alors
appelle annoncer("Il y a déjà une culture ici.")
sinon si non bonneSaison(graineSel) alors
appelle annoncer(cNom[graineSel] + " : pas la bonne saison ! (G pour changer)")
sinon si argent < cGraine[graineSel] alors
appelle annoncer("Pas assez d'argent pour les graines.")
sinon
argent vaut argent - cGraine[graineSel]
culture[k] vaut graineSel
stade[k] vaut 0
secJours[k] vaut 0
mort[k] vaut faux
appelle ajouterPop("-" + convertir_texte(cGraine[graineSel]) + " EUR", ex - 20, ey)
appelle annoncer(cNom[graineSel] + " semée ! Prête dans " + convertir_texte(cJours[graineSel]) + " jours d'arrosage.")
fin si
sinon si outil = 3 alors
// ARROSOIR
si sol[k] = 1 alors
si arrose[k] alors
appelle annoncer("C'est déjà arrosé.")
sinon
arrose[k] vaut vrai
appelle ajouterPop("splash !", ex - 20, ey)
fin si
sinon
appelle annoncer("On arrose la terre labourée.")
fin si
sinon si outil = 4 alors
// FAUCILLE
si estMure(k) alors
sorte est un nombre
sorte vaut culture[k]
stock[sorte] vaut stock[sorte] + 1
appelle ajouterPop("+1 " + cNom[sorte], ex - 25, ey)
si cRepousse[sorte] > 0 alors
stade[k] vaut cJours[sorte] - cRepousse[sorte]
appelle annoncer(cNom[sorte] + " récoltée ! Elle va repousser.")
sinon
culture[k] vaut 0
stade[k] vaut 0
appelle annoncer(cNom[sorte] + " récoltée !")
fin si
sinon si culture[k] > 0 et non mort[k] alors
appelle annoncer("Pas encore mûr : encore " + convertir_texte(cJours[culture[k]] - stade[k]) + " jours.")
sinon
appelle annoncer("Rien à récolter ici.")
fin si
sinon
// ARROSEUR
si nbArroseurs <= 0 alors
appelle annoncer("Achète d'abord un arroseur au marché (M).")
sinon si objet[k] > 0 ou culture[k] > 0 alors
appelle annoncer("La case doit être vide.")
sinon
objet[k] vaut 4
sol[k] vaut 0
nbArroseurs soustrait 1
appelle annoncer("Arroseur posé : il arrosera les 8 cases autour chaque matin.")
fin si
fin si
fin procédure
procédure changerGraine()
// on passe a la graine suivante qui pousse en cette saison
trouvee est un booléen
trouvee vaut faux
essai est un nombre
pour essai de 1 à 5
si non trouvee alors
graineSel vaut graineSel mod 5 + 1
si bonneSaison(graineSel) alors
trouvee vaut vrai
fin si
fin si
fin pour
appelle annoncer("Graine : " + cNom[graineSel] + " (" + convertir_texte(cGraine[graineSel]) + " EUR)")
fin procédure
procédure vendre(kp)
si stock[kp] > 0 alors
gain est un nombre
gain vaut stock[kp] * prixJour[kp]
argent vaut argent + gain
totalGagne vaut totalGagne + gain
msgMarche vaut convertir_texte(stock[kp]) + " " + pNom[kp] + " vendus : +" + convertir_texte(gain) + " EUR"
stock[kp] vaut 0
appelle verifierPaliers()
sinon
msgMarche vaut "Tu n'as pas de " + pNom[kp] + " à vendre."
fin si
fin procédure
procédure verifierPaliers()
si palierIdx < 4 alors
si totalGagne >= paliers[palierIdx] alors
banniere vaut "Ta ferme devient : " + palNoms[palierIdx] + " !"
banniereT vaut 50
palierIdx ajoute 1
fin si
fin si
si totalGagne >= OBJECTIF et non objectifAtteint alors
objectifAtteint vaut vrai
etat vaut 4
fin si
fin procédure
procédure acheter(ka)
si argent < achPrix[ka] alors
msgMarche vaut "Il te manque " + convertir_texte(achPrix[ka] - argent) + " EUR."
sinon si ka = 0 alors
si aPoulailler alors
msgMarche vaut "Tu as déjà un poulailler."
sinon
argent vaut argent - achPrix[ka]
aPoulailler vaut vrai
objet[90] vaut 2
nbPoules vaut 2
msgMarche vaut "Poulailler construit ! Cot cot !"
fin si
sinon si ka = 1 alors
si non aPoulailler alors
msgMarche vaut "Il faut d'abord un poulailler."
sinon si nbPoules >= 6 alors
msgMarche vaut "Le poulailler est plein."
sinon
argent vaut argent - achPrix[ka]
nbPoules ajoute 1
msgMarche vaut "Une poule de plus (" + convertir_texte(nbPoules) + ")."
fin si
sinon si ka = 2 alors
si aEtable alors
msgMarche vaut "Tu as déjà une étable."
sinon
argent vaut argent - achPrix[ka]
aEtable vaut vrai
objet[9] vaut 3
nbVaches vaut 1
msgMarche vaut "Étable construite ! Meuh !"
fin si
sinon si ka = 3 alors
si non aEtable alors
msgMarche vaut "Il faut d'abord une étable."
sinon si nbVaches >= 4 alors
msgMarche vaut "L'étable est pleine."
sinon
argent vaut argent - achPrix[ka]
nbVaches ajoute 1
msgMarche vaut "Une vache de plus (" + convertir_texte(nbVaches) + ")."
fin si
sinon
argent vaut argent - achPrix[ka]
nbArroseurs ajoute 1
outil vaut 5
msgMarche vaut "Arroseur acheté : pose-le avec l'outil 5."
fin si
fin procédure
@ DESSIN : TERRAIN ET OBJETS
procédure losange(x, y, coul)
polygone(ecran, [x, y - DYT, x + DXT, y, x, y + DYT, x - DXT, y], coul)
fin procédure
procédure dessinerTuile(x, y, k)
// l'epaisseur de la tuile
polygone(ecran, [x - DXT, y, x, y + DYT, x, y + DYT + 6, x - DXT, y + 6], #6D4C33)
polygone(ecran, [x, y + DYT, x + DXT, y, x + DXT, y + 6, x, y + DYT + 6], #5A3E29)
si sol[k] = 1 alors
si arrose[k] alors
appelle losange(x, y, #5D3A22)
sinon
appelle losange(x, y, #8D5B3A)
fin si
// les sillons
ligne(ecran, x - DXT * 0.5, y - DYT * 0.5, x + DXT * 0.5, y + DYT * 0.5, rgba(0, 0, 0, 0.15), 2)
ligne(ecran, x - DXT * 0.5 - 6, y - DYT * 0.5 + 6, x + DXT * 0.5 - 6, y + DYT * 0.5 + 6, rgba(0, 0, 0, 0.12), 2)
sinon
si (k + arrondi_inferieur(k / TF)) mod 2 = 0 alors
appelle losange(x, y, sHerbe[saison])
sinon
appelle losange(x, y, sHerbeOmbre[saison])
fin si
fin si
fin procédure
procédure dessinerCulture(x, y, k)
sorte est un nombre
sorte vaut culture[k]
f est un nombre
f vaut stade[k] / cJours[sorte]
si mort[k] alors
ligne(ecran, x - 4, y, x - 7, y - 8, #6D4C41, 2)
ligne(ecran, x + 3, y, x + 6, y - 7, #6D4C41, 2)
ellipse(ecran, x, y - 2, 6, 2, #795548)
sinon si f < 0.34 alors
// une pousse
ligne(ecran, x, y, x, y - 6, #43A047, 2)
ellipse(ecran, x - 3, y - 6, 3, 2, #66BB6A)
ellipse(ecran, x + 3, y - 7, 3, 2, #66BB6A)
sinon si f < 1 alors
// la plante grandit
hauteurP est un nombre
hauteurP vaut 6 + f * 12
si sorte = 4 alors
hauteurP vaut 8 + f * 22
fin si
ligne(ecran, x, y, x, y - hauteurP, #388E3C, 2)
ellipse(ecran, x - 5, y - hauteurP * 0.6, 5, 2, #4CAF50)
ellipse(ecran, x + 5, y - hauteurP * 0.8, 5, 2, #4CAF50)
ellipse(ecran, x, y - hauteurP, 4, 3, #66BB6A)
sinon
// MURE : chaque culture a son allure
si sorte = 1 alors
polygone(ecran, [x - 4, y - 4, x + 4, y - 4, x, y + 3], #FF8C1A)
ligne(ecran, x, y - 4, x - 4, y - 14, #43A047, 2)
ligne(ecran, x, y - 4, x + 4, y - 14, #43A047, 2)
ligne(ecran, x, y - 4, x, y - 15, #66BB6A, 2)
sinon si sorte = 2 alors
ellipse(ecran, x, y - 6, 11, 6, #388E3C)
cercle(ecran, x - 5, y - 6, 3, #E53935)
cercle(ecran, x + 4, y - 8, 3, #E53935)
cercle(ecran, x + 1, y - 3, 3, #E53935)
sinon si sorte = 3 alors
ligne(ecran, x, y, x, y - 24, #8D6E63, 2)
ellipse(ecran, x, y - 14, 8, 9, #43A047)
cercle(ecran, x - 4, y - 12, 4, #D32F2F)
cercle(ecran, x + 4, y - 17, 4, #D32F2F)
cercle(ecran, x + 3, y - 8, 3, #E53935)
sinon si sorte = 4 alors
ligne(ecran, x - 3, y, x - 3, y - 30, #7CB342, 3)
ligne(ecran, x + 3, y, x + 3, y - 28, #7CB342, 3)
ellipse(ecran, x - 7, y - 18, 3, 7, #FBC02D)
ellipse(ecran, x + 7, y - 16, 3, 7, #FBC02D)
ligne(ecran, x - 3, y - 22, x - 11, y - 28, #9CCC65, 2)
sinon
ellipse(ecran, x, y - 6, 13, 9, #F57C00)
ligne(ecran, x - 5, y - 13, x - 5, y + 1, #E65100, 1)
ligne(ecran, x + 5, y - 13, x + 5, y + 1, #E65100, 1)
rectangle(ecran, x - 1, y - 17, 3, 4, #5D4037)
ellipse(ecran, x + 6, y - 15, 4, 2, #66BB6A)
fin si
// une etincelle : c'est pret !
si (tic + k) mod 12 < 6 alors
cercle(ecran, x + 9, y - 22, 2, #FFFFFF)
ligne(ecran, x + 5, y - 22, x + 13, y - 22, #FFF59D, 1)
ligne(ecran, x + 9, y - 26, x + 9, y - 18, #FFF59D, 1)
fin si
fin si
fin procédure
procédure dessinerObjet(x, y, k)
ob est un nombre
ob vaut objet[k]
si ob = 1 alors
// LA MAISON
polygone(ecran, [x - 22, y - 2, x, y + 9, x, y - 25, x - 22, y - 36], #FFE0B2)
polygone(ecran, [x, y + 9, x + 22, y - 2, x + 22, y - 36, x, y - 25], #FFCC80)
polygone(ecran, [x - 26, y - 34, x, y - 21, x, y - 52], #C62828)
polygone(ecran, [x, y - 21, x + 26, y - 34, x, y - 52], #8E0000)
polygone(ecran, [x + 6, y + 1, x + 13, y - 2, x + 13, y - 16, x + 6, y - 13], #6D4C41)
si tickJour > DUREE_JOUR * 0.72 alors
rectangle(ecran, x - 15, y - 26, 8, 7, #FFEE58)
cercle(ecran, x - 11, y - 22, 14, rgba(255, 238, 88, 0.18))
sinon
rectangle(ecran, x - 15, y - 26, 8, 7, #90CAF9)
fin si
rectangle(ecran, x + 8, y - 54, 5, 12, #5D4037)
fum est un nombre
fum vaut tic mod 20
cercle(ecran, x + 11, y - 58 - fum, 4 + fum / 5, rgba(220, 220, 220, 0.6 - fum / 40))
sinon si ob = 2 ou ob = 3 alors
// POULAILLER ou ETABLE
si ob = 2 alors
polygone(ecran, [x - 16, y - 2, x, y + 6, x, y - 12, x - 16, y - 20], #A1887F)
polygone(ecran, [x, y + 6, x + 16, y - 2, x + 16, y - 20, x, y - 12], #8D6E63)
polygone(ecran, [x - 19, y - 19, x, y - 9, x, y - 32], #6D4C41)
polygone(ecran, [x, y - 9, x + 19, y - 19, x, y - 32], #4E342E)
cercle(ecran, x - 8, y - 9, 3, #3E2723)
sinon
polygone(ecran, [x - 22, y - 2, x, y + 9, x, y - 18, x - 22, y - 29], #C62828)
polygone(ecran, [x, y + 9, x + 22, y - 2, x + 22, y - 29, x, y - 18], #B71C1C)
polygone(ecran, [x - 25, y - 28, x, y - 16, x, y - 44], #ECEFF1)
polygone(ecran, [x, y - 16, x + 25, y - 28, x, y - 44], #B0BEC5)
ligne(ecran, x + 5, y + 1, x + 16, y - 15, #FFFFFF, 2)
ligne(ecran, x + 16, y - 4, x + 5, y - 12, #FFFFFF, 2)
fin si
sinon si ob = 4 alors
// ARROSEUR (il tourne le matin)
rectangle(ecran, x - 2, y - 14, 4, 14, #78909C)
cercle(ecran, x, y - 15, 4, #B0BEC5)
si tickJour < 60 ou pluie alors
kj est un nombre
pour kj de 0 à 3
angJ est un nombre
angJ vaut radians(tic * 20 + kj * 90)
cercle(ecran, x + cosinus(angJ) * 12, y - 12 + sinus(angJ) * 5, 2, #81D4FA)
fin pour
fin si
sinon si ob = 5 alors
// ARBRE (couleur selon la saison)
rectangle(ecran, x - 3, y - 16, 6, 16, #6D4C41)
si saison = 3 alors
cercle(ecran, x, y - 26, 13, #ECEFF1)
cercle(ecran, x - 6, y - 20, 8, #CFD8DC)
sinon si saison = 2 alors
cercle(ecran, x, y - 26, 13, #EF6C00)
cercle(ecran, x - 6, y - 20, 8, #F9A825)
sinon
cercle(ecran, x, y - 26, 13, #2E7D32)
cercle(ecran, x - 6, y - 20, 8, #388E3C)
si saison = 0 alors
cercle(ecran, x + 4, y - 30, 2, #F8BBD0)
cercle(ecran, x - 5, y - 24, 2, #F8BBD0)
fin si
fin si
sinon si ob = 6 alors
// ENCLOS VIDE, a construire au marche
ligne(ecran, x - 18, y, x, y + 9, #8D6E63, 2)
ligne(ecran, x, y + 9, x + 18, y, #8D6E63, 2)
ligne(ecran, x - 18, y - 6, x, y + 3, #A1887F, 2)
ligne(ecran, x, y + 3, x + 18, y - 6, #A1887F, 2)
rectangle(ecran, x - 8, y - 22, 16, 10, #FFF8E1)
label(ecran, x - 6, y - 14, "€", #8D6E63, 9)
fin si
fin procédure
procédure dessinerAnimaux()
ka est un nombre
bx, by, px, py est un nombre
// les poules autour du poulailler
si nbPoules > 0 alors
bx vaut ecranX(0, 8)
by vaut ecranY(0, 8)
pour ka de 0 à nbPoules - 1
px vaut bx + sinus(radians(tic * 3 + ka * 70)) * 14 + ka * 4 - 10
py vaut by + cosinus(radians(tic * 2 + ka * 50)) * 5
ellipse(ecran, px, py, 5, 2, rgba(0, 0, 0, 0.2))
ellipse(ecran, px, py - 5, 5, 4, #FFFFFF)
cercle(ecran, px + 4, py - 9, 3, #FFFFFF)
cercle(ecran, px + 4, py - 12, 1.5, #E53935)
cercle(ecran, px + 6, py - 9, 1, #FFA000)
fin pour
fin si
// les vaches pres de l'etable
si nbVaches > 0 alors
bx vaut ecranX(8, 0)
by vaut ecranY(8, 0)
pour ka de 0 à nbVaches - 1
px vaut bx + sinus(radians(tic * 1.5 + ka * 90)) * 16 - ka * 10 + 8
py vaut by + 6 + ka * 3 + cosinus(radians(tic + ka * 60)) * 3
ellipse(ecran, px, py, 9, 3, rgba(0, 0, 0, 0.2))
ellipse(ecran, px, py - 8, 10, 6, #FAFAFA)
cercle(ecran, px - 3, py - 9, 2.5, #212121)
cercle(ecran, px + 4, py - 7, 2, #212121)
ellipse(ecran, px + 10, py - 10, 4, 4, #FAFAFA)
ellipse(ecran, px + 12, py - 8, 2, 2, #F8BBD0)
ligne(ecran, px - 6, py - 3, px - 6, py, #616161, 2)
ligne(ecran, px + 5, py - 3, px + 5, py, #616161, 2)
fin pour
fin si
fin procédure
procédure dessinerFermier(x, y)
// le losange de selection
contour(ecran, #FFFFFF, 2)
appelle losange(x, y, rgba(255, 255, 255, 0.15))
contour(ecran, #0)
saut est un nombre
saut vaut sialors(tic mod 8 < 4, 0, 1)
ellipse(ecran, x + 10, y + 2, 6, 2, rgba(0, 0, 0, 0.25))
rectangle(ecran, x + 7, y - 6 - saut, 6, 6, #1565C0)
rectangle(ecran, x + 6, y - 14 - saut, 8, 9, #E53935)
cercle(ecran, x + 10, y - 18 - saut, 4, #FFCC80)
ellipse(ecran, x + 10, y - 21 - saut, 7, 2, #FBC02D)
rectangle(ecran, x + 7, y - 25 - saut, 6, 4, #FBC02D)
// l'outil a la main
si outil = 1 alors
ligne(ecran, x + 14, y - 10, x + 20, y - 22, #8D6E63, 2)
ligne(ecran, x + 18, y - 22, x + 23, y - 20, #90A4AE, 3)
sinon si outil = 2 alors
rectangle(ecran, x + 14, y - 14, 6, 7, #D7CCC8)
cercle(ecran, x + 17, y - 10, 1.5, cCoul[graineSel])
sinon si outil = 3 alors
rectangle(ecran, x + 14, y - 13, 8, 7, #4FC3F7)
ligne(ecran, x + 22, y - 11, x + 26, y - 15, #4FC3F7, 2)
sinon si outil = 4 alors
ligne(ecran, x + 14, y - 8, x + 17, y - 16, #8D6E63, 2)
ligne(ecran, x + 17, y - 16, x + 23, y - 14, #B0BEC5, 2)
sinon
rectangle(ecran, x + 15, y - 16, 3, 10, #78909C)
fin si
fin procédure
@ DESSIN : LA SCENE COMPLETE
procédure dessinerCiel()
phase est un nombre
phase vaut tickJour / DUREE_JOUR
si pluie alors
dégradé(ecran, [#607D8B, #90A4AE])
sinon si phase < 0.62 alors
si saison = 3 alors
dégradé(ecran, [#90CAF9, #E3F2FD])
sinon
dégradé(ecran, [#4FC3F7, #B3E5FC])
fin si
cercle(ecran, 80 + phase * 700, 90 - sinus(radians(phase * 290)) * 30, 18, #FFEE58)
sinon si phase < 0.78 alors
dégradé(ecran, [#7E57C2, #FF8A65, #FFCC80])
sinon
dégradé(ecran, [#0D1B3E, #283593])
ke est un nombre
pour ke de 0 à 20
cercle(ecran, (ke * 89) mod 640, 60 + (ke * 37) mod 90, 1, rgba(255, 255, 255, 0.7))
fin pour
fin si
// les collines au loin
ellipse(ecran, 120, 200, 220, 70, sHerbeOmbre[saison])
ellipse(ecran, 520, 210, 240, 80, sHerbeOmbre[saison])
fin procédure
procédure dessinerFerme()
effacer(ecran)
contour(ecran, #0)
appelle dessinerCiel()
s est un nombre
// ordre du peintre : diagonale par diagonale
pour s de 0 à 2 * TF - 2
gx est un nombre
pour gx de maximum(0, s - TF + 1) à minimum(TF - 1, s)
gy est un nombre
gy vaut s - gx
k est un nombre
k vaut gy * TF + gx
x est un nombre
x vaut ecranX(gx, gy)
y est un nombre
y vaut ecranY(gx, gy)
appelle dessinerTuile(x, y, k)
si culture[k] > 0 alors
appelle dessinerCulture(x, y, k)
fin si
si objet[k] > 0 alors
appelle dessinerObjet(x, y, k)
fin si
si gx = curX et gy = curY alors
appelle dessinerFermier(x, y)
fin si
fin pour
fin pour
appelle dessinerAnimaux()
// la meteo
kp, rx, ry est un nombre
si pluie alors
pour kp de 0 à 40
rx vaut (kp * 53 + tic * 7) mod 660 - 10
ry vaut (kp * 97 + tic * 13) mod 420 + 50
ligne(ecran, rx, ry, rx - 3, ry + 10, rgba(200, 225, 255, 0.6), 1)
fin pour
sinon si saison = 3 alors
pour kp de 0 à 30
rx vaut (kp * 53 + sinus(radians(tic * 3 + kp * 30)) * 10) mod 640
ry vaut (kp * 97 + tic * 2) mod 420 + 50
cercle(ecran, rx, ry, 2, rgba(255, 255, 255, 0.85))
fin pour
fin si
// le soir et la nuit
phase est un nombre
phase vaut tickJour / DUREE_JOUR
si phase > 0.65 alors
rectangle(ecran, 0, 0, 640, 540, rgba(10, 20, 60, limiter((phase - 0.65) * 1.6, 0, 0.45)))
fin si
// les nombres qui s'envolent
si longueur(popT) > 0 alors
kq est un nombre
pour kq de 0 à longueur(popT) - 1
label(ecran, popX[kq], popY[kq], popTxt[kq], #FFFFFF, 13)
fin pour
fin si
fin procédure
procédure dessinerHud()
// le haut : date, meteo, argent, progression
rectangle(ecran, 0, 0, 640, 56, rgba(62, 39, 35, 0.88))
label(ecran, 12, 22, "MA PETITE FERME", #FFE082, 15)
label(ecran, 12, 44, "Jour " + convertir_texte(jour) + " - " + sNom[saison] + " " + convertir_texte(jourSaison) + "/10 - An " + convertir_texte(annee), #FFF8E1, 12)
// l'heure : une barre qui avance
rectangle(ecran, 250, 36, 90, 6, rgba(255, 255, 255, 0.2))
rectangle(ecran, 250, 36, 90 * tickJour / DUREE_JOUR, 6, #FFCA28)
si pluie alors
ellipse(ecran, 362, 22, 12, 7, #ECEFF1)
ligne(ecran, 358, 31, 356, 37, #81D4FA, 2)
ligne(ecran, 366, 31, 364, 37, #81D4FA, 2)
sinon si saison = 3 alors
cercle(ecran, 362, 26, 8, #FFFFFF)
sinon
cercle(ecran, 362, 26, 8, #FFEE58)
fin si
label(ecran, 392, 26, convertir_texte(argent) + " EUR", #FFE082, 17)
label(ecran, 392, 46, "Gagné : " + convertir_texte(totalGagne) + " / " + convertir_texte(OBJECTIF), #D7CCC8, 10)
rectangle(ecran, 530, 38, 98, 6, rgba(255, 255, 255, 0.2))
rectangle(ecran, 530, 38, 98 * minimum(totalGagne, OBJECTIF) / OBJECTIF, 6, #8BC34A)
si palierIdx > 0 alors
label(ecran, 530, 26, palNoms[palierIdx - 1], #C5E1A5, 11)
sinon
label(ecran, 530, 26, "Débutant", #C5E1A5, 11)
fin si
// le stock, en petit, sous le bandeau
rectangle_arrondi(ecran, 8, 62, 128, 112, 10, rgba(62, 39, 35, 0.75))
label(ecran, 18, 78, "Stock", #FFE082, 11)
ks est un nombre
pour ks de 1 à 7
label(ecran, 18, 78 + ks * 13, pNom[ks], #FFF8E1, 10)
label(ecran, 110, 78 + ks * 13, convertir_texte(stock[ks]), #FFFFFF, 10)
fin pour
// la banniere du jour
si banniereT > 0 alors
largB est un nombre
largB vaut label_largeur(banniere, 15) + 40
rectangle_arrondi(ecran, (640 - largB) / 2, 66, largB, 34, 14, rgba(255, 248, 225, 0.95))
label(ecran, (640 - largB) / 2 + 20, 89, banniere, #4E342E, 15)
fin si
// le bas : les outils
rectangle(ecran, 0, 468, 640, 72, rgba(62, 39, 35, 0.9))
ko est un nombre
pour ko de 1 à 5
boutX est un nombre
boutX vaut 10 + (ko - 1) * 84
si ko = outil alors
contour(ecran, #FFE082, 2)
rectangle_arrondi(ecran, boutX, 474, 78, 38, 8, rgba(255, 224, 130, 0.25))
sinon
contour(ecran, rgba(255, 255, 255, 0.15), 1)
rectangle_arrondi(ecran, boutX, 474, 78, 38, 8, rgba(255, 255, 255, 0.05))
fin si
contour(ecran, #0)
label(ecran, boutX + 6, 488, convertir_texte(ko), #BCAAA4, 10)
label(ecran, boutX + 39 - label_largeur(oNom[ko - 1], 12) / 2, 504, oNom[ko - 1], #FFF8E1, 12)
fin pour
// la graine choisie
contour(ecran, cCoul[graineSel], 2)
rectangle_arrondi(ecran, 434, 474, 196, 38, 8, rgba(255, 255, 255, 0.05))
contour(ecran, #0)
cercle(ecran, 450, 493, 7, cCoul[graineSel])
si bonneSaison(graineSel) alors
label(ecran, 464, 490, cNom[graineSel] + " - " + convertir_texte(cGraine[graineSel]) + " EUR", #FFF8E1, 12)
label(ecran, 464, 505, convertir_texte(cJours[graineSel]) + " jours [G] changer", #C5E1A5, 10)
sinon
label(ecran, 464, 490, cNom[graineSel] + " : hors saison", #EF9A9A, 12)
label(ecran, 464, 505, "[G] changer de graine", #EF9A9A, 10)
fin si
label(ecran, 12, 532, message, #FFF8E1, 12)
label(ecran, 470, 532, "M marché N dormir H aide", #A1887F, 10)
fin procédure
procédure dessinerMarche()
rectangle(ecran, 0, 0, 640, 540, rgba(30, 20, 15, 0.6))
rectangle_arrondi(ecran, 50, 70, 540, 400, 16, #FFF8E1)
rectangle_arrondi(ecran, 50, 70, 540, 50, 16, #8D6E63)
label(ecran, 72, 103, "LE MARCHÉ", #FFFFFF, 22)
label(ecran, 430, 102, convertir_texte(argent) + " EUR", #FFE082, 17)
// les onglets
si ongletMarche = 0 alors
rectangle_arrondi(ecran, 220, 80, 90, 30, 12, #FFF8E1)
label(ecran, 240, 101, "Vendre", #5D4037, 14)
label(ecran, 330, 101, "Acheter", #D7CCC8, 14)
sinon
rectangle_arrondi(ecran, 316, 80, 90, 30, 12, #FFF8E1)
label(ecran, 240, 101, "Vendre", #D7CCC8, 14)
label(ecran, 330, 101, "Acheter", #5D4037, 14)
fin si
kl est un nombre
yl est un nombre
si ongletMarche = 0 alors
label(ecran, 300, 140, "Stock", #8D6E63, 11)
label(ecran, 380, 140, "Prix du jour", #8D6E63, 11)
pour kl de 0 à 7
yl vaut 162 + kl * 30
si kl = ligneMarche alors
rectangle_arrondi(ecran, 66, yl - 18, 508, 26, 8, rgba(255, 193, 7, 0.3))
fin si
si kl < 7 alors
label(ecran, 80, yl, pNom[kl + 1], #4E342E, 14)
label(ecran, 300, yl, convertir_texte(stock[kl + 1]), #4E342E, 14)
label(ecran, 380, yl, convertir_texte(prixJour[kl + 1]) + " EUR", #4E342E, 14)
// le prix est-il bon aujourd'hui ?
si prixJour[kl + 1] > pBase[kl + 1] * 1.1 alors
label(ecran, 460, yl, "prix haut !", #2E7D32, 12)
sinon si prixJour[kl + 1] < pBase[kl + 1] * 0.9 alors
label(ecran, 460, yl, "prix bas", #C62828, 12)
fin si
sinon
label(ecran, 80, yl, "TOUT VENDRE", #2E7D32, 14)
fin si
fin pour
sinon
pour kl de 0 à 4
yl vaut 160 + kl * 52
si kl = ligneMarche alors
rectangle_arrondi(ecran, 66, yl - 20, 508, 46, 8, rgba(255, 193, 7, 0.3))
fin si
label(ecran, 80, yl, achNom[kl], #4E342E, 14)
label(ecran, 80, yl + 18, achDescr[kl], #8D6E63, 10)
si argent >= achPrix[kl] alors
label(ecran, 490, yl, convertir_texte(achPrix[kl]) + " EUR", #2E7D32, 14)
sinon
label(ecran, 490, yl, convertir_texte(achPrix[kl]) + " EUR", #C62828, 14)
fin si
fin pour
label(ecran, 80, 430, "Poules : " + convertir_texte(nbPoules) + " Vaches : " + convertir_texte(nbVaches) + " Arroseurs en réserve : " + convertir_texte(nbArroseurs), #5D4037, 11)
fin si
si msgMarche <> "" alors
label(ecran, 320 - label_largeur(msgMarche, 13) / 2, 455, msgMarche, #2E7D32, 13)
fin si
label(ecran, 120, 500, "Q / D : onglet Z / S : choisir ESPACE : valider M : fermer", #FFF8E1, 12)
fin procédure
procédure dessinerTitre()
appelle dessinerFerme()
rectangle_arrondi(ecran, 120, 70, 400, 210, 18, rgba(255, 248, 225, 0.95))
label(ecran, 320 - label_largeur("MA PETITE FERME", 34) / 2, 125, "MA PETITE FERME", #5D4037, 34)
label(ecran, 320 - label_largeur("Sème, récolte, élève... et deviens riche !", 14) / 2, 152, "Sème, récolte, élève... et deviens riche !", #8D6E63, 14)
label(ecran, 320 - label_largeur("ESPACE : jouer", 18) / 2, 196, "ESPACE : jouer", #2E7D32, 18)
label(ecran, 320 - label_largeur("H : comment jouer X : quitter", 14) / 2, 226, "H : comment jouer X : quitter", #8D6E63, 14)
label(ecran, 320 - label_largeur("Objectif : gagner 10 000 EUR", 13) / 2, 258, "Objectif : gagner 10 000 EUR", #C62828, 13)
fin procédure
procédure dessinerAide()
effacer(ecran)
dégradé(ecran, [#5D4037, #3E2723])
label(ecran, 40, 50, "COMMENT JOUER", #FFE082, 26)
label(ecran, 40, 90, "ZQSD ou clic : déplacer le fermier 1 à 5 : choisir un outil", #FFF8E1, 13)
label(ecran, 40, 112, "ESPACE : utiliser l'outil G : changer de graine", #FFF8E1, 13)
label(ecran, 40, 134, "M : le marché N : dormir (passer au jour suivant) P : pause", #FFF8E1, 13)
label(ecran, 40, 172, "LES CULTURES", #C5E1A5, 15)
label(ecran, 40, 196, "1. Laboure l'herbe (Houe) 2. Sème (Graines) 3. Arrose chaque jour", #FFF8E1, 12)
label(ecran, 40, 216, "4. Une culture arrosée grandit d'un jour par nuit. Sans eau 3 jours, elle fane !", #FFF8E1, 12)
label(ecran, 40, 236, "5. Quand elle brille, récolte-la (Faucille). Fraises et tomates repoussent.", #FFF8E1, 12)
label(ecran, 40, 256, "La pluie arrose tout. À chaque nouvelle saison, les cultures hors saison meurent.", #FFF8E1, 12)
label(ecran, 40, 290, "Printemps : carotte, fraise Été : tomate, maïs Automne : carotte, citrouille", #FFE082, 12)
label(ecran, 40, 310, "Hiver : rien ne pousse... vis de tes animaux et de tes réserves !", #FFE082, 12)
label(ecran, 40, 348, "LE MARCHÉ", #C5E1A5, 15)
label(ecran, 40, 372, "Les prix changent chaque jour : vends quand c'est prix haut !", #FFF8E1, 12)
label(ecran, 40, 392, "Achète un poulailler, une étable et des arroseurs automatiques.", #FFF8E1, 12)
label(ecran, 40, 430, "Paliers : Petite ferme 1000 - Ferme 3000 - Grande ferme 6000 - Domaine 10000", #FFE082, 12)
label(ecran, 200, 500, "ESPACE ou H : retour", #BCAAA4, 14)
fin procédure
procédure dessinerVictoire()
appelle dessinerFerme()
rectangle(ecran, 0, 0, 640, 540, rgba(255, 236, 179, 0.35))
rectangle_arrondi(ecran, 110, 130, 420, 230, 18, #FFF8E1)
label(ecran, 320 - label_largeur("DOMAINE PROSPÈRE !", 30) / 2, 185, "DOMAINE PROSPÈRE !", #2E7D32, 30)
label(ecran, 320 - label_largeur("Tu as gagné " + convertir_texte(totalGagne) + " EUR", 16) / 2, 225, "Tu as gagné " + convertir_texte(totalGagne) + " EUR", #5D4037, 16)
label(ecran, 320 - label_largeur("en " + convertir_texte(jour) + " jours de travail. Bravo, fermier !", 14) / 2, 252, "en " + convertir_texte(jour) + " jours de travail. Bravo, fermier !", #8D6E63, 14)
label(ecran, 320 - label_largeur("ESPACE : continuer à jouer X : menu", 13) / 2, 320, "ESPACE : continuer à jouer X : menu", #5D4037, 13)
fin procédure
@ LE PROCESSUS : la ferme vit en temps reel
processus Ferme()
tant que appActif
tic ajoute 1
si etat = 1 alors
tickJour ajoute 1
si tickJour >= DUREE_JOUR alors
appelle nouvelleJournee()
fin si
si banniereT > 0 alors
banniereT soustrait 1
fin si
nbP est un nombre
nbP vaut longueur(popT)
si nbP > 0 alors
kq est un nombre
pour kq de nbP - 1 à 0 pas -1
popT[kq] vaut popT[kq] - 1
popY[kq] vaut popY[kq] - 1
si popT[kq] <= 0 alors
popTxt supprime kq
popX supprime kq
popY supprime kq
popT supprime kq
fin si
fin pour
fin si
appelle dessinerFerme()
appelle dessinerHud()
sinon si etat = 0 alors
appelle dessinerTitre()
sinon si etat = 2 alors
appelle dessinerFerme()
appelle dessinerHud()
appelle dessinerMarche()
sinon si etat = 3 alors
appelle dessinerAide()
sinon si etat = 4 alors
appelle dessinerVictoire()
sinon si etat = 5 alors
appelle dessinerFerme()
appelle dessinerHud()
rectangle(ecran, 0, 0, 640, 540, rgba(0, 0, 0, 0.45))
label(ecran, 320 - label_largeur("PAUSE", 40) / 2, 260, "PAUSE", #FFFFFF, 40)
label(ecran, 320 - label_largeur("P : reprendre X : menu", 15) / 2, 292, "P : reprendre X : menu", #FFE082, 15)
fin si
affiche ecran
pause 100
fin tant que
fin processus
@ DEMARRAGE
appelle nouvellePartie()
Ferme()
tant que appActif
si etat = 0 alors
interagir ecran, [" ", "h", "x"] dans action, ptX, ptY
si action = 1 ou action = 0 alors
appelle nouvellePartie()
etat vaut 1
sinon si action = 2 alors
etat vaut 3
sinon si action = 3 alors
appActif vaut faux
fin si
sinon si etat = 1 alors
interagir ecran, ["z", "q", "s", "d", " ", "1", "2", "3", "4", "5", "g", "n", "m", "p", "h"] dans action, ptX, ptY
si etat = 1 alors
si action = 0 alors
// clic : on retrouve la case sous la souris
rx est un nombre
rx vaut (ptX - OX) / DXT
ry est un nombre
ry vaut (ptY - OY) / DYT
cgx est un nombre
cgx vaut arrondi((rx + ry) / 2)
cgy est un nombre
cgy vaut arrondi((ry - rx) / 2)
si cgx >= 0 et cgx < TF et cgy >= 0 et cgy < TF alors
curX vaut cgx
curY vaut cgy
fin si
sinon si action = 1 alors
curY vaut maximum(0, curY - 1)
sinon si action = 2 alors
curX vaut maximum(0, curX - 1)
sinon si action = 3 alors
curY vaut minimum(TF - 1, curY + 1)
sinon si action = 4 alors
curX vaut minimum(TF - 1, curX + 1)
sinon si action = 5 alors
appelle utiliserOutil()
sinon si action >= 6 et action <= 10 alors
outil vaut action - 5
appelle annoncer(oNom[outil - 1] + " : " + oDescr[outil - 1])
sinon si action = 11 alors
appelle changerGraine()
sinon si action = 12 alors
tickJour vaut DUREE_JOUR
appelle annoncer("Bonne nuit...")
sinon si action = 13 alors
ongletMarche vaut 0
ligneMarche vaut 0
msgMarche vaut ""
etat vaut 2
sinon si action = 14 alors
etat vaut 5
sinon si action = 15 alors
etat vaut 3
fin si
fin si
sinon si etat = 2 alors
interagir ecran, ["z", "s", "q", "d", " ", "m", "x"] dans action, ptX, ptY
nbLignes est un nombre
nbLignes vaut sialors(ongletMarche = 0, 8, 5)
si action = 1 alors
ligneMarche vaut (ligneMarche + nbLignes - 1) mod nbLignes
sinon si action = 2 alors
ligneMarche vaut (ligneMarche + 1) mod nbLignes
sinon si action = 3 ou action = 4 alors
ongletMarche vaut 1 - ongletMarche
ligneMarche vaut 0
msgMarche vaut ""
sinon si action = 5 alors
si ongletMarche = 0 alors
si ligneMarche < 7 alors
appelle vendre(ligneMarche + 1)
sinon
totalVente est un nombre
totalVente vaut 0
kv est un nombre
pour kv de 1 à 7
totalVente vaut totalVente + stock[kv] * prixJour[kv]
stock[kv] vaut 0
fin pour
argent vaut argent + totalVente
totalGagne vaut totalGagne + totalVente
msgMarche vaut "Tout vendu : +" + convertir_texte(totalVente) + " EUR"
appelle verifierPaliers()
fin si
sinon
appelle acheter(ligneMarche)
fin si
sinon si action = 6 ou action = 7 alors
si etat = 2 alors
etat vaut 1
fin si
fin si
sinon si etat = 3 alors
interagir ecran, [" ", "h"] dans action, ptX, ptY
si jour > 1 ou tickJour > 0 alors
etat vaut 1
sinon
etat vaut 0
fin si
sinon si etat = 4 alors
interagir ecran, [" ", "x"] dans action, ptX, ptY
si action = 2 alors
etat vaut 0
sinon
etat vaut 1
fin si
sinon si etat = 5 alors
interagir ecran, ["p", "x"] dans action, ptX, ptY
si action = 2 alors
etat vaut 0
sinon
etat vaut 1
fin si
fin si
fin tant que
effacer(ecran)
dégradé(ecran, [#5D4037, #3E2723])
label(ecran, 320 - label_largeur("À bientôt à la ferme !", 30) / 2, 270, "À bientôt à la ferme !", #FFE082, 30)
affiche ecran