# data[].attributes.headline
interaction entre fenêtre grâce aux boutons

# data[].attributes.subject
interaction entre fenêtre grâce aux boutons

# data[].attributes.body
Pro gammer

# data[].attributes.body
Abdelmalik

# data[].attributes.attachment_link.readable_text
import pygame
pygame.init()
window = pygame.display.set_mode((792,599))

img = pygame.image.load('Règles.png')
ico = pygame.image.load('tile.jpg')  
pygame.display.set_icon(ico)
pygame.display.set_caption('Tile Master-règles')

done = False
while not done:
    pygame.display.flip()
    window.blit(img,(0,0))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done=True
pygame.display.set_icon(img)


pygame.quit()

# data[].attributes.body
Scrum Master
co-développeur

# data[].attributes.body
Product Owner
co-développeur

# data[].attributes.body
co-développeur

# data[].attributes.body
le joueur écoute une suite de sons et doit essayer de la reproduire à l'aide d’un clavier les niveau se baseront sur la suite de Fibonacci.

niveau 1: 1 son.
niveau 2: 2 sons à la suite.
niveau 3: 3 sons à la suite.
niveau 4: 5 sons à la suite.
niveau 5: 8 sons à la suite.
niveau 6: 13 sons à la suite.
niveau 7: 21 sons à la suite.

# data[].attributes.body
mathieu

# data[].attributes.attachment_link.readable_text
from pygame import *
from dict import *
from classes import *
from random import randint
from user_interface import piano


def loop():
    """Ceci est la fonction principale du programme, qui gère tout ce qui se réfère à pygame

        Variables :
        screen : la fenêtre principale
        appRunning : une variable qui, tant qu'elle est vraie (cf. l. 41) fait fonctionner la fenêtre dans une boucle
    """

    init()

    mixer.set_num_channels(18)

    screen = display.set_mode((750, 750))

    appRunning = True

    ico = image.load('Images/tile.jpg')
    display.set_icon(ico)

    display.set_caption('Tile Master')

    def creer_melodie(nbNotes, meloBackup):
        """génère une mélodie aléatoire selon le nombre de notes"""
        melo = Pile()
        melo.contenu = meloBackup
        for i in range(nbNotes - len(meloBackup)):
            melo.empiler(notes[touches[randint(0, len(touches)-1)]])
        return melo

    def creer_melo_backup(melo):
        meloBackup = []
        for i in range(len(melo.contenu)):
            meloBackup.append(melo.contenu[i])
        return meloBackup

    def jouer_melodie(melo):
        """permet de jouer la mélodie choisie au hasard par l'ordinateur"""
        print(melo.contenu)
        for i in range(len(melo.contenu)):
            mixer.Channel(0).play(mixer.Sound(melo.contenu[i]))
            time.wait(750)

    def est_juste(note, melo):
        return note == melo[0]

    # définie le volume des chaînes à un certains volume pour éviter que le son sature
    for i in range(mixer.get_num_channels()):
        mixer.Channel(i).set_volume(0.75)

    nbNiveaux = 0
    nbNotes = 1
    fibo1 = 1
    fibo2 = 1

    piano(screen)
    display.flip()
    melodie = creer_melodie(nbNotes, [])
    print(melodie)
    melodieBackup = creer_melo_backup(melodie)
    melodieAJouer = melodie
    jouer_melodie(melodieAJouer)

    # boucle principale du programme
    while appRunning:
        for e in event.get():
            if e.type == QUIT:
                appRunning = False
            if e.type == KEYDOWN:
                if e.unicode in notes:
                    mixer.Channel(channelID[e.unicode]).play(mixer.Sound(notes[e.unicode]))
                    if est_juste(notes[e.unicode], melodie.contenu):
                        melodie.depiler()
                        if melodie.est_vide():
                            nbNiveaux += 1
                            if nbNiveaux == 7:
                                time.wait(500)
                                mixer.Channel(17).play(mixer.Sound("Sons/correct.wav"))
                                time.wait(1000)

                                appRunning = False
                            else:
                                time.wait(500)
                                mixer.Channel(17).play(mixer.Sound("Sons/correct.wav"))
                                time.wait(500)
                                nbNotes = fibo1 + fibo2
                                fibo1 = fibo2
                                fibo2 = nbNotes
                                melodie = creer_melodie(nbNotes, melodieBackup)
                                melodieAJouer = melodie
                                melodieBackup = creer_melo_backup(melodie)
                                jouer_melodie(melodieAJouer)
                if e.key == K_RETURN:
                    print(melodieBackup)
                    jouer_melodie(melodieAJouer)

    quit()

