mirror of
https://github.com/guezoloic/BakersAdventure.git
synced 2026-03-29 02:03:45 +00:00
add oldproject folder
This commit is contained in:
69
game/fight.py
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
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
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
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
|
||||
|
||||
Reference in New Issue
Block a user