-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaneteBeta.py
91 lines (72 loc) · 2.3 KB
/
planeteBeta.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import pygame
import show_screen
import planet
listePlanetes = []
nbPlanete = 50
black = [0, 0, 0]
white = [255, 255, 255]
xmax = 1000
ymax = 700
taille = [xmax, ymax]
screen = pygame.display.set_mode(taille)
def initDonnees():
automatique = True
for i in range(nbPlanete):
if automatique == False:
x = input("x" + str(i) + ":")
y = input("y" + str(i) + ":")
vx = input("vx" + str(i) + ":")
vy = input("vy" + str(i) + ":")
m = input("masse" + str(i) + ":")
else:
if i == 0:
m = 900
x = 600.0
y = 400.0
vx = 0
vy = 0
else:
m = 2.0
x = 600.0 # random.randrange(200,300)+1/float(i)
y = 400.0 - 20 * i # random.randrange(200,300)+1/float(i)
vx, vy = (20.0 - i) * (-1) ** i, 0
x = int(x)
y = int(y)
vx = int(vx)
vy = int(vy)
m = int(m)
def boucleAffichage(affichage):
done = False
while done == False:
done = affichage.evenement(listePlanetes)
affichage.effacer()
for planete in listePlanetes:
planete.afficher(affichage)
for planete in listePlanetes:
planete.deplacer(listePlanetes)
# on affiche a l utilisateur si les frottements sont présents ou non
file = open("frottements.txt")
chaine = ""
for line in file:
chaine += line
file.close()
if chaine == '0.99':
chaine = 0.99
elif chaine == '1.0':
chaine = 1.0
frottements = chaine
if frottements == 1.0:
font = pygame.font.Font(None, 25)
text1 = font.render("frottements desactives ", True, white)
screen.blit(text1, [730, 100])
elif frottements == 0.99:
font = pygame.font.Font(None, 25)
text1 = font.render("frottements activés ", True, white)
screen.blit(text1, [730, 100])
affichage.actualiser()
def main():
affichage = show_screen.Screen()
initDonnees()
boucleAffichage(affichage)
if __name__ == '__main__':
main()