# data[].attributes.attachment_link.readable_text

import pygame

#button class
class Button():
	def __init__(self, x, y, image, scale):
		width = image.get_width()
		height = image.get_height()
		self.image = pygame.transform.scale(image, (int(width * scale), int(height * scale)))
		self.rect = self.image.get_rect()
		self.rect.topleft = (x, y)
		self.clicked = False

	def draw(self, surface):
		action = False
		#get mouse position
		pos = pygame.mouse.get_pos()

		#check mouseover and clicked conditions
		if self.rect.collidepoint(pos):
			if pygame.mouse.get_pressed()[0] == 1 and self.clicked == False:
				self.clicked = True
				action = True

		if pygame.mouse.get_pressed()[0] == 0:
			self.clicked = False

		#draw button on screen
		surface.blit(self.image, (self.rect.x, self.rect.y))

		return action



# data[].attributes.body
quelque chose de magnifique

# data[].attributes.attachment_link.readable_text
from random import randint

notes = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"]

melo = [notes[randint(1,len(notes)-1)] for loop in range(5)]

print(melo)

juste = 0

for i in range(len(melo)):
    noteSimple = input()
    if noteSimple != melo[i]:
        break
    juste += 1

print("Vous avez", juste, "notes justes !")

# data[].attributes.attachment_link.readable_text
import pygame
import button
from clavier import keyboard

def home():
	#create display window
	img = pygame.image.load('accueil.png')
	ico = pygame.image.load('tile.jpg')
	pygame.display.set_icon(ico)
	pygame.display.set_caption('Tile Master-accueil')

	screen = pygame.display.set_mode((792,599))


	#load button images
	start_img = pygame.image.load('start_btn.png').convert_alpha()
	exit_img = pygame.image.load('exit_btn.png').convert_alpha()

	#create button instances
	start_button = button.Button(100, 200, start_img, 0.8)
	exit_button = button.Button(450, 200, exit_img, 0.8)

	#game loop
	run = True
	while run:

		screen.blit(img,(0,0))
		if start_button.draw(screen):
			print('START')
		if exit_button.draw(screen):
			print('EXIT')

		#event handler
		for event in pygame.event.get():
			#quit game
			if event.type == pygame.QUIT:
				run = False

		pygame.display.update()

	pygame.quit()
home()

# data[].attributes.attachment_link.readable_text

import pygame


pygame.init()
screen=pygame.display.set_mode((750,750))


def draw():
    for i in range (10):
        pygame.draw.rect(screen, (255,255,255), (i*76,600,75,150))

    for i in range (7):
        pygame.draw.rect(screen, (0,0,0), (50+i*76,600,50,75))


########### cord ##############

c_pos_x=500
c_pos_y=152



######### loop ###########

run=True
while run:
    draw()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run=False

            ## key pressed ##

        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                run = False

            if event.key == pygame.K_h:

                c_pos_x=402
                c_pos_y=152
                hwav.play()

            if event.key == pygame.K_g:

                c_pos_x=315
                gwav.play()

            if event.key == pygame.K_f:

                c_pos_x=228
                fwav.play()

            if event.key == pygame.K_d:

                c_pos_x=141
                dwav.play()

            if event.key == pygame.K_s:

                c_pos_x=58
                swav.play()

            if event.key == pygame.K_a:

                c_pos_x=-22
                awav.play()

            #### key unpressed ####

        if event.type == pygame.KEYUP:
            if event.key == pygame.K_h or event.key == pygame.K_g or event.key == pygame.K_f or  event.key == pygame.K_d or event.key == pygame.K_s or event.key == pygame.K_a:
                 c_pos_x=500
                 c_pos_y=152

