Salut les pythons,
je me rend a vous après de multiples essaies de rafraîchir un écran de pygame contenant un triangle qui devrai disparaître afin que l'on puisse en dessiner un nouveau par la suite mais les méthodes:
-pygame.display.update()
-et même pygame.display.flip()Citation:
pygame.display.update
update portions of the screen for software displays
pygame.display.update(rectangle=None): return None
pygame.display.update(rectangle_list): return None
This function is like an optimized version of pygame.display.flip - update the full display Surface to the screen for software displays. It allows only a portion of the screen to updated, instead of the entire area. If no argument is passed it updates the entire Surface area like pygame.display.flip - update the full display Surface to the screen.
You can pass the function a single rectangle, or a sequence of rectangles. It is more efficient to pass many rectangles at once than to call update multiple times with single or a partial list of rectangles. If passing a sequence of rectangles it is safe to include None values in the list, which will be skipped.
This call cannot be used on pygame.OPENGL displays and will generate an exception.
Qui sont censés rafraîchir partiellement ou entièrement l'écran ca ne fonctionne pas et je débute avec ce module, j'ai essayer avec un objet qui contient les coordonnées du triangle comme attributs en espérant que la méthode pygame.display.update() mettrai a jours le triangle au lieu de ca il en dessine un nouveau...Citation:
pygame.display.flip
update the full display Surface to the screen
pygame.display.flip(): return None
This will update the contents of the entire display. If your display mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF, this will wait for a vertical retrace and swap the surfaces. If you are using a different type of display mode, it will simply update the entire contents of the surface.
When using an pygame.OPENGL display mode this will perform a gl buffer swap.
Je ne sais plus comment faire pour pouvoir effacer un élément inséré avec la classe pygame.draw...
Voici un code qui marche mais qui ne fait pas ce que j'attends de lui:
Je suis désespéré de ne même pas avoir de plan B...Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 # -*- coding: utf-8 -*- import pygame from pygame.locals import * from sys import exit pygame.init() screen=pygame.display.set_mode((800,600),0,32) #flache=pygame.Surface((800, 600)) Essaie avec une surface class Test() : def trieck(self,a=(150,150),b=(150,300),c=(300,150),i=0) : self.a_x=a[0] self.a_y=a[1] self.b_x=b[0] self.b_y=b[1] self.c_x=c[0] self.c_y=c[1] self.i=i+1 return [(self.a_x,self.a_y),(self.b_x,self.b_y),(self.c_x,self.c_y)] test=Test() test.trieck() koords=[] while True : for event in pygame.event.get() : if event.type == QUIT : exit() if event.type == MOUSEBUTTONDOWN : x,y=pygame.mouse.get_pos() koords.append((x,y)) test.i +=1 if test.i == 4 : koords_liste=test.trieck(koords[0],koords[1],koords[2],0) pygame.draw.polygon(screen,(255,0,0),[(test.a_x,test.a_y),(test.b_x,test.b_y),(test.c_x,test.c_y)]) # Essaie avec une surface # avec pygame.draw.polygon(flache,(255,0,0),[(test.a_x,test.a_y),(test.b_x,test.b_y),(test.c_x,test.c_y)]) #pygame.Surface.blit(screen,flache,(0,0)) Essaie avec une surface koords=[] pygame.display.flip() # cette methode ne rafraichis pas l'écran. pygame.display.update()
Avez vous eu des difficultés a assimilé ce module car pour moi c'est difficile d'arriver à ce que je veux ?
Merci pour vos réponses.