CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

[Python] Explication d'un programme

mrpsicopate
mrpsicopate
Niveau 9
14 mai 2017 à 17:53:45

Salut salut !

Je cherche à comprendre comment fonctionne un bout de programme trouvé sur internet :)
Je comprends plusieurs ligne mais certaines me sont totalement étrangère !

Le code :

def texte1(variables):
myfont = pygame.font.Font(None, 40)
text = [myfont.render('Cliquez sur ENTREZ pour jouer.', True, text_col),
myfont.render(' ', True, text_col)]
ticks0 = pygame.time.get_ticks()
clignotement = 1
while clignotement == 1:
fenetre.blit(accueil, (0,0))
seconds = int((pygame.time.get_ticks() - ticks0)/1000)
n_image = seconds%2
my_image = text[n_image]
rect = my_image.get_rect()
rect.center = [400, 400]
fenetre.blit(my_image, rect)
pygame.display.flip()
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_RETURN:
clignotement = 0
Lancement.play()
if event.type == QUIT:
clignotement = 0
pygame.quit()

Je cherche à comprendre comme fonctionne les lignes avec myfont, rect et comment le programme comptabilise le temps passé ( la vitesse de clignotement ).

Merci d'avance :) !

MrBeauf
MrBeauf
Niveau 7
15 mai 2017 à 12:47:31

S'il était indenté ce serait mieux, en plus pour du python :hap:

Ebara
Ebara
Niveau 16
15 mai 2017 à 14:38:14

Utilise pastebin...

mrpsicopate
mrpsicopate
Niveau 9
15 mai 2017 à 19:23:50

Désolé oui jvc à supprimé les indentations ! ;'(

def texte1(variables):
        myfont = pygame.font.Font(None, 40)
        text = [myfont.render('Cliquez sur ENTREZ pour jouer.', True, text_col),
        myfont.render('                                ', True, text_col)]
        ticks0 = pygame.time.get_ticks()
        clignotement = 1
        while clignotement == 1:
            fenetre.blit(accueil, (0,0))
            seconds = int((pygame.time.get_ticks() - ticks0)/1000)
            n_image = seconds%2
            my_image = text[n_image]
            rect = my_image.get_rect()
            rect.center = [400, 400]
            fenetre.blit(my_image, rect)
            pygame.display.flip()
            for event in pygame.event.get():
                if event.type == KEYDOWN:
                    if event.key == K_RETURN:
                        clignotement = 0
                        Lancement.play()
                if event.type == QUIT:
                    clignotement = 0
                    pygame.quit()
Message édité le 15 mai 2017 à 19:24:10 par mrpsicopate
Sous forums
  • Aide à l'achat Mac
  • Macintosh
  • Création de Jeux
  • Programmation
  • Création de sites web
  • Linux
  • Internet
  • Steam Deck
  • Hardware
La vidéo du moment