@@ -31,8 +31,8 @@ def getData():
31
31
32
32
time .sleep (2 )
33
33
34
- scene .width = 700
35
- scene .height = 700
34
+ scene .width = 1300
35
+ scene .height = 1000
36
36
scene .range = 20
37
37
38
38
ground = box (pos = vector (0 ,- 10.05 ,0 ), size = (40.0 ,1 ,1 ), color = color .white )
@@ -52,7 +52,11 @@ def getData():
52
52
FgravArrow = arrow (pos = spaceship .pos , axis = scale * spaceship .m * g , color = color .red )
53
53
FthrustArrow = arrow (pos = spaceship .pos , axis = Fthrust , color = color .cyan )
54
54
55
+ safespeed = 2
56
+
55
57
voltage = []
58
+ scene .waitfor ('click' )
59
+
56
60
57
61
while 1 :
58
62
rate (100 )
@@ -65,8 +69,22 @@ def getData():
65
69
spaceship .v = spaceship .v + (Fnet / spaceship .m )* dt
66
70
spaceship .pos = spaceship .pos + spaceship .v * dt
67
71
if (spaceship .pos .y - spaceship .height / 2 < ground .pos .y + ground .height / 2 ):
68
- print ("spaceship has landed, v= " , mag (spaceship .v ))
69
- break
72
+ print ("spaceship has landed, v= " ,spaceship .v , "speed= " , mag (spaceship .v ))
73
+ if (spaceship .pos .x > target .pos .x - target .size .x / 2 and spaceship .pos .x < target .pos .x + target .size .x / 2 and mag (spaceship .v )< safespeed and abs (spaceship .v .x )< 0.5 ):
74
+ message = label (pos = vector (0 ,0 ,0 ), text = "You Win! The spaceship landed safely!" )
75
+ else :
76
+ message = label (pos = vector (0 ,0 ,0 ), text = "The spaceship crashed! Bummer!" )
77
+ if (abs (spaceship .v .x )> 1 ):
78
+ message .text = message .text + "\n Your lateral landing speed was too large."
79
+ elif (mag (spaceship .v )> safespeed ):
80
+ message .text = message .text + "\n Your landing speed was too large."
81
+ scene .waitfor ('click' )
82
+ message .visible = 0
83
+ spaceship .v = vector (0 ,0 ,0 )
84
+ spaceship .pos = vector (- 10 ,8 ,0 )
85
+ Fthrust = vector (0 ,0 ,0 )
86
+ F = vector (0 ,0 ,0 )
87
+ t = 0
70
88
t = t + dt
71
89
FgravArrow .pos = spaceship .pos
72
90
FgravArrow .axis = scale * Fgrav
0 commit comments