add oldproject folder
228
.gitignore
vendored
@@ -1,26 +1,216 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug
|
||||
target
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[codz]
|
||||
*$py.class
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# Generated by cargo mutants
|
||||
# Contains mutation testing data
|
||||
**/mutants.out*/
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# RustRover
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Added by cargo
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
/target
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
# Pipfile.lock
|
||||
|
||||
# UV
|
||||
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# uv.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
# poetry.lock
|
||||
# poetry.toml
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
||||
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
||||
# pdm.lock
|
||||
# pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# pixi
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
||||
# pixi.lock
|
||||
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
||||
# in the .venv directory. It is recommended not to include this directory in version control.
|
||||
.pixi
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# Redis
|
||||
*.rdb
|
||||
*.aof
|
||||
*.pid
|
||||
|
||||
# RabbitMQ
|
||||
mnesia/
|
||||
rabbitmq/
|
||||
rabbitmq-data/
|
||||
|
||||
# ActiveMQ
|
||||
activemq-data/
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.envrc
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
# .idea/
|
||||
|
||||
# Abstra
|
||||
# Abstra is an AI-powered process automation framework.
|
||||
# Ignore directories containing user credentials, local state, and settings.
|
||||
# Learn more at https://abstra.io/docs
|
||||
.abstra/
|
||||
|
||||
# Visual Studio Code
|
||||
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
||||
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
||||
# you could uncomment the following to ignore the entire vscode folder
|
||||
# .vscode/
|
||||
|
||||
# Ruff stuff:
|
||||
.ruff_cache/
|
||||
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
# Marimo
|
||||
marimo/_static/
|
||||
marimo/_lsp/
|
||||
__marimo__/
|
||||
|
||||
# Streamlit
|
||||
.streamlit/secrets.toml
|
||||
@@ -1,2 +1,4 @@
|
||||
# BakersAdventure
|
||||
Backer's Adventure is an old high school project rewritten in Rust (originally python)
|
||||
# Bakers Adventure
|
||||
|
||||
It was a school projet created in 2 weeks, the projet is not finished but the big is there.
|
||||
it makes me cry but there are responsive so its okay now :-)
|
||||
|
||||
BIN
assets/Image/arrow.png
Executable file
|
After Width: | Height: | Size: 106 B |
BIN
assets/Image/baker/attack_animation/baker_animation_archer_attack1.png
Executable file
|
After Width: | Height: | Size: 691 B |
BIN
assets/Image/baker/attack_animation/baker_animation_archer_attack2.png
Executable file
|
After Width: | Height: | Size: 736 B |
BIN
assets/Image/baker/attack_animation/baker_animation_archer_attack3.png
Executable file
|
After Width: | Height: | Size: 750 B |
BIN
assets/Image/baker/attack_animation/baker_animation_dwarf_attack1.png
Executable file
|
After Width: | Height: | Size: 402 B |
BIN
assets/Image/baker/attack_animation/baker_animation_dwarf_attack2.png
Executable file
|
After Width: | Height: | Size: 428 B |
BIN
assets/Image/baker/attack_animation/baker_animation_dwarf_attack3.png
Executable file
|
After Width: | Height: | Size: 448 B |
BIN
assets/Image/baker/attack_animation/baker_animation_magician_attack1.png
Executable file
|
After Width: | Height: | Size: 601 B |
BIN
assets/Image/baker/attack_animation/baker_animation_magician_attack2.png
Executable file
|
After Width: | Height: | Size: 594 B |
BIN
assets/Image/baker/attack_animation/baker_animation_magician_attack3.png
Executable file
|
After Width: | Height: | Size: 638 B |
BIN
assets/Image/baker/attack_animation/baker_animation_warrior_attack1.png
Executable file
|
After Width: | Height: | Size: 573 B |
BIN
assets/Image/baker/attack_animation/baker_animation_warrior_attack2.png
Executable file
|
After Width: | Height: | Size: 536 B |
BIN
assets/Image/baker/attack_animation/baker_animation_warrior_attack3.png
Executable file
|
After Width: | Height: | Size: 558 B |
BIN
assets/Image/baker/normal_animation/baker_archer1.png
Executable file
|
After Width: | Height: | Size: 709 B |
BIN
assets/Image/baker/normal_animation/baker_archer2.png
Executable file
|
After Width: | Height: | Size: 706 B |
BIN
assets/Image/baker/normal_animation/baker_archer3.png
Executable file
|
After Width: | Height: | Size: 707 B |
BIN
assets/Image/baker/normal_animation/baker_dwarf1.png
Executable file
|
After Width: | Height: | Size: 398 B |
BIN
assets/Image/baker/normal_animation/baker_dwarf2.png
Executable file
|
After Width: | Height: | Size: 421 B |
BIN
assets/Image/baker/normal_animation/baker_dwarf3.png
Executable file
|
After Width: | Height: | Size: 426 B |
BIN
assets/Image/baker/normal_animation/baker_magician1.png
Executable file
|
After Width: | Height: | Size: 596 B |
BIN
assets/Image/baker/normal_animation/baker_magician2.png
Executable file
|
After Width: | Height: | Size: 594 B |
BIN
assets/Image/baker/normal_animation/baker_magician3.png
Executable file
|
After Width: | Height: | Size: 572 B |
BIN
assets/Image/baker/normal_animation/baker_warrior1.png
Executable file
|
After Width: | Height: | Size: 556 B |
BIN
assets/Image/baker/normal_animation/baker_warrior2.png
Executable file
|
After Width: | Height: | Size: 556 B |
BIN
assets/Image/baker/normal_animation/baker_warrior3.png
Executable file
|
After Width: | Height: | Size: 560 B |
BIN
assets/Image/bg.png
Executable file
|
After Width: | Height: | Size: 121 KiB |
BIN
assets/Image/bread.png
Executable file
|
After Width: | Height: | Size: 46 KiB |
BIN
assets/Image/crosshair.png
Executable file
|
After Width: | Height: | Size: 168 B |
BIN
assets/Image/cursor-png-1127.png
Executable file
|
After Width: | Height: | Size: 216 B |
BIN
assets/Image/cursor_pointer.png
Executable file
|
After Width: | Height: | Size: 242 B |
BIN
assets/Image/heal.png
Executable file
|
After Width: | Height: | Size: 106 B |
BIN
assets/Image/menu.png
Executable file
|
After Width: | Height: | Size: 592 B |
BIN
assets/Image/menu_closed.png
Executable file
|
After Width: | Height: | Size: 293 B |
BIN
assets/Image/monstercookie/monstercookie1.png
Executable file
|
After Width: | Height: | Size: 900 B |
BIN
assets/Image/monstercookie/monstercookie2.png
Executable file
|
After Width: | Height: | Size: 899 B |
BIN
assets/Image/monstercookie/monstercookie3.png
Executable file
|
After Width: | Height: | Size: 892 B |
BIN
assets/Image/nope_cursor.png
Executable file
|
After Width: | Height: | Size: 166 B |
BIN
assets/Image/pointer.png
Executable file
|
After Width: | Height: | Size: 254 B |
BIN
assets/Image/socle.png
Executable file
|
After Width: | Height: | Size: 701 B |
BIN
assets/Image/weapon/bow.png
Executable file
|
After Width: | Height: | Size: 180 B |
BIN
assets/Image/weapon/crossbow.png
Executable file
|
After Width: | Height: | Size: 294 B |
BIN
assets/Image/weapon/healing_potion.png
Executable file
|
After Width: | Height: | Size: 189 B |
BIN
assets/Image/weapon/knife.png
Executable file
|
After Width: | Height: | Size: 212 B |
BIN
assets/Image/weapon/magic_stick.png
Executable file
|
After Width: | Height: | Size: 195 B |
BIN
assets/Image/weapon/sword.png
Executable file
|
After Width: | Height: | Size: 228 B |
BIN
assets/Music/boculezelta.mp3
Executable file
BIN
assets/Music/musique_2019.mp3
Executable file
BIN
assets/Music/phonk.mp3
Executable file
BIN
assets/Music/phonk/phonk.ogg
Executable file
BIN
assets/Music/phonk/phonk_boucle.ogg
Executable file
BIN
assets/Music/phonk/phonk_fin.mp3
Executable file
12
assets/Rect.py
Executable file
@@ -0,0 +1,12 @@
|
||||
import pygame
|
||||
from game.settings import*
|
||||
|
||||
class Page:
|
||||
def __init__(self, top, left, width, height, rgb = (0, 0, 0)):
|
||||
self.rgb = rgb
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.draw = pygame.draw.rect(SCREEN, self.rgb, pygame.Rect(top, left, self.width, self.height))
|
||||
|
||||
def collision(self, x, y):
|
||||
return self.draw.collidepoint((x, y))
|
||||
11
assets/image.py
Executable file
@@ -0,0 +1,11 @@
|
||||
import pygame
|
||||
import os
|
||||
|
||||
class Image(pygame.sprite.Sprite):
|
||||
def __init__(self, image:str, size):
|
||||
self.image_path = os.path.join(os.path.dirname(f"{os.path.realpath(__file__)}"), f"image/{image}") # entrer les noms d'images ( + extension) du sprite
|
||||
self.load = pygame.transform.scale(pygame.image.load(self.image_path).convert_alpha(), size)
|
||||
|
||||
def get_collision(self, x, y):
|
||||
return self.load.get_rect().collidepoint(x, y)
|
||||
|
||||
15
assets/music.py
Executable file
@@ -0,0 +1,15 @@
|
||||
import pygame
|
||||
import os
|
||||
|
||||
class Music:
|
||||
def __init__(self, music:str, SOUND, replay = False):
|
||||
|
||||
self.music_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),f"Music/{music}") # entrer le nom de la musique ( + extension) de la musique
|
||||
self.load = pygame.mixer.music.load(self.music_path)
|
||||
self.load = pygame.mixer.music.set_volume(SOUND)
|
||||
|
||||
if replay: self.load = pygame.mixer.music.play(-1)
|
||||
else: self.load = pygame.mixer.music.play(1)
|
||||
|
||||
def get_time(self):
|
||||
return pygame.mixer.music.get_pos()
|
||||
29
entity/Heros.py
Executable file
@@ -0,0 +1,29 @@
|
||||
from random import randint
|
||||
|
||||
class Hero():
|
||||
def __init__(self, life:int, mana:int, punch_damage:int,magic:bool, range:bool, strength:bool , name:str):
|
||||
#int
|
||||
self.punch_damage = punch_damage
|
||||
self.started_life = life
|
||||
self.life = life
|
||||
self.mana = mana
|
||||
self.name = name
|
||||
|
||||
#bool
|
||||
self.magic = magic
|
||||
self.range = range
|
||||
self.strength = strength
|
||||
|
||||
def is_dodging(self):
|
||||
#bool
|
||||
|
||||
if randint(1, 4) == 4: return True
|
||||
else: return False
|
||||
|
||||
|
||||
baker_warrior = Hero(125, 50, 34, 0, 0, 1, "baker warrior") #speciality : strength
|
||||
baker_magician = Hero(60, 120, 30, 1, 0, 0, "baker magician") #speciality : magic
|
||||
baker_dwarf = Hero(90, 80, 100, 0, 0, 0, "baker dwarf") #speciality : his fists
|
||||
baker_archer = Hero(65, 60, 25, 0, 1, 0, "baker archer") #speciality : ranger
|
||||
|
||||
print("Heros class loaded")
|
||||
40
entity/Inventory.py
Executable file
@@ -0,0 +1,40 @@
|
||||
from entity.Utilities import*
|
||||
|
||||
class Inventory():
|
||||
def __init__(self):
|
||||
self.content = [
|
||||
[], #knifes
|
||||
[], #swords
|
||||
[], #bows
|
||||
[], #crossbows
|
||||
[], #magic_sticks
|
||||
[], #healing Potions
|
||||
]
|
||||
|
||||
def is_inventory_full(self, item):
|
||||
if item == knife:
|
||||
if len(self.content[0]) < 4: self.content[0].append(item)
|
||||
else: return False
|
||||
|
||||
if item == sword:
|
||||
if len(self.content[1]) < 4: self.content[1].append(item)
|
||||
else: return False
|
||||
|
||||
if item == bow:
|
||||
if len(self.content[2]) < 4: self.content[2].append(item)
|
||||
else: return False
|
||||
|
||||
if item == crossbow:
|
||||
if len(self.content[3]) < 4: self.content[3].append(item)
|
||||
else: return False
|
||||
|
||||
if item == magic_stick:
|
||||
if len(self.content[4]) < 4: self.content[4].append(item)
|
||||
else: return False
|
||||
|
||||
if item == healing_potion:
|
||||
if len(self.content[5]) <2: self.content[5].append(item)
|
||||
else: return False
|
||||
|
||||
baker_inventory = Inventory()
|
||||
print("Inventory class loaded")
|
||||
25
entity/Monsters.py
Executable file
@@ -0,0 +1,25 @@
|
||||
import random
|
||||
import os
|
||||
|
||||
class Monster():
|
||||
def __init__(self, mana:int, big:bool):
|
||||
#monster's name
|
||||
|
||||
file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'names.txt')
|
||||
with open(f"{file}") as txt: self.name = txt.readlines()[random.randint(0, len(file))]
|
||||
#int
|
||||
self.life = random.randint(150, 500)
|
||||
self.mana = mana
|
||||
self.damage = 25
|
||||
|
||||
#bool
|
||||
if big:
|
||||
self.life += 150
|
||||
self.damage += 35
|
||||
|
||||
def is_dodging():
|
||||
#bool
|
||||
if random.randint(1, 7) == 5: return True
|
||||
else: return False
|
||||
|
||||
print("Monsters class loaded")
|
||||
33
entity/Utilities.py
Executable file
@@ -0,0 +1,33 @@
|
||||
import random
|
||||
|
||||
class Weapon():
|
||||
def __init__(self, damage_send:int, durability:int, magic:bool, range:bool, strength:bool, name):
|
||||
#int
|
||||
|
||||
self.damage = damage_send
|
||||
self.durability = durability
|
||||
self.name = name
|
||||
|
||||
#bool
|
||||
|
||||
self.magic = magic
|
||||
self.range = range
|
||||
self.strength = strength
|
||||
|
||||
|
||||
|
||||
knife = Weapon(100 + random.randint(0, 20), 10 + random.randint(0, 15), 0, 0, 1, "knife")
|
||||
sword = Weapon(124 + random.randint(0, 10), 7 + random.randint(0, 15), 0, 0, 1, "sword")
|
||||
bow = Weapon(120 + random.randint(0, 25), 14 + random.randint(0, 7), 0, 1, 0, "bow")
|
||||
crossbow = Weapon(100 + random.randint(0, 15), 17 + random.randint(0, 15), 0, 1, 0, "crossbow")
|
||||
magic_stick = Weapon(150 + random.randint(0, 35), 50 + random.randint(0, 15), 1, 0, 0, "magic_stick")
|
||||
|
||||
print("weapons class loaded")
|
||||
|
||||
class Potion():
|
||||
def __init__(self, heal:int):
|
||||
self.heal = heal
|
||||
|
||||
healing_potion = Potion(random.randint(5, 40))
|
||||
|
||||
print("potion class loaded")
|
||||
18239
entity/names.txt
Executable file
69
game/fight.py
Executable file
@@ -0,0 +1,69 @@
|
||||
from entity.Inventory import*
|
||||
from entity.Heros import*
|
||||
from entity.Monsters import*
|
||||
|
||||
import random
|
||||
|
||||
class Fight:
|
||||
def __init__(self):
|
||||
self.round = [
|
||||
baker_archer,
|
||||
baker_dwarf,
|
||||
baker_magician,
|
||||
baker_warrior
|
||||
]
|
||||
self.hero = [
|
||||
baker_archer,
|
||||
baker_dwarf,
|
||||
baker_magician,
|
||||
baker_warrior
|
||||
]
|
||||
|
||||
self.ennemies = []
|
||||
self.current_round = 0
|
||||
self.current_round_player = 0
|
||||
self.is_fighting = True
|
||||
|
||||
#list life
|
||||
|
||||
self.hero_life = [
|
||||
baker_archer.life,
|
||||
baker_dwarf.life,
|
||||
baker_magician.life,
|
||||
baker_warrior.life
|
||||
]
|
||||
self.ennemies_life = []
|
||||
|
||||
|
||||
def shuffle_order(self):
|
||||
for i in range(random.randint(1, 3)):
|
||||
self.is_big = False
|
||||
monster = Monster(10, self.is_big)
|
||||
if random.randint(1, 9) == 5:
|
||||
self.is_big = True
|
||||
|
||||
self.ennemies_life.append(monster.life)
|
||||
self.ennemies.append(monster)
|
||||
self.round.append(monster)
|
||||
|
||||
random.shuffle(self.round)
|
||||
return self.round
|
||||
|
||||
def is_playing(self):
|
||||
self.hero_selected = False
|
||||
|
||||
if self.round[self.current_round] in self.hero:
|
||||
for is_hero in self.hero:
|
||||
if self.round[self.current_round] == is_hero:
|
||||
self.hero_selected = True
|
||||
|
||||
return self.hero_selected
|
||||
|
||||
def inventory_randomly(self):
|
||||
items = [knife, sword, crossbow, bow, magic_stick, healing_potion]
|
||||
|
||||
for i in range(random.randint(1, 15)):
|
||||
baker_inventory.is_inventory_full(items[random.randint(0, len(items)-1)])
|
||||
|
||||
fight = Fight()
|
||||
|
||||
24
game/game.py
Executable file
@@ -0,0 +1,24 @@
|
||||
import pygame
|
||||
|
||||
from assets.image import*
|
||||
from assets.music import*
|
||||
from assets.Rect import*
|
||||
|
||||
from game.settings import*
|
||||
|
||||
def initialisation():
|
||||
pygame.init() #allumer pygame
|
||||
pygame.mixer.init() #allumer l'audio de pygame
|
||||
Music("musique_2019.mp3", SOUND, True)
|
||||
|
||||
|
||||
def runcursor():
|
||||
pygame.mouse.set_visible(False)
|
||||
X_AXIS_POS, Y_AXIS_POS = pygame.mouse.get_pos()
|
||||
x, y = X_AXIS_POS, Y_AXIS_POS
|
||||
|
||||
return x, y
|
||||
|
||||
def information(X_AXIS, Y_AXIS, Clock):
|
||||
information = Text(X_AXIS, Y_AXIS).render(f"Screen Size: {X_AXIS}/{Y_AXIS} FPS: {round(Clock.get_fps())}", False, (255, 255, 255))
|
||||
SCREEN.blit(information, (X_AXIS//1.6, 5))
|
||||
60
game/hand_detection.py
Executable file
@@ -0,0 +1,60 @@
|
||||
import cv2
|
||||
import mediapipe as mp
|
||||
from cvzone.HandTrackingModule import HandDetector
|
||||
|
||||
mp_drawing = mp.solutions.drawing_utils
|
||||
mp_drawing_styles = mp.solutions.drawing_styles #initialisation des modules
|
||||
mp_hands = mp.solutions.hands
|
||||
|
||||
|
||||
class HandTracking:
|
||||
def __init__(self):
|
||||
self.hand_tracking = mp_hands.Hands(min_detection_confidence=0.5, min_tracking_confidence=0.5)
|
||||
# self.detector = HandDetector(detectionCon=0.8, maxHands=1)
|
||||
self.cap = cv2.VideoCapture(0)
|
||||
|
||||
self.hand_x = 0
|
||||
self.hand_y = 0 #coordonnées
|
||||
self.axis_x = 0
|
||||
self.axis_y = 0
|
||||
|
||||
self.results = None
|
||||
self.hand_closed = False
|
||||
|
||||
|
||||
def scan_hands(self):
|
||||
_, self.frame = self.cap.read() #initialiser la cam
|
||||
self.frame.shape
|
||||
self.frame = cv2.cvtColor(cv2.flip(self.frame, 1), cv2.COLOR_BGR2RGB) #mettre un filtre
|
||||
self.frame.flags.writeable = False
|
||||
|
||||
self.results = self.hand_tracking.process(self.frame)
|
||||
|
||||
#mettre le filtre sur la cam
|
||||
self.frame.flags.writeable = True
|
||||
self.frame = cv2.cvtColor(self.frame, cv2.COLOR_RGB2BGR)
|
||||
|
||||
self.hand_closed = False
|
||||
|
||||
if self.results.multi_hand_landmarks:
|
||||
for hand_landmarks in self.results.multi_hand_landmarks:
|
||||
x, y = hand_landmarks.landmark[9].x, hand_landmarks.landmark[9].y
|
||||
|
||||
self.hand_x = int(x * self.axis_x)
|
||||
self.hand_y = int(y * self.axis_y) #pour chaque point de la main
|
||||
|
||||
y_close = hand_landmarks.landmark[12].y
|
||||
|
||||
if y < y_close and y < hand_landmarks.landmark[0].y: #fermer la main
|
||||
self.hand_closed = True
|
||||
|
||||
mp_drawing.draw_landmarks(
|
||||
self.frame,
|
||||
hand_landmarks,
|
||||
mp_hands.HAND_CONNECTIONS, #optimisation
|
||||
mp_drawing_styles.get_default_hand_landmarks_style(),
|
||||
mp_drawing_styles.get_default_hand_connections_style()
|
||||
)
|
||||
cv2.imshow("Camera Baker Adventure", self.frame) #afficher la caméra
|
||||
|
||||
hand_tracking = HandTracking()
|
||||
118
game/settings.py
Executable file
@@ -0,0 +1,118 @@
|
||||
import pygame # importer pygame (il sert à faire une fenêtre avec des fonctions expret pour les jeux)
|
||||
import pyautogui # importer pyautogui (il sert juste à prendre la résolution de l'écran)
|
||||
|
||||
click_cursor = False # créer la variable cliquer curseur False
|
||||
is_mouse = True # créer la variable si c'est la souris True
|
||||
|
||||
SOUND = 0.15 # la variable sound
|
||||
FPS = 60 # les images maximales par secondes
|
||||
|
||||
x, y = 0, 0
|
||||
if_cursor = 0
|
||||
time_click = 0
|
||||
|
||||
image = 0
|
||||
current_hero_image = 0
|
||||
|
||||
crosshair = [
|
||||
'cursor-png-1127.png',
|
||||
'crosshair.png',
|
||||
'cursor_pointer.png',
|
||||
'nope_cursor.png'
|
||||
]
|
||||
|
||||
cookiemonster = [
|
||||
'monstercookie/monstercookie1.png',
|
||||
'monstercookie/monstercookie2.png',
|
||||
'monstercookie/monstercookie3.png'
|
||||
]
|
||||
|
||||
heros = [[
|
||||
['baker/normal_animation/baker_archer1.png','baker/normal_animation/baker_archer2.png','baker/normal_animation/baker_archer3.png'],
|
||||
# baker archer normal animation
|
||||
|
||||
['baker/normal_animation/baker_dwarf1.png','baker/normal_animation/baker_dwarf2.png','baker/normal_animation/baker_dwarf3.png'],
|
||||
# baker dwarf normal animation
|
||||
|
||||
['baker/normal_animation/baker_magician1.png','baker/normal_animation/baker_magician2.png','baker/normal_animation/baker_magician3.png'],
|
||||
# baker magician normal animation
|
||||
|
||||
['baker/normal_animation/baker_warrior1.png','baker/normal_animation/baker_warrior2.png','baker/normal_animation/baker_warrior3.png']
|
||||
# baker warrior normal animation
|
||||
],[
|
||||
['baker/attack_animation/baker_animation_archer_attack1.png','baker/attack_animation/baker_animation_archer_attack2.png','baker/attack_animation/baker_animation_archer_attack3.png'],
|
||||
# baker archer attack animation
|
||||
|
||||
['baker/attack_animation/baker_animation_dwarf_attack1.png','baker/attack_animation/baker_animation_dwarf_attack2.png','baker/attack_animation/baker_animation_dwarf_attack3.png'],
|
||||
# baker dwarf attack animation
|
||||
|
||||
['baker/attack_animation/baker_animation_magician_attack1.png','baker/attack_animation/baker_animation_magician_attack2.png','baker/attack_animation/baker_animation_magician_attack3.png'],
|
||||
# baker magician attack animation
|
||||
|
||||
['baker/attack_animation/baker_animation_warrior_attack1.png','baker/attack_animation/baker_animation_warrior_attack2.png','baker/attack_animation/baker_animation_warrior_attack3.png']
|
||||
# baker warrior attack animation
|
||||
]]
|
||||
monster_animation = 0
|
||||
attack_animation = 0
|
||||
animation = 0
|
||||
opening = 0
|
||||
monster1_attack = False
|
||||
monster2_attack = False
|
||||
monster3_attack = False
|
||||
|
||||
exit_game = False
|
||||
# les couleurs des blocks du jeu dans le menu
|
||||
|
||||
game_type_color = (200, 200, 200) # les couleurs du bouton "Play"
|
||||
change_type_color = (200, 200, 200) # les couleurs du bouton "Change mode"
|
||||
quit_type_color = (200, 200, 200) # les couleurs du bouton "quit game"
|
||||
quit_type_color_yes = (200, 200, 200)
|
||||
quit_type_color_no = (200, 200, 200)
|
||||
color_text_game_button = (10, 10, 10) # les couleurs du text "play"
|
||||
color_text_change_type = (10, 10, 10) # les couleurs du text "change mode"
|
||||
color_text_quit_type = (10, 10, 10) # les couleurs du text "quit game"
|
||||
|
||||
color_attack_button = (50, 50, 50)
|
||||
color_heal_button = (50, 50, 50)
|
||||
color_names = (25, 25, 25)
|
||||
|
||||
knife_color_page = (86, 66, 46)
|
||||
sword_color_page = (86, 66, 46)
|
||||
crossbow_color_page = (86, 66, 46)
|
||||
bow_color_page = (86, 66, 46)
|
||||
magic_stick_color_page = (86, 66, 46)
|
||||
healing_potion_color_page = (86, 66, 46)
|
||||
|
||||
X_AXIS_GAME, Y_AXIS_GAME = pyautogui.size() # avoir la resolution de l'écran
|
||||
Y_AXIS_GAME -= 63 # -63 pour pas que le jeu sois en plein écran fenêtré
|
||||
|
||||
SCREEN = pygame.display.set_mode((X_AXIS_GAME, Y_AXIS_GAME), pygame.RESIZABLE) # définir l'écran du jeu avec la résolution de l'ecran et pygame.RESIZABLE sert à pouvoir bouger l'écran (dans la partie responsive)
|
||||
pygame.display.set_caption("Bakers Adventure")
|
||||
|
||||
def Text(X_AXIS, Y_AXIS):
|
||||
return pygame.font.SysFont('./Liberation Serif', (X_AXIS//150 + Y_AXIS//150)) # faire une fonction qui permet d'écrire ce qu'on veut avec la police liberation serif
|
||||
|
||||
mainpage = True # ouvrir la page de menu
|
||||
launchgame = False # ouvrir la page du jeu
|
||||
settings = False # ouvrir la page des settings
|
||||
game_inventory = False
|
||||
game_choice = True
|
||||
choice = False
|
||||
main_choice = True
|
||||
inventory_opened = False
|
||||
animation_launched = False
|
||||
|
||||
choice_hero = True
|
||||
|
||||
knife_chosen = False
|
||||
sword_chosen = False
|
||||
bow_chosen = False
|
||||
crossbow_chosen = False
|
||||
magic_stick_chosen = False
|
||||
|
||||
healing_potion_chosen = False
|
||||
|
||||
start_music = True
|
||||
middle_music = True
|
||||
end_music = True
|
||||
|
||||
8
installer/install.bat
Executable file
@@ -0,0 +1,8 @@
|
||||
@echo off
|
||||
|
||||
pip install -r requirements.txt
|
||||
|
||||
echo.
|
||||
echo installation is ready
|
||||
|
||||
pause
|
||||
8
installer/requirements.txt
Executable file
@@ -0,0 +1,8 @@
|
||||
pygame==2.1.2
|
||||
cvzone==1.5.6
|
||||
opencv-contrib-python==4.7.0.68
|
||||
opencv-python==4.7.0.68
|
||||
PyAutoGUI==0.9.53
|
||||
mediapipe>= 0.9.0.1
|
||||
numpy==1.24.1
|
||||
keyboard==0.13.5
|
||||
5
launch.bat
Executable file
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
|
||||
cd ..
|
||||
|
||||
python .\Bakers_Adventure\main.py
|
||||
746
main.py
Executable file
@@ -0,0 +1,746 @@
|
||||
from game.fight import*
|
||||
from game.game import*
|
||||
from game.fight import*
|
||||
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
initialisation()
|
||||
Clock = pygame.time.Clock()
|
||||
|
||||
while True:
|
||||
|
||||
click_cursor = False # la fonction si c'est cliqué
|
||||
X_AXIS, Y_AXIS = SCREEN.get_size() # la taille de la fenêtre
|
||||
|
||||
for event in pygame.event.get(): # pour tout les evenements du jeu
|
||||
if event.type == pygame.QUIT: # si l'élément est quitter
|
||||
# fermer le programme
|
||||
pygame.quit() # quitter la page pygame
|
||||
sys.exit() # fermer tout les processus en cours
|
||||
|
||||
if event.type == pygame.KEYDOWN: # si c'est une touche préssée
|
||||
if event.key == pygame.K_DELETE: # si la touche préssée est suppr
|
||||
# fermer le programme
|
||||
pygame.quit() # quitter la page pygame
|
||||
sys.exit() # fermer tout les processus en cours
|
||||
|
||||
if time_click < 18: # fait un cooldown pour chaque clique de la souris
|
||||
time_click += 1
|
||||
|
||||
if is_mouse:
|
||||
x, y = runcursor() # avoir x et y de la fonction (crée)
|
||||
if event.type == pygame.MOUSEBUTTONDOWN and time_click == 18: # si c'est clique souris et time_click qui est 15
|
||||
click_cursor = True # faire un clique souris
|
||||
time_click = 0
|
||||
else:
|
||||
try:
|
||||
import game.hand_detection as handdetection
|
||||
|
||||
handdetection.hand_tracking.axis_x, handdetection.hand_tracking.axis_y = X_AXIS, Y_AXIS
|
||||
x, y = handdetection.hand_tracking.hand_x, handdetection.hand_tracking.hand_y # transformer hand_x et hand_y en x et y
|
||||
handdetection.hand_tracking.scan_hands()
|
||||
|
||||
if handdetection.hand_tracking.hand_closed: click_cursor = True
|
||||
|
||||
pygame.mouse.set_visible(True) #la souris de l'ordianteur est visible
|
||||
|
||||
if handdetection.hand_tracking.hand_closed and time_click == 18: #si la main est fermée et time_click == 15
|
||||
click_cursor = True
|
||||
time_click = 0
|
||||
|
||||
except:
|
||||
error_install_modules = Text(X_AXIS, Y_AXIS).render("install modules !", False, (255, 255, 255))
|
||||
SCREEN.blit(error_install_modules, (X_AXIS//2.25, 1)) # si c'est la main qui est utilisée ou la souris
|
||||
try:
|
||||
if mainpage:
|
||||
SCREEN.fill((37,40,80))
|
||||
game_type = Page(X_AXIS//2.7, Y_AXIS//2.75, X_AXIS//4, Y_AXIS//10, game_type_color)
|
||||
game_type_text = pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//100 + Y_AXIS//100)).render("Play", False, color_text_game_button)
|
||||
|
||||
SCREEN.blit(game_type_text, (X_AXIS//2.08, Y_AXIS//2.5))
|
||||
|
||||
change_type = Page(X_AXIS//2.7, Y_AXIS//2, X_AXIS//4, Y_AXIS//10, change_type_color)
|
||||
change_type_text = pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//100 + Y_AXIS//100)).render("Change mode", False, color_text_change_type) #bouton changer de mode
|
||||
SCREEN.blit(change_type_text, (X_AXIS//2.195, Y_AXIS//1.8555))
|
||||
|
||||
quit_type = Page(X_AXIS//2.7, Y_AXIS//1.566, X_AXIS//4, Y_AXIS//10, quit_type_color)
|
||||
quit_type_text = pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//100 + Y_AXIS//100)).render("quit game", False, color_text_quit_type) #bouton quit
|
||||
SCREEN.blit(quit_type_text, (X_AXIS//2.156, Y_AXIS//1.483))
|
||||
|
||||
if quit_type.collision(x, y) and click_cursor:
|
||||
exit_game = True
|
||||
|
||||
|
||||
if click_cursor and game_type.collision(x, y): launchgame = True #lancer la partie
|
||||
if game_type.collision(x, y):
|
||||
game_type_color = (145, 145, 145) #changer la couleur du bouton
|
||||
color_text_game_button = (255, 255, 255)
|
||||
else:
|
||||
game_type_color = (200, 200, 200)
|
||||
color_text_game_button = (10, 10, 10)
|
||||
|
||||
if click_cursor and change_type.collision(x, y):
|
||||
if is_mouse: is_mouse = False #changer de mode entre avec souris ou avec la main
|
||||
else: is_mouse = True
|
||||
|
||||
if change_type.collision(x, y):
|
||||
change_type_color = (145, 145, 145) #activer bouton du changement de mode
|
||||
color_text_change_type = (255, 255, 255)
|
||||
else:
|
||||
change_type_color = (200, 200, 200) #changer couleur du changement de mode
|
||||
color_text_change_type = (10, 10, 10)
|
||||
|
||||
if click_cursor and quit_type.collision(x, y): #activer bouton du bouton settings
|
||||
pygame.quit() #bouton quitter le jeu
|
||||
sys.exit()
|
||||
if quit_type.collision(x, y):
|
||||
quit_type_color = (145, 145, 145) #changer la couleur du bouton settings
|
||||
color_text_quit_type = (255, 255, 255)
|
||||
else:
|
||||
quit_type_color = (200, 200, 200)
|
||||
color_text_quit_type = (10, 10, 10)
|
||||
SCREEN.blit(pygame.font.SysFont('./Liberation Serif', (X_AXIS//200 + Y_AXIS//200)).render("The game can change", False, (255, 255, 255)), (1, Y_AXIS-70))
|
||||
|
||||
if launchgame: #lancer le jeu
|
||||
opening += 1 #lancer le temps de l'opening
|
||||
if opening >= 3*round(Clock.get_fps()): #si l'opening est passé
|
||||
|
||||
if fight.is_fighting:
|
||||
|
||||
fight.shuffle_order() #mettre l'ordre aléatoire
|
||||
fight.inventory_randomly() #mettre des objets aléatoire
|
||||
fight.is_fighting = False
|
||||
|
||||
if middle_music and pygame.mixer.music.get_pos() == -1:
|
||||
Music("phonk/phonk_boucle.ogg", SOUND, True)
|
||||
middle_music = False
|
||||
|
||||
if sum(fight.hero_life) > 0 and sum(fight.ennemies_life) > 0: #si un des deux n'a plus de vie
|
||||
|
||||
if fight.current_round == (len(fight.round)-1): #si len(fight.round) est égal à current_round
|
||||
fight.current_round = 0
|
||||
|
||||
SCREEN.fill((37,40,80))
|
||||
image += 1
|
||||
|
||||
if image >= round(Clock.get_fps())//2: #animations
|
||||
current_hero_image += 1 #les frames d'animations pour chaque image
|
||||
image = 0
|
||||
|
||||
if current_hero_image == 3: current_hero_image = 0 #revenir à la première frames
|
||||
|
||||
monster = Image(cookiemonster[current_hero_image], (X_AXIS//4, Y_AXIS//2))
|
||||
|
||||
baker_archer_collision = Page(X_AXIS//12, Y_AXIS//2.1, X_AXIS//15, Y_AXIS//5, (37, 40, 80))
|
||||
baker_dwarf_collision = Page(X_AXIS//6.25, Y_AXIS//1.7, X_AXIS//15, Y_AXIS//5, (37, 40, 80))
|
||||
baker_magician_collision = Page(X_AXIS//5.55, Y_AXIS//2.7, X_AXIS//15, Y_AXIS//5, (37, 40, 80)) #les persos pour cliquer
|
||||
baker_warrior_collision = Page(X_AXIS//3.85, Y_AXIS//2, X_AXIS//15, Y_AXIS//5, (37, 40, 80))
|
||||
|
||||
if len(fight.ennemies) == 1:
|
||||
monster_1 = Page(X_AXIS//1.35,Y_AXIS//1.9, X_AXIS//10, Y_AXIS//5, (37, 40, 80)) #si un il y a 1 monstre
|
||||
|
||||
elif len(fight.ennemies) == 2:
|
||||
monster_1 = Page(X_AXIS//1.35,Y_AXIS//3, X_AXIS//10, Y_AXIS//5, (37, 40, 80))
|
||||
monster_2 = Page(X_AXIS//1.35,Y_AXIS//1.75, X_AXIS//10, Y_AXIS//5, (37, 40, 80)) #si un il y a 2 monstre
|
||||
|
||||
elif len(fight.ennemies) == 3:
|
||||
monster_1 = Page(X_AXIS//1.28,Y_AXIS//2.9, X_AXIS//10, Y_AXIS//5, (37, 40, 80))
|
||||
monster_2 = Page(X_AXIS//1.28,Y_AXIS//1.75, X_AXIS//10, Y_AXIS//5, (37, 40, 80)) #si un il y a 3 monstre
|
||||
monster_3 = Page(X_AXIS//1.52,Y_AXIS//2, X_AXIS//10, Y_AXIS//5, (37, 40, 80))
|
||||
|
||||
SCREEN.blit(Image('socle.png', (X_AXIS//4, Y_AXIS//2.5)).load, (X_AXIS//12.7, Y_AXIS//2))
|
||||
SCREEN.blit(Image('socle.png', (X_AXIS//4, Y_AXIS//2.5)).load, (X_AXIS//1.5, Y_AXIS//2)) #les socles en dessous des persos
|
||||
|
||||
baker_archer_character = Image(heros[0][0][current_hero_image], (X_AXIS//10, Y_AXIS//5.5))
|
||||
baker_dwarf_character = Image(heros[0][1][current_hero_image], (X_AXIS//10, Y_AXIS//5.5))
|
||||
baker_magician_character = Image(heros[0][2][current_hero_image], (X_AXIS//10, Y_AXIS//5.5)) #dessiner les persos
|
||||
baker_warrior_character = Image(heros[0][3][current_hero_image], (X_AXIS//10, Y_AXIS//5.5))
|
||||
|
||||
if fight.hero_life[0] > 0:
|
||||
SCREEN.blit(baker_archer_character.load, (X_AXIS//15, Y_AXIS//2.1)) #dessiner les heros
|
||||
|
||||
if X_AXIS > Y_AXIS: SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[0]} {fight.hero[0].name}", False, color_names), (X_AXIS//12, Y_AXIS//1.5))
|
||||
else: SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[0]}", False, color_names), (X_AXIS//10, Y_AXIS//1.5))
|
||||
|
||||
if fight.hero_life[1] > 0:
|
||||
SCREEN.blit(baker_dwarf_character.load, (X_AXIS//7, Y_AXIS//1.7))
|
||||
|
||||
if X_AXIS > Y_AXIS: SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[1]} {fight.hero[1].name}", False, color_names), (X_AXIS//6.1, Y_AXIS//1.29))
|
||||
else: SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[1]}", False, color_names), (X_AXIS//5.4, Y_AXIS//1.29))
|
||||
|
||||
if fight.hero_life[2] > 0 :
|
||||
SCREEN.blit(baker_magician_character.load, (X_AXIS//6, Y_AXIS//2.7))
|
||||
|
||||
if X_AXIS > Y_AXIS: SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[2]} {fight.hero[2].name}", False, color_names), (X_AXIS//5.6, Y_AXIS//1.79))
|
||||
else: SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[2]}", False, color_names), (X_AXIS//4.9, Y_AXIS//1.79))
|
||||
|
||||
if fight.hero_life[3] > 0:
|
||||
SCREEN.blit(baker_warrior_character.load, (X_AXIS//4.2, Y_AXIS//1.99))
|
||||
|
||||
if X_AXIS > Y_AXIS: SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[3]} {fight.hero[3].name}", False, color_names), (X_AXIS//4, Y_AXIS//1.45))
|
||||
else: SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[3]}", False, color_names), (X_AXIS//3.6, Y_AXIS//1.45))
|
||||
|
||||
if fight.hero_life[0] < -1: fight.hero_life[0] = 0
|
||||
if fight.hero_life[1] < -1: fight.hero_life[1] = 0
|
||||
if fight.hero_life[2] < -1: fight.hero_life[2] = 0 #pour pas depasser vers les nombres négatifs
|
||||
if fight.hero_life[3] < -1: fight.hero_life[3] = 0
|
||||
|
||||
if len(fight.ennemies) == 1:
|
||||
if fight.ennemies_life[0] > 0:
|
||||
SCREEN.blit(monster.load, (X_AXIS//1.5,Y_AXIS//2.7))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.ennemies[0].name} {fight.ennemies_life[0]}", False, (255, 255, 255)), (X_AXIS//1.3,Y_AXIS//1.33))
|
||||
|
||||
elif len(fight.ennemies) == 2:
|
||||
if fight.ennemies_life[0] > 0:
|
||||
SCREEN.blit(monster.load, (X_AXIS//1.5, Y_AXIS//5))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.ennemies[0].name} {fight.ennemies_life[0]}", False, (255, 255, 255)), (X_AXIS//1.31, Y_AXIS//3.3))
|
||||
|
||||
if fight.ennemies_life[1] > 0:
|
||||
SCREEN.blit(monster.load, (X_AXIS//1.5, Y_AXIS//2.4))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.ennemies[1].name} {fight.ennemies_life[1]}", False, (255, 255, 255)), (X_AXIS//1.31, Y_AXIS//1.24)) #si la liste des ennemies est égal à 2
|
||||
|
||||
elif len(fight.ennemies) == 3:
|
||||
if fight.ennemies_life[0] > 0:
|
||||
SCREEN.blit(monster.load, (X_AXIS//1.41, Y_AXIS//5))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.ennemies[0].name}{fight.ennemies_life[0]}", False, (255, 255, 255)), (X_AXIS//1.235, Y_AXIS//3.3))
|
||||
|
||||
if fight.ennemies_life[1] > 0:
|
||||
SCREEN.blit(monster.load, (X_AXIS//1.41, Y_AXIS//2.45))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.ennemies[1].name} {fight.ennemies_life[1]}", False, (255, 255, 255)), (X_AXIS//1.235, Y_AXIS//1.24)) #si la liste des ennemies est égal à 1
|
||||
|
||||
if fight.ennemies_life[2] > 0:
|
||||
SCREEN.blit(monster.load, (X_AXIS//1.7, Y_AXIS//3))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.ennemies[2].name} {fight.ennemies_life[2]}", False, (255, 255, 255)), (X_AXIS//1.46, Y_AXIS//2.27))
|
||||
|
||||
if fight.is_playing(): #si c'est autour des héros
|
||||
menu_closed = Page(X_AXIS//1.78, Y_AXIS//15.5, X_AXIS//2.5, Y_AXIS//12, (37, 40, 80))
|
||||
if game_choice: #la fenetre
|
||||
SCREEN.blit(Image("menu.png", (X_AXIS//2, Y_AXIS//1.07)).load, (X_AXIS//1.95, Y_AXIS//21))
|
||||
|
||||
if main_choice:
|
||||
attack_button = Page(X_AXIS//1.62, Y_AXIS//4, X_AXIS//3.5, Y_AXIS//9, color_attack_button)
|
||||
inventory_button = Page(X_AXIS//1.62, Y_AXIS//2.5, X_AXIS//3.5, Y_AXIS//9, color_heal_button)
|
||||
|
||||
if X_AXIS > Y_AXIS:
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//50 + Y_AXIS//50)).render("ATTACK", False, (255, 255, 255)), (X_AXIS//1.42, Y_AXIS//3.75))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//50 + Y_AXIS//50)).render("INVENTORY", False, (255, 255, 255)), (X_AXIS//1.48, Y_AXIS//2.4))
|
||||
else:
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//100 + Y_AXIS//100)).render("ATTACK", False, (255, 255, 255)), (X_AXIS//1.42, Y_AXIS//3.75)) #le menu principal de la fenetre
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//100 + Y_AXIS//100)).render("INVENTORY", False, (255, 255, 255)), (X_AXIS//1.48, Y_AXIS//2.4))
|
||||
|
||||
if_cursor = 0
|
||||
if attack_button.collision(x, y): color_attack_button = (123, 95, 67)
|
||||
else: color_attack_button = (86, 66, 46)
|
||||
|
||||
if inventory_button.collision(x, y): color_heal_button = (123, 95, 67)
|
||||
else: color_heal_button = (86, 66, 46)
|
||||
|
||||
if inventory_button.collision(x, y) and click_cursor: inventory_opened = True
|
||||
if attack_button.collision(x, y) and click_cursor: game_choice = False
|
||||
|
||||
if inventory_opened:
|
||||
healing_potion_color = Page(X_AXIS//1.62, Y_AXIS//6, X_AXIS//3.5, Y_AXIS//25, healing_potion_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"0{len(baker_inventory.content[5])}", False, (255, 255, 255)), (X_AXIS//1.2, Y_AXIS//6)) #le menu inventaire de la fenetre
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"healing potion", False, (255, 255, 255)), (X_AXIS//1.55, Y_AXIS//6))
|
||||
|
||||
if healing_potion_color.collision(x, y) and click_cursor and len(baker_inventory.content[5]) > 0:
|
||||
healing_potion_chosen = True
|
||||
game_choice = False
|
||||
|
||||
knife_color = Page(X_AXIS//1.62, Y_AXIS//2.23, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"0{len(baker_inventory.content[0])}", False, (255, 255, 255)), (X_AXIS//1.2, Y_AXIS//2.23))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render("knife", False, (255, 255, 255)), (X_AXIS//1.55, Y_AXIS//2.23))
|
||||
if knife_color.collision(x, y) and click_cursor:
|
||||
inventory_opened = False
|
||||
knife_chosen = True
|
||||
|
||||
sword_color = Page(X_AXIS//1.62, Y_AXIS//4.5, X_AXIS//3.5, Y_AXIS//25, sword_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"0{len(baker_inventory.content[1])}", False, (255, 255, 255)), (X_AXIS//1.2, Y_AXIS//4.5))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render("sword", False, (255, 255, 255)), (X_AXIS//1.55, Y_AXIS//4.5))
|
||||
if sword_color.collision(x, y) and click_cursor:
|
||||
inventory_opened = False
|
||||
sword_chosen = True
|
||||
|
||||
bow_color = Page(X_AXIS//1.62, Y_AXIS//3.6, X_AXIS//3.5, Y_AXIS//25, bow_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"0{len(baker_inventory.content[2])}", False, (255, 255, 255)), (X_AXIS//1.2, Y_AXIS//3.6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render("bow", False, (255, 255, 255)), (X_AXIS//1.55, Y_AXIS//3.6))
|
||||
if bow_color.collision(x, y) and click_cursor:
|
||||
inventory_opened = False
|
||||
bow_chosen = True
|
||||
|
||||
crossbow_color = Page(X_AXIS//1.62, Y_AXIS//3, X_AXIS//3.5, Y_AXIS//25, crossbow_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"0{len(baker_inventory.content[3])}", False, (255, 255, 255)), (X_AXIS//1.2, Y_AXIS//3))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render("crossbow", False, (255, 255, 255)), (X_AXIS//1.55, Y_AXIS//3))
|
||||
if crossbow_color.collision(x, y) and click_cursor:
|
||||
inventory_opened = False
|
||||
crossbow_chosen = True
|
||||
|
||||
magic_stick_color = Page(X_AXIS//1.62, Y_AXIS//2.55, X_AXIS//3.5, Y_AXIS//25, magic_stick_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"0{len(baker_inventory.content[4])}", False, (255, 255, 255)), (X_AXIS//1.2, Y_AXIS//2.55))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render("magic stick", False, (255, 255, 255)), (X_AXIS//1.55, Y_AXIS//2.55))
|
||||
if magic_stick_color.collision(x, y) and click_cursor:
|
||||
inventory_opened = False
|
||||
magic_stick_chosen = True
|
||||
|
||||
if knife_color.collision(x, y): knife_color_page = (123, 95, 67)
|
||||
else: knife_color_page = (86, 66, 46)
|
||||
|
||||
if sword_color.collision(x, y): sword_color_page = (123, 95, 67)
|
||||
else: sword_color_page = (86, 66, 46)
|
||||
|
||||
if bow_color.collision(x, y): bow_color_page = (123, 95, 67)
|
||||
else: bow_color_page = (86, 66, 46)
|
||||
|
||||
if crossbow_color.collision(x, y): crossbow_color_page = (123, 95, 67) #pour faire les animations quand on passe la souris sur les boutons
|
||||
else: crossbow_color_page = (86, 66, 46)
|
||||
|
||||
if magic_stick_color.collision(x, y): magic_stick_color_page = (123, 95, 67)
|
||||
else: magic_stick_color_page = (86, 66, 46)
|
||||
|
||||
if healing_potion_color.collision(x, y) and len(baker_inventory.content[5]) > 0:
|
||||
healing_potion_color_page = (255, 0, 0)
|
||||
|
||||
main_choice = False
|
||||
if healing_potion_color.collision(x, y): healing_potion_color_page = (123, 95, 67)
|
||||
else: healing_potion_color_page = (86, 66, 46)
|
||||
|
||||
if menu_closed.collision(x, y): if_cursor = 2
|
||||
else: if_cursor = 0
|
||||
|
||||
if menu_closed.collision(x, y) and click_cursor: #revenir sur le menu principal quand on est dans l'inventaire
|
||||
main_choice = True
|
||||
inventory_opened = False
|
||||
|
||||
if knife_chosen:
|
||||
if len(baker_inventory.content[0]) == 0:
|
||||
inventory_opened = True
|
||||
knife_chosen = False
|
||||
|
||||
if menu_closed.collision(x, y) and click_cursor:
|
||||
knife_chosen = False
|
||||
inventory_opened = True
|
||||
|
||||
if menu_closed.collision(x, y): if_cursor = 2
|
||||
else: if_cursor = 0
|
||||
|
||||
if len(baker_inventory.content[0]) >= 1:
|
||||
Page(X_AXIS//1.62, Y_AXIS//6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[0][0].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[0][0].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//6))
|
||||
|
||||
if len(baker_inventory.content[0]) >= 2:
|
||||
Page(X_AXIS//1.62, Y_AXIS//4.5, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[0][1].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//4.5))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[0][1].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//4.5))
|
||||
|
||||
if len(baker_inventory.content[0]) >= 3:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3.6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[0][2].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3.6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[0][2].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3.6))
|
||||
|
||||
|
||||
if len(baker_inventory.content[0]) == 4:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[0][3].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[0][3].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3))
|
||||
|
||||
if sword_chosen:
|
||||
if len(baker_inventory.content[1]) == 0:
|
||||
inventory_opened = True
|
||||
sword_chosen = False
|
||||
|
||||
if menu_closed.collision(x, y) and click_cursor:
|
||||
sword_chosen = False
|
||||
inventory_opened = True
|
||||
|
||||
if menu_closed.collision(x, y): if_cursor = 2
|
||||
else: if_cursor = 0
|
||||
|
||||
if len(baker_inventory.content[1]) >= 1:
|
||||
Page(X_AXIS//1.62, Y_AXIS//6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[1][0].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[1][0].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//6))
|
||||
|
||||
if len(baker_inventory.content[1]) >= 2:
|
||||
Page(X_AXIS//1.62, Y_AXIS//4.5, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[1][1].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//4.5))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[1][1].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//4.5))
|
||||
|
||||
if len(baker_inventory.content[1]) >= 3:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3.6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[1][2].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3.6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[1][2].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3.6))
|
||||
|
||||
|
||||
if len(baker_inventory.content[1]) == 4:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[1][3].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[1][3].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3))
|
||||
|
||||
|
||||
if bow_chosen:
|
||||
if len(baker_inventory.content[2]) == 0:
|
||||
inventory_opened = True
|
||||
bow_chosen = False
|
||||
|
||||
if menu_closed.collision(x, y) and click_cursor:
|
||||
bow_chosen = False
|
||||
inventory_opened = True
|
||||
|
||||
if menu_closed.collision(x, y): if_cursor = 2
|
||||
else: if_cursor = 0
|
||||
|
||||
if len(baker_inventory.content[2]) >= 1:
|
||||
Page(X_AXIS//1.62, Y_AXIS//6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[2][0].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[2][0].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//6))
|
||||
|
||||
if len(baker_inventory.content[2]) >= 2:
|
||||
Page(X_AXIS//1.62, Y_AXIS//4.5, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[2][1].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//4.5))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[2][1].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//4.5))
|
||||
|
||||
if len(baker_inventory.content[2]) >= 3:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3.6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[2][2].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3.6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[2][2].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3.6))
|
||||
|
||||
|
||||
if len(baker_inventory.content[2]) == 4:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[2][3].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[2][3].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3))
|
||||
|
||||
if crossbow_chosen:
|
||||
if len(baker_inventory.content[3]) == 0:
|
||||
inventory_opened = True
|
||||
crossbow_chosen = False
|
||||
|
||||
if menu_closed.collision(x, y) and click_cursor:
|
||||
crossbow_chosen = False
|
||||
inventory_opened = True
|
||||
|
||||
if menu_closed.collision(x, y): if_cursor = 2
|
||||
else: if_cursor = 0
|
||||
|
||||
if len(baker_inventory.content[3]) >= 1:
|
||||
Page(X_AXIS//1.62, Y_AXIS//6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[3][0].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[3][0].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//6))
|
||||
|
||||
if len(baker_inventory.content[3]) >= 2:
|
||||
Page(X_AXIS//1.62, Y_AXIS//4.5, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[3][1].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//4.5))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[3][1].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//4.5))
|
||||
|
||||
if len(baker_inventory.content[3]) >= 3:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3.6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[3][2].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3.6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[3][2].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3.6))
|
||||
|
||||
|
||||
if len(baker_inventory.content[3]) == 4:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[3][3].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[3][3].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3))
|
||||
|
||||
if magic_stick_chosen:
|
||||
if len(baker_inventory.content[4]) == 0:
|
||||
inventory_opened = True
|
||||
magic_stick_chosen = False
|
||||
|
||||
if menu_closed.collision(x, y) and click_cursor:
|
||||
magic_stick_chosen = False
|
||||
inventory_opened = True
|
||||
|
||||
if menu_closed.collision(x, y): if_cursor = 2
|
||||
else: if_cursor = 0
|
||||
|
||||
if len(baker_inventory.content[2]) >= 1:
|
||||
Page(X_AXIS//1.62, Y_AXIS//6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[4][0].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[4][0].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//6))
|
||||
|
||||
if len(baker_inventory.content[2]) >= 2:
|
||||
Page(X_AXIS//1.62, Y_AXIS//4.5, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[4][1].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//4.5))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[4][1].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//4.5))
|
||||
|
||||
if len(baker_inventory.content[2]) >= 3:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3.6, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[4][2].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3.6))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[4][2].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3.6))
|
||||
|
||||
|
||||
if len(baker_inventory.content[2]) == 4:
|
||||
Page(X_AXIS//1.62, Y_AXIS//3, X_AXIS//3.5, Y_AXIS//25, knife_color_page)
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"damage: {baker_inventory.content[4][3].damage}", False, (255, 255, 255)), (X_AXIS//1.62, Y_AXIS//3))
|
||||
SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//75 + Y_AXIS//75)).render(f"durability: {baker_inventory.content[4][3].durability}", False, (255, 255, 255)), (X_AXIS//1.34, Y_AXIS//3))
|
||||
|
||||
elif healing_potion_chosen and game_choice == False:
|
||||
SCREEN.blit(Image("menu_closed.png", (X_AXIS//2, Y_AXIS//1.07)).load, (X_AXIS//1.95, Y_AXIS//21))
|
||||
|
||||
if menu_closed.collision(x, y) and click_cursor:
|
||||
game_choice = True
|
||||
healing_potion_chosen = False
|
||||
elif menu_closed.collision(x, y): if_cursor = 2
|
||||
else: if_cursor = 1
|
||||
|
||||
if baker_archer_collision.collision(x, y) and fight.hero_life[0] > 0:
|
||||
SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//10,Y_AXIS//2.5))
|
||||
if_cursor = 2
|
||||
|
||||
if baker_archer_collision.collision(x, y) and fight.hero_life[0] > 0 and click_cursor:
|
||||
fight.hero_life[0] += healing_potion.heal
|
||||
if len(baker_inventory.content[5]) == 1:
|
||||
baker_inventory.content.remove(baker_inventory.content[5][0])
|
||||
if len(baker_inventory.content[5]) == 2:
|
||||
baker_inventory.content.remove(baker_inventory.content[5][1])
|
||||
fight.current_round += 1
|
||||
healing_potion_chosen = False
|
||||
game_choice = True
|
||||
|
||||
if baker_warrior_collision.collision(x, y) and fight.hero_life[3] > 0:
|
||||
SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//3.75,Y_AXIS//2.35))
|
||||
if_cursor = 2
|
||||
|
||||
if baker_warrior_collision.collision(x, y) and fight.hero_life[3] > 0 and click_cursor:
|
||||
fight.hero_life[3] += healing_potion.heal
|
||||
if len(baker_inventory.content[5]) == 1:
|
||||
baker_inventory.content.remove(baker_inventory.content[5][0])
|
||||
if len(baker_inventory.content[5]) == 2:
|
||||
baker_inventory.content.remove(baker_inventory.content[5][1])
|
||||
fight.current_round += 1
|
||||
healing_potion_chosen = False
|
||||
game_choice = True
|
||||
|
||||
if baker_dwarf_collision.collision(x, y) and fight.hero_life[1] > 0:
|
||||
SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//5.5,Y_AXIS//1.9))
|
||||
if_cursor = 2
|
||||
|
||||
if baker_dwarf_collision.collision(x, y) and fight.hero_life[1] > 0 and click_cursor:
|
||||
fight.hero_life[1] += healing_potion.heal
|
||||
if len(baker_inventory.content[5]) == 1:
|
||||
baker_inventory.content.remove(baker_inventory.content[5][0])
|
||||
if len(baker_inventory.content[5]) == 2:
|
||||
baker_inventory.content.remove(baker_inventory.content[5][1])
|
||||
fight.current_round += 1
|
||||
healing_potion_chosen = False
|
||||
game_choice = True
|
||||
|
||||
if baker_magician_collision.collision(x, y) and fight.hero_life[2] > 0:
|
||||
SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//5,Y_AXIS//3.4))
|
||||
if_cursor = 2
|
||||
|
||||
if baker_magician_collision.collision(x, y) and fight.hero_life[2] > 0 and click_cursor:
|
||||
fight.hero_life[2] += healing_potion.heal
|
||||
if len(baker_inventory.content[5]) == 1:
|
||||
baker_inventory.content.remove(baker_inventory.content[5][0])
|
||||
if len(baker_inventory.content[5]) == 2:
|
||||
baker_inventory.content.remove(baker_inventory.content[5][1])
|
||||
fight.current_round += 1
|
||||
healing_potion_chosen = False
|
||||
game_choice = True
|
||||
|
||||
elif game_choice == False and healing_potion_chosen == False:
|
||||
SCREEN.blit(Image("menu_closed.png", (X_AXIS//2, Y_AXIS//1.07)).load, (X_AXIS//1.95, Y_AXIS//21))
|
||||
|
||||
if menu_closed.collision(x, y) and click_cursor: game_choice = True
|
||||
elif baker_archer_collision.collision(x, y): if_cursor = 3
|
||||
elif baker_warrior_collision.collision(x, y): if_cursor = 3
|
||||
elif baker_dwarf_collision.collision(x, y): if_cursor = 3
|
||||
elif baker_magician_collision.collision(x, y): if_cursor = 3
|
||||
elif menu_closed.collision(x, y): if_cursor = 2
|
||||
else: if_cursor = 1
|
||||
|
||||
if len(fight.ennemies) == 1:
|
||||
if monster_1.collision(x, y) and fight.ennemies_life[0] > 0: SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//1.28,Y_AXIS//2.35))
|
||||
|
||||
if monster_1.collision(x, y) and click_cursor:
|
||||
animation_launched = True
|
||||
monster1_attack = True
|
||||
|
||||
if len(fight.ennemies) == 2:
|
||||
if monster_1.collision(x, y) and fight.ennemies_life[0] > 0: SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//1.28,Y_AXIS//4.5))
|
||||
if monster_2.collision(x, y) and fight.ennemies_life[1] > 0: SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//1.28,Y_AXIS//2.28))
|
||||
|
||||
if monster_1.collision(x, y) and click_cursor:
|
||||
animation_launched = True
|
||||
monster1_attack = True
|
||||
|
||||
if monster_2.collision(x, y) and click_cursor:
|
||||
animation_launched = True
|
||||
monster2_attack = True
|
||||
|
||||
if len(fight.ennemies) == 3:
|
||||
if monster_1.collision(x, y) and fight.ennemies_life[0] > 0: SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//1.22,Y_AXIS//4.5))
|
||||
if monster_2.collision(x, y) and fight.ennemies_life[1] > 0: SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//1.22,Y_AXIS//2.28))
|
||||
if monster_3.collision(x, y) and fight.ennemies_life[2] > 0: SCREEN.blit(Image("pointer.png", (X_AXIS//50, Y_AXIS//18)).load, (X_AXIS//1.43,Y_AXIS//2.7))
|
||||
|
||||
if monster_1.collision(x, y) and click_cursor:
|
||||
animation_launched = True
|
||||
monster1_attack = True
|
||||
|
||||
if monster_2.collision(x, y) and click_cursor:
|
||||
animation_launched = True
|
||||
monster2_attack = True
|
||||
|
||||
if monster_3.collision(x, y) and click_cursor:
|
||||
animation_launched = True
|
||||
monster3_attack = True
|
||||
|
||||
if animation_launched:
|
||||
attack_animation += 1
|
||||
|
||||
if attack_animation >= round(Clock.get_fps())//2:
|
||||
attack_animation = 0
|
||||
animation += 1
|
||||
|
||||
if monster1_attack and fight.ennemies_life[0] > 0:
|
||||
if animation == 3:
|
||||
fight.ennemies_life[0] -= fight.round[fight.current_round].punch_damage
|
||||
print(fight.round[fight.current_round].name, "attacked", fight.ennemies[0].name)
|
||||
|
||||
|
||||
animation = 0
|
||||
fight.current_round += 1
|
||||
animation_launched = False
|
||||
game_choice = True
|
||||
monster1_attack = False
|
||||
else:
|
||||
if_cursor = 0
|
||||
game_choice = False
|
||||
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.round[fight.current_round].name} attacked {fight.ennemies[0].name}", False, (255, 255, 255)), (X_AXIS//1.8, Y_AXIS//2.5))
|
||||
|
||||
if fight.round[fight.current_round] == baker_archer: SCREEN.blit(Image(heros[1][0][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_dwarf: SCREEN.blit(Image(heros[1][1][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_magician: SCREEN.blit(Image(heros[1][2][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_warrior: SCREEN.blit(Image(heros[1][3][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
|
||||
if monster2_attack and len(fight.ennemies) >= 2 and fight.ennemies_life[1] > 0:
|
||||
if animation == 3:
|
||||
fight.ennemies_life[1] -= fight.round[fight.current_round].punch_damage
|
||||
print(fight.round[fight.current_round].name, "attacked", fight.ennemies[1].name)
|
||||
|
||||
animation = 0
|
||||
|
||||
fight.current_round += 1
|
||||
animation_launched = False
|
||||
game_choice = True
|
||||
monster2_attack = False
|
||||
|
||||
else:
|
||||
if_cursor = 0
|
||||
game_choice = False
|
||||
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.round[fight.current_round].name} attacked {fight.ennemies[1].name}", False, (255, 255, 255)), (X_AXIS//1.8, Y_AXIS//2.5))
|
||||
|
||||
if fight.round[fight.current_round] == baker_archer: SCREEN.blit(Image(heros[1][0][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_dwarf: SCREEN.blit(Image(heros[1][1][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_magician: SCREEN.blit(Image(heros[1][2][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_warrior: SCREEN.blit(Image(heros[1][3][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
|
||||
if monster3_attack and len(fight.ennemies) == 3 and fight.ennemies_life[2] > 0:
|
||||
if animation == 3:
|
||||
fight.ennemies_life[2] -= fight.round[fight.current_round].punch_damage
|
||||
print(fight.round[fight.current_round].name, "attacked", fight.ennemies[2].name)
|
||||
|
||||
animation = 0
|
||||
monster3_attack = False
|
||||
fight.current_round += 1
|
||||
animation_launched = False
|
||||
game_choice = True
|
||||
else:
|
||||
if_cursor = 0
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.round[fight.current_round].name} attacked {fight.ennemies[2].name}", False, (255, 255, 255)), (X_AXIS//1.8, Y_AXIS//2.5))
|
||||
|
||||
game_choice = False
|
||||
if fight.round[fight.current_round] == baker_archer: SCREEN.blit(Image(heros[1][0][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_dwarf: SCREEN.blit(Image(heros[1][1][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_magician: SCREEN.blit(Image(heros[1][2][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
if fight.round[fight.current_round] == baker_warrior: SCREEN.blit(Image(heros[1][3][animation], (X_AXIS//10, Y_AXIS//5.5)).load, (X_AXIS//1.8, Y_AXIS//2))
|
||||
|
||||
if not fight.is_playing():
|
||||
monster_animation += 1
|
||||
if choice_hero:
|
||||
hero = random.randint( 0, len(fight.hero)-1)
|
||||
choice_hero = False
|
||||
|
||||
if monster_animation >= 2*( round(Clock.get_fps())//2):
|
||||
monster_animation = 0
|
||||
|
||||
fight.hero_life[hero] -= fight.round[fight.current_round].damage
|
||||
|
||||
print(fight.round[fight.current_round].name, "attacked", fight.hero[hero].name) #c'est autour des monstres
|
||||
fight.current_round += 1
|
||||
choice_hero = True
|
||||
else:
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.round[fight.current_round].name} attacked {fight.hero[hero].name}", False, (255, 255, 255)), (X_AXIS//2,Y_AXIS//2))
|
||||
|
||||
|
||||
Page(5, Y_AXIS//100, X_AXIS//7, Y_AXIS//25, (20, 20, 20))
|
||||
if fight.hero_life[0] > 0:
|
||||
Page(5 + X_AXIS//80, Y_AXIS//75, X_AXIS//7.4 - (X_AXIS//fight.hero_life[0]), Y_AXIS//30, (120,190,33))
|
||||
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[0]}/65", False, (255, 255, 255)), (X_AXIS//25, Y_AXIS//75))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero[0].name}", False, (255, 255, 255)), (X_AXIS//6.5, Y_AXIS//75))
|
||||
|
||||
Page(5, Y_AXIS//18, X_AXIS//7, Y_AXIS//25, (20, 20, 20))
|
||||
if fight.hero_life[1] > 0:
|
||||
Page(5 + X_AXIS//80, Y_AXIS//17, X_AXIS//7.65 - (X_AXIS//fight.hero_life[1]), Y_AXIS//30, (120,190,33))
|
||||
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[1]}/90", False, (255, 255, 255)), (X_AXIS//25, Y_AXIS//17))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero[1].name}", False, (255, 255, 255)), (X_AXIS//6.5, Y_AXIS//17))
|
||||
|
||||
Page(5, Y_AXIS//10, X_AXIS//7, Y_AXIS//25, (20, 20, 20)) #systeme de plus apparaitre lors que le pero n'a plus de vie
|
||||
if fight.hero_life[2] > 0:
|
||||
Page(5 + X_AXIS//80, Y_AXIS//9.7, X_AXIS//7.4 - (X_AXIS//fight.hero_life[2]), Y_AXIS//30, (120,190,33))
|
||||
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[2]}/60", False, (255, 255, 255)), (X_AXIS//25, Y_AXIS//9.7))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero[2].name}", False, (255, 255, 255)), (X_AXIS//6.5, Y_AXIS//9.7))
|
||||
|
||||
Page(5, Y_AXIS//7, X_AXIS//7, Y_AXIS//25, (20, 20, 20))
|
||||
if fight.hero_life[3] > 0:
|
||||
Page(5 + X_AXIS//80, Y_AXIS//6.85, X_AXIS//8 - (X_AXIS//fight.hero_life[3]), Y_AXIS//30, (120,190,33))
|
||||
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero_life[3]}/125", False, (255, 255, 255)), (X_AXIS//30, Y_AXIS//6.85))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"{fight.hero[3].name}", False, (255, 255, 255)), (X_AXIS//6.5, Y_AXIS//6.85))
|
||||
|
||||
if fight.hero_life[0] > 65: fight.hero_life[0] = 65
|
||||
if fight.hero_life[1] > 90: fight.hero_life[1] = 90
|
||||
if fight.hero_life[2] > 60: fight.hero_life[2] = 60
|
||||
if fight.hero_life[3] > 125: fight.hero_life[3] = 125
|
||||
|
||||
else:
|
||||
if end_music and pygame.mixer.music.get_pos() == 0:
|
||||
Music("phonk/phonk_fin.ogg", SOUND)
|
||||
end_music = False
|
||||
SCREEN.fill((0, 0, 0))
|
||||
if sum(fight.hero_life): SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//50 + Y_AXIS//50)).render("VICTORY", False, (255, 255, 255)), (X_AXIS//2.5, Y_AXIS//2.5))
|
||||
else: SCREEN.blit(pygame.font.SysFont('.\\Liberation Serif', (X_AXIS//50 + Y_AXIS//50)).render("DEFEAT", False, (255, 255, 255)), (X_AXIS//2.5, Y_AXIS//2.5))
|
||||
|
||||
else:
|
||||
if start_music:
|
||||
Music("phonk/phonk.ogg", SOUND) #la class music qui est utilisé avec la musique (créée)
|
||||
start_music = False
|
||||
|
||||
SCREEN.fill((0, 0, 0))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render("in a world with corruption and madness, our heros will chase the bread thief and retake their recipe of the bread sacred ", False, (255, 255, 255)), (X_AXIS//30, Y_AXIS//6.85))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render("they're going in a strange place and they discovered that", False, (255, 255, 255)), (X_AXIS//30, Y_AXIS//6)) #le lore du jeu
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render("even if someone die, if they have friend with them, he can help him even in death ", False, (255, 255, 255)), (X_AXIS//30, Y_AXIS//5.2))
|
||||
|
||||
cursor = Image(f'{crosshair[if_cursor]}', ( 26, 26))
|
||||
SCREEN.blit(cursor.load, (x, y))
|
||||
except Exception as error:
|
||||
|
||||
SCREEN.fill((0, 0, 0))
|
||||
SCREEN.blit(Text(X_AXIS, Y_AXIS).render(f"error {error}, the game needs to be restarted", False, (255, 255, 255)), (X_AXIS//30, Y_AXIS//6.85))
|
||||
|
||||
print(error)
|
||||
information(X_AXIS, Y_AXIS, Clock)
|
||||
|
||||
Clock.tick(FPS)
|
||||
pygame.display.flip() #le systeme d'image sur pygame
|
||||
pygame.display.update()
|
||||