########## calling function ##########


    pygame.display.update()



pygame.quit()




# data[].attributes.attachment_link.readable_text
import pygame


pygame.init()
screen=pygame.display.set_mode((750,750))


def draw():
    for i in range (10):
        pygame.draw.rect(screen, (0,255,100), (i*76,600,75,150))

    for i in range (2):
        pygame.draw.rect(screen, (0,0,0), (50+i*76,600,50,80))
    pygame.draw.rect(screen, (0,0,0), (278,600,50,80))
    pygame.draw.rect(screen, (0,0,0), (355,600,50,80))
    pygame.draw.rect(screen, (0,0,0), (432,600,50,80))
    pygame.draw.rect(screen, (0,0,0), (582,600,50,80))
    pygame.draw.rect(screen, (0,0,0), (655,600,50,80))



c_pos_x=500
c_pos_y=152



######### loop ###########

run=True
while run:
    draw()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run=False

            ## key pressed ##

        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                run = False

            if event.key == pygame.K_h:

                c_pos_x=402
                c_pos_y=152
                hwav.play()

            if event.key == pygame.K_g:

                c_pos_x=315
                gwav.play()

            if event.key == pygame.K_f:

                c_pos_x=228
                fwav.play()

            if event.key == pygame.K_d:

                c_pos_x=141
                dwav.play()

            if event.key == pygame.K_s:

                c_pos_x=58
                swav.play()

            if event.key == pygame.K_a:

                c_pos_x=-22
                awav.play()

            #### key unpressed ####

        if event.type == pygame.KEYUP:
            if event.key == pygame.K_h or event.key == pygame.K_g or event.key == pygame.K_f or  event.key == pygame.K_d or event.key == pygame.K_s or event.key == pygame.K_a:
                 c_pos_x=500
                 c_pos_y=152

########## calling function ##########


    pygame.display.update()



pygame.quit()

# data[].attributes.attachment_link.readable_text

import pygame

#button class
class Button():
	def __init__(self, x, y, image, scale):
		width = image.get_width()
		height = image.get_height()
		self.image = pygame.transform.scale(image, (int(width * scale), int(height * scale)))
		self.rect = self.image.get_rect()
		self.rect.topleft = (x, y)
		self.clicked = False

	def draw(self, surface):
		action = False
		#get mouse position
		pos = pygame.mouse.get_pos()

		#check mouseover and clicked conditions
		if self.rect.collidepoint(pos):
			if pygame.mouse.get_pressed()[0] == 1 and self.clicked == False:
				self.clicked = True
				action = True

		if pygame.mouse.get_pressed()[0] == 0:
			self.clicked = False

		#draw button on screen
		surface.blit(self.image, (self.rect.x, self.rect.y))

		return action



# data[].attributes.attachment_link.readable_text
import pygame
import button


def home():
	#create display window
	img = pygame.image.load('accueil.png')
	ico = pygame.image.load('tile.jpg')
	pygame.display.set_icon(ico)
	pygame.display.set_caption('Tile Master-accueil')

	screen = pygame.display.set_mode((792,599))


	#load button images
	start_img = pygame.image.load('start_btn.png').convert_alpha()
	exit_img = pygame.image.load('exit_btn.png').convert_alpha()

	#create button instances
	start_button = button.Button(100, 450, start_img, 0.8)
	exit_button = button.Button(450, 450, exit_img, 0.8)

	#game loop
	run = True
	while run:

		screen.blit(img,(0,0))
		if start_button.draw(screen):
			print('START')
		if exit_button.draw(screen):
			run=False

		#event handler
		for event in pygame.event.get():
			#quit game
			if event.type == pygame.QUIT:
				run = False

		pygame.display.update()

	pygame.quit()
